@@ -0,0 +1,2384 @@
+# A simple loadtest using locust.%0A# launch using: locust -f simpleloadtest.py --host=http://pencilcode.net%0A%0Afrom locust import HttpLocust, TaskSet, task%0Aimport simplejson, random%0A%0Aclass MyTaskSet(TaskSet):%0A    def userbase(self, user):%0A      return self.client.base_url.replace('//', '//' + user + '.')%0A%0A    def topget(self, url):%0A      return self.client.get(url, headers=%7B%22User-Agent%22:%22locust%22%7D)%0A%0A    def myget(self, user, url):%0A      return self.client.get(self.userbase(user) + url,%0A          headers=%7B%22User-Agent%22:%22locust%22%7D)%0A%0A    def mypost(self, user, url, data):%0A      return self.client.post(self.userbase(user) + url, data,%0A          headers=%7B%22User-Agent%22:%22locust%22%7D)%0A%0A    # @task(1)%0A    def index(self):%0A        for url in %5B'/', '/welcome.css', '/image/vpencil-20-64.png',%0A            '/image/art.png', '/image/music.png', '/image/adventure.png',%0A            '/lib/jquery.js', '/lib/jquery.autocomplete.min.js',%0A            '/load/?callback=loadusers'%5D:%0A          self.topget(url)%0A        for url in %5B'/home/promo1', '/home/goldwheel-code.png',%0A            '/lib/seedrandom.js', '/turtlebits.js'%5D:%0A          self.myget('promo', url)%0A%0A    # @task(1)%0A    def edit(self):%0A        topdir = self.topget(%22/load/%22).json()%0A        randuser = random.choice(topdir%5B'list'%5D)%0A        randname = randuser%5B'name'%5D%0A        if 'd' not in randuser%5B'mode'%5D:%0A          return%0A        for url in %5B'/edit/', '/editor.js', '/favicon.ico',%0A            '/apple-touch-icon.png', '/load'%5D:%0A          mydir = self.myget(randname, url)%0A%0A    @task(1)%0A    def browserandom(self):%0A        topdir = self.topget(%22/load/%22).json()%0A        randuser = random.choice(topdir%5B'list'%5D)%0A        randname = randuser%5B'name'%5D%0A        if 'd' in randuser%5B'mode'%5D:%0A          try:%0A            mydir = self.myget(randname, '/load/').json()%0A          except:%0A            print 'error listing', randuser%0A            return%0A          randfile = random.choice(mydir%5B'list'%5D)%5B'name'%5D%0A          try:%0A            self.myget(randname, '/load/' + randfile).json()%0A          except:%0A            print 'error reading', randuser, randfile%0A%0A    @task(1)%0A    def livetestsave(self):%0A        myok = self.mypost('livetest', '/save/loadtest', %7B%0A          'data': 'pen red%5Cnfor %5B1..4%5D%5Cn  fd 100%5Cn  rt 90',%0A          'key': '123'%0A        %7D).json()%0A%0Aclass MyLocust(HttpLocust):%0A    task_set = MyTaskSet%0A    min_wait =  5000%0A    max_wait = 15000%0A

Add a simple load test.