示例#1
0
    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')
示例#2
0
    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')
示例#3
0
    def get(self):
        results = TestResult.objects().all()

        for result in results:
            if result.done: continue

            for run in result.runs:
                if run.done or run.in_progress: continue

                run.in_progress = True
                result.save()

                self.write(
                    dumps({
                        'task-details': {
                            'result_id': str(result.id),
                            'run_id': run.uuid,
                            'git_repo': run.git_repo,
                            'url': run.server_url,
                            'cycles': run.cycles,
                            'duration': run.cycle_duration,
                            'test_module': run.module,
                            'test_class': run.test_class
                        }
                    }))
                return

        self.write(dumps('no-available-tasks'))
示例#4
0
    def get(self):
        results = TestResult.objects().all()

        for result in results:
            if result.done: continue

            for run in result.runs:
                if run.done or run.in_progress: continue

                run.in_progress = True
                result.save()

                self.write(dumps({
                    'task-details': {
                        'result_id': str(result.id),
                        'run_id': run.uuid,
                        'git_repo': run.git_repo,
                        'url': run.server_url,
                        'cycles': run.cycles,
                        'duration': run.cycle_duration,
                        'test_module': run.module,
                        'test_class': run.test_class
                    }
                }))
                return

        self.write(dumps('no-available-tasks'))
示例#5
0
    def post(self):
        xml_dir = '/tmp/rockload/%s' % uuid4()

        if not os.path.exists(xml_dir):
            os.makedirs(xml_dir)

        result_id = ObjectId(self.get_argument('result_id'))
        result = TestResult.objects(id=result_id).get()
        try:
            run = filter(lambda run: run.uuid == self.get_argument('run_id'),
                         result.runs)[0]
            run.in_progress = False

            with tempfile.NamedTemporaryFile(suffix='.xml',
                                             dir=xml_dir,
                                             delete=False) as xml_file:
                xml_file.write(self.get_argument('result').decode('utf-8'))
                run.xml_file = xml_file.name

            run.done = True
            result.save()
        except IndexError:
            pass

        if result.done:
            xml_file_names = []
            for run in result.runs:
                with tempfile.NamedTemporaryFile(suffix='.xml',
                                                 dir=xml_dir,
                                                 delete=False) as xml_file:
                    with open(run.xml_file, 'rb') as xml_source:
                        xml_file.write(xml_source.read())
                        xml_file_names.append(xml_file.name)

            with lcd(xml_dir):
                local('fl-build-report --html %s' % ' '.join(xml_file_names))

                for item in os.listdir(xml_dir):
                    html_dir = os.path.join(xml_dir, item)
                    if os.path.isdir(html_dir) and os.path.exists(
                            os.path.join(html_dir, 'index.html')):
                        print 'found results under %s' % html_dir
                        target_path = os.path.join(
                            self.application.settings['report_dir'],
                            os.path.basename(html_dir))
                        shutil.copytree(html_dir, target_path)
                        result.html_path = os.path.join(
                            os.path.basename(html_dir), 'index.html')

            result.finished_date = datetime.now()
            result.update_stats(self.application.settings['report_dir'])

            result.save()

            result.test.update_stats()

        self.write('OK')
示例#6
0
    def get(self, result_id):
        result_id = ObjectId(result_id)
        result = TestResult.objects(id=result_id).get()

        if result.cloned:
            self.write("True")
            return

        self.write("False")
示例#7
0
    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')
示例#8
0
    def get(self, result_id):
        result_id = ObjectId(result_id)
        result = TestResult.objects(id=result_id).get()

        if result.cloned:
            self.write("True")
            return

        self.write("False")
示例#9
0
    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')
示例#10
0
    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')
示例#11
0
    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')
示例#12
0
    def post(self):
        result_id = ObjectId(self.get_argument('result_id'))
        result = TestResult.objects(id=result_id).get()

        run = filter(lambda run: run.uuid == self.get_argument('run_id'), result.runs)[0]
        run.in_progress = self.get_argument('in_progress') == 'True'
        run.cloned = self.get_argument('cloned') == 'True'
        result.save()

        self.write('OK')
示例#13
0
    def post(self):
        result_id = ObjectId(self.get_argument('result_id'))
        result = TestResult.objects(id=result_id).get()

        run = filter(lambda run: run.uuid == self.get_argument('run_id'),
                     result.runs)[0]
        run.in_progress = self.get_argument('in_progress') == 'True'
        run.cloned = self.get_argument('cloned') == 'True'
        result.save()

        self.write('OK')
示例#14
0
    def post(self):
        xml_dir = '/tmp/rockload/%s' % uuid4()

        if not os.path.exists(xml_dir):
            os.makedirs(xml_dir)

        result_id = ObjectId(self.get_argument('result_id'))
        result = TestResult.objects(id=result_id).get()
        try:
            run = filter(lambda run: run.uuid == self.get_argument('run_id'), result.runs)[0]
            run.in_progress = False

            with tempfile.NamedTemporaryFile(suffix='.xml', dir=xml_dir, delete=False) as xml_file:
                xml_file.write(self.get_argument('result').decode('utf-8'))
                run.xml_file = xml_file.name

            run.done = True
            result.save()
        except IndexError:
            pass

        if result.done:
            xml_file_names = []
            for run in result.runs:
                with tempfile.NamedTemporaryFile(suffix='.xml', dir=xml_dir, delete=False) as xml_file:
                    with open(run.xml_file, 'rb') as xml_source:
                        xml_file.write(xml_source.read())
                        xml_file_names.append(xml_file.name)

            with lcd(xml_dir):
                local('fl-build-report --html %s' % ' '.join(xml_file_names))

                for item in os.listdir(xml_dir):
                    html_dir = os.path.join(xml_dir, item)
                    if os.path.isdir(html_dir) and os.path.exists(os.path.join(html_dir, 'index.html')):
                        print 'found results under %s' % html_dir
                        target_path = os.path.join(self.application.settings['report_dir'], os.path.basename(html_dir))
                        shutil.copytree(html_dir, target_path)
                        result.html_path = os.path.join(os.path.basename(html_dir), 'index.html')

            result.finished_date = datetime.now()
            result.update_stats(self.application.settings['report_dir'])

            result.save()

            result.test.update_stats()

        self.write('OK')
示例#15
0
    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)
示例#16
0
    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)