def get(self, project_name, test_name): project = Project.objects(name=project_name).get() test = Test.objects(project=project, name=test_name).get() # transforms 30:60:90 in [10:20:30, 10:20:30, 10:20:30] test_cycles = [':'.join([str(int(cycle) / test.number_of_workers) for cycle in test.cycles.split(':')])] \ * test.number_of_workers result = TestResult(test=test, number_of_workers=test.number_of_workers, created_date=datetime.now()) result.stats = TestStats() for index, worker in enumerate(range(test.number_of_workers)): test_cycle = test_cycles[index] run = TestRun(uuid=str(uuid4()), git_repo = project.git_repo, module = test.module, test_class = test.test_class, server_url = test.server_url, cycles = test_cycle, cycle_duration = test.cycle_duration) result.runs.append(run) result.save() self.redirect('/?test_scheduled=true')
def get(self, project_name, test_name): project = Project.objects(name=project_name).get() test = Test.objects(project=project, name=test_name).get() # transforms 30:60:90 in [10:20:30, 10:20:30, 10:20:30] test_cycles = [':'.join([str(int(cycle) / test.number_of_workers) for cycle in test.cycles.split(':')])] \ * test.number_of_workers result = TestResult(test=test, number_of_workers=test.number_of_workers, created_date=datetime.now()) result.stats = TestStats() for index, worker in enumerate(range(test.number_of_workers)): test_cycle = test_cycles[index] run = TestRun(uuid=str(uuid4()), git_repo=project.git_repo, module=test.module, test_class=test.test_class, server_url=test.server_url, cycles=test_cycle, cycle_duration=test.cycle_duration) result.runs.append(run) result.save() self.redirect('/?test_scheduled=true')
def post(self): name = self.get_argument('name', '') git_repo = self.get_argument('gitrepo', '') errors = [] if not name: errors.append('name') if not git_repo: errors.append('gitrepo') if errors: self.render('rockload/apps/main/new_project.html', errors=errors, values={ 'name': name, 'gitrepo': git_repo }) else: prj = Project(name=name, git_repo=git_repo, created_at=datetime.now(), owner=self.get_current_user()) prj.save() self.redirect('/projects/%s' % quote(name))
def get(self, project_name): all_projects = self.all_projects() project = Project.objects(name=project_name).get() tests = Test.objects(project=project).all() if tests: self.render('rockload/apps/main/project_details.html', projects=all_projects(), project=project, tests=tests) else: self.render('rockload/apps/main/no_tests.html', projects=all_projects(), project=project)
def get(self, project_name, test_name, test_result_id): project = Project.objects(name=project_name).get() test = Test.objects(project=project, name=test_name).get() test_result = TestResult.objects(test=test, id=ObjectId(test_result_id)) test_result.delete() test.update_stats() self.redirect('/?test-deleted=True')
def post(self, project_name): project = Project.objects(name=project_name).get() name = self.get_argument('name', '') module = self.get_argument('module', '') test_class = self.get_argument('test_class', '') server_url = self.get_argument('server_url', '') cycles = self.get_argument('cycles', '') try: cycle_duration = float(self.get_argument('cycle_duration', '')) except ValueError: cycle_duration = 0 try: number_of_workers = int(self.get_argument('number_of_workers', '')) except ValueError: number_of_workers = 0 errors = [] if not name: errors.append('name') if not module: errors.append('module') if not test_class: errors.append('test_class') if not server_url: errors.append('server_url') if not cycles or not self.is_valid_cycles(cycles): errors.append('cycles') if cycle_duration <= 0: errors.append('cycle_duration') if number_of_workers <= 0: errors.append('number_of_workers') if errors: self.render('rockload/apps/main/new_test.html', projects=self.all_projects(), project=project, errors=errors, values={ 'name': name, 'module': module, 'test_class': test_class, 'server_url': server_url, 'cycles': cycles, 'cycle_duration': cycle_duration, 'number_of_workers': number_of_workers }) else: test = Test(project=project, name=name, module=module, test_class=test_class, server_url=server_url, cycles=cycles, cycle_duration=cycle_duration, number_of_workers=number_of_workers, created_at=datetime.now()) test.stats = TestStats() test.save() self.redirect('/projects/%s/tests/%s' % (quote(project.name), quote(test.name)))
def get(self, project_name, test_name): project = Project.objects(name=project_name).get() test = Test.objects(project=project, name=test_name).get() for test_result in TestResult.objects(test=test).all(): test_result.delete() test.delete() self.redirect('/?test-deleted=True')
def get(self, project_name): project = Project.objects(name=project_name).get() self.render('rockload/apps/main/new_test.html', projects=self.all_projects(), project=project, errors=[], values={ 'name': '', 'module': '', 'test_class': '', 'server_url': '', 'cycles': '30:60:90', 'cycle_duration': 10, 'number_of_workers': 3 })
def get(self, project_name, test_name): projects = self.all_projects() project = Project.objects(name=project_name).get() test = Test.objects(project=project, name=test_name.strip()).all()[0] results = [result for result in TestResult.objects(test=test) if result.done] test_scheduled = False if self.get_argument('test_scheduled', None) == 'true': test_scheduled = True self.render('rockload/apps/main/test_details.html', projects=projects, project=project, test=test, test_scheduled=test_scheduled, results=results)
def get(self, project_name, test_name): projects = self.all_projects() project = Project.objects(name=project_name).get() test = Test.objects(project=project, name=test_name.strip()).all()[0] results = [ result for result in TestResult.objects(test=test) if result.done ] test_scheduled = False if self.get_argument('test_scheduled', None) == 'true': test_scheduled = True self.render('rockload/apps/main/test_details.html', projects=projects, project=project, test=test, test_scheduled=test_scheduled, results=results)
def all_projects(self): return Project.objects().all()