Пример #1
0
    def test_delete_benchmark_definition_also_deletes_benchmark_executions(
            self):
        layout = BluesteelLayoutController.create_new_default_layout()
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        BenchmarkExecutionController.create_benchmark_execution(
            definition, self.commit1, self.worker1)
        BenchmarkExecutionController.create_benchmark_execution(
            definition, self.commit2, self.worker1)
        BenchmarkExecutionController.create_benchmark_execution(
            definition, self.commit3, self.worker1)
        BenchmarkExecutionController.create_benchmark_execution(
            definition, self.commit1, self.worker2)
        BenchmarkExecutionController.create_benchmark_execution(
            definition, self.commit2, self.worker2)
        BenchmarkExecutionController.create_benchmark_execution(
            definition, self.commit3, self.worker2)

        self.assertEqual(6, BenchmarkExecutionEntry.objects.all().count())

        resp = self.client.post('/main/definition/{0}/delete/'.format(
            definition.id),
                                data='',
                                content_type='application/json')

        self.assertEqual(0, BenchmarkDefinitionEntry.objects.all().count())
        self.assertEqual(0, BenchmarkExecutionEntry.objects.all().count())
    def setUp(self):
        self.client = Client()
        self.user1 = User.objects.create_user('*****@*****.**',
                                              '*****@*****.**', 'pass')

        self.git_project1 = GitProjectEntry.objects.create(url='http://test/')

        self.git_user1 = GitUserEntry.objects.create(project=self.git_project1,
                                                     name='user1',
                                                     email='*****@*****.**')

        self.commit1 = GitCommitEntry.objects.create(
            project=self.git_project1,
            commit_hash='0000100001000010000100001000010000100001',
            author=self.git_user1,
            author_date=timezone.now(),
            committer=self.git_user1,
            committer_date=timezone.now())

        self.worker1 = WorkerEntry.objects.create(
            name='worker-name-1',
            uuid='uuid-worker-1',
            operative_system='osx',
            description='long-description-1',
            user=self.user1,
            git_feeder=False)

        self.bluesteel_layout1 = BluesteelLayoutController.create_new_default_layout(
        )
        self.benchmark_definition1 = BenchmarkDefinitionController.create_default_benchmark_definition(
        )
Пример #3
0
 def test_create_default_benchmark_definition_without_layout_returns_nothing(
         self):
     self.assertEqual(0, BluesteelLayoutEntry.objects.all().count())
     self.assertEqual(0, BluesteelProjectEntry.objects.all().count())
     self.assertEqual(
         None,
         BenchmarkDefinitionController.create_default_benchmark_definition(
         ))
Пример #4
0
    def test_is_benchmark_definition_equivalent_all(self):
        layout = BluesteelLayoutEntry.objects.create(name='default-name')
        project = BluesteelProjectController.create_default_project(
            layout, 'project', 0)
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        commands = self.get_default_commands()

        self.assertEqual(
            True,
            BenchmarkDefinitionController.is_benchmark_definition_equivalent(
                definition.id, layout.id, project.id, commands))
def create_new_benchmark_definition(request):
    """ Creates a new benchmark defintion """
    if request.method != 'POST':
        return res.get_response(400, 'Only post allowed', {})

    definition = BenchmarkDefinitionController.create_default_benchmark_definition(
    )
    BenchmarkDefinitionController.populate_worker_passes_for_definition(
        definition)

    data = {}
    data['redirect'] = ViewUrlGenerator.get_benchmark_definitions_url(1)

    return res.get_response(200, 'Benchmark definition created', data)
Пример #6
0
    def test_is_benchmark_definition_equivalent_commands(self):
        layout = BluesteelLayoutEntry.objects.create(name='default-name')
        project = BluesteelProjectController.create_default_project(
            layout, 'project', 0)
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        commands = []
        commands.append('command-28')
        commands.append('command-29')
        commands.append('command-30')

        self.assertEqual(
            False,
            BenchmarkDefinitionController.is_benchmark_definition_equivalent(
                definition.id, layout.id, project.id, commands))
Пример #7
0
    def test_save_benchmark_definition_with_longest_override_id_possible(self):
        layout = BluesteelLayoutController.create_new_default_layout()
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        project = BluesteelProjectEntry.objects.filter(layout=layout).first()

        long_id = 'a' * 255

        obj = {}
        obj['name'] = 'new-name-1'
        obj['layout_id'] = layout.id
        obj['project_id'] = project.id
        obj['priority'] = 3
        obj['active'] = True
        obj['max_fluctuation_percent'] = 28
        obj['max_weeks_old_notify'] = 8
        obj['command_list'] = []
        obj['command_list'].append('command-28')
        obj['overrides'] = []
        obj['overrides'].append({
            'result_id': long_id,
            'override_value': 28,
            'ignore_fluctuation': False
        })
        obj['work_passes'] = []

        resp = self.client.post('/main/definition/{0}/save/'.format(
            definition.id),
                                data=json.dumps(obj),
                                content_type='application/json')

        res.check_cross_origin_headers(self, resp)
        resp_obj = json.loads(resp.content)

        self.assertEqual(200, resp_obj['status'])

        self.assertEqual(
            1,
            BenchmarkFluctuationOverrideEntry.objects.all().count())
        self.assertEqual(
            1,
            BenchmarkFluctuationOverrideEntry.objects.filter(
                result_id=long_id, override_value=28).count())
        self.assertEqual(
            long_id,
            BenchmarkFluctuationOverrideEntry.objects.all().first().result_id)
Пример #8
0
    def test_create_default_benchmark_definition_without_projects_returns_nothing(
            self):
        self.assertEqual(0, CommandGroupEntry.objects.all().count())
        self.assertEqual(0, CommandSetEntry.objects.all().count())
        self.assertEqual(0, CommandEntry.objects.all().count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())

        new_layout = BluesteelLayoutEntry.objects.create(name='default-name')
        project = BluesteelProjectController.create_default_project(
            new_layout, 'project', 0)
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        self.assertEqual(1, BluesteelLayoutEntry.objects.all().count())
        self.assertEqual(1, BluesteelProjectEntry.objects.all().count())
        self.assertNotEqual(None, definition.command_set)
        self.assertEqual(
            3,
            CommandEntry.objects.filter(
                command_set=definition.command_set).count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())
Пример #9
0
    def test_get_workes_only_associated_with_a_benchmark_definition(self):
        layout = BluesteelLayoutController.create_new_default_layout()
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        BenchmarkDefinitionWorkerPassEntry.objects.create(
            definition=definition, worker=self.worker1, allowed=True)
        BenchmarkDefinitionWorkerPassEntry.objects.create(
            definition=definition, worker=self.worker2, allowed=False)

        resp = self.client.get('/main/definition/{0}/workers/list/'.format(
            definition.id))

        res.check_cross_origin_headers(self, resp)
        resp_obj = json.loads(resp.content)

        self.assertEqual(1, len(resp_obj['data']['workers']))
        self.assertEqual(self.worker1.id, resp_obj['data']['workers'][0]['id'])
        self.assertEqual('worker-name-1',
                         resp_obj['data']['workers'][0]['name'])
        self.assertEqual('osx',
                         resp_obj['data']['workers'][0]['operative_system'])
Пример #10
0
    def test_save_benchmark_definition(self):
        layout = BluesteelLayoutController.create_new_default_layout()
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        self.assertEqual('default-name', definition.name)
        self.assertEqual(False, definition.active)
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git checkout {commit_hash}').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git submodule update --init --recursive').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='<add_more_commands_here>').count())
        self.assertEqual(
            0,
            BenchmarkFluctuationOverrideEntry.objects.all().count())

        project = BluesteelProjectEntry.objects.filter(layout=layout).first()

        obj = {}
        obj['name'] = 'new-name-1'
        obj['layout_id'] = layout.id
        obj['project_id'] = project.id
        obj['priority'] = 3
        obj['active'] = True
        obj['max_fluctuation_percent'] = 28
        obj['max_weeks_old_notify'] = 8
        obj['command_list'] = []
        obj['command_list'].append('command-28')
        obj['command_list'].append('command-29')
        obj['command_list'].append('command-30')
        obj['command_list'].append('command-31')
        obj['overrides'] = []
        obj['overrides'].append({
            'result_id': 'id1',
            'override_value': 28,
            'ignore_fluctuation': False
        })
        obj['overrides'].append({
            'result_id': 'id2',
            'override_value': 29,
            'ignore_fluctuation': False
        })
        obj['work_passes'] = []

        resp = self.client.post('/main/definition/{0}/save/'.format(
            definition.id),
                                data=json.dumps(obj),
                                content_type='application/json')

        res.check_cross_origin_headers(self, resp)
        resp_obj = json.loads(resp.content)

        self.assertEqual(200, resp_obj['status'])

        definition = BenchmarkDefinitionEntry.objects.filter(
            id=definition.id).first()

        self.assertEqual('new-name-1', definition.name)
        self.assertEqual(True, definition.active)
        self.assertEqual(28, definition.max_fluctuation_percent)
        self.assertEqual(8, definition.max_weeks_old_notify)

        self.assertEqual(
            0,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git checkout {commit_hash}').count())
        self.assertEqual(
            0,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git submodule update --init --recursive').count())
        self.assertEqual(
            0,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='<add_more_commands_here>').count())

        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-28').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-29').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-30').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-31').count())

        self.assertEqual(
            2,
            BenchmarkFluctuationOverrideEntry.objects.all().count())
        self.assertEqual(
            1,
            BenchmarkFluctuationOverrideEntry.objects.filter(
                result_id='id1', override_value=28).count())
        self.assertEqual(
            1,
            BenchmarkFluctuationOverrideEntry.objects.filter(
                result_id='id2', override_value=29).count())
Пример #11
0
    def test_duplicate_benchmark_definition(self):
        self.assertEqual(0, CommandGroupEntry.objects.all().count())
        self.assertEqual(0, CommandSetEntry.objects.all().count())
        self.assertEqual(0, CommandEntry.objects.all().count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())

        new_layout = BluesteelLayoutEntry.objects.create(name='default-name')
        project = BluesteelProjectController.create_default_project(
            new_layout, 'project', 0)
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )
        definition.priority = BenchmarkDefinitionEntry.VERY_HIGH
        definition.active = True
        definition.max_fluctuation_percent = 28
        definition.revision = 3
        definition.max_weeks_old_notify = 2
        definition.save()

        BenchmarkFluctuationOverrideEntry.objects.create(
            definition=definition,
            result_id='id1',
            override_value=28,
            ignore_fluctuation=False)
        BenchmarkFluctuationOverrideEntry.objects.create(
            definition=definition,
            result_id='id2',
            override_value=29,
            ignore_fluctuation=False)
        BenchmarkFluctuationOverrideEntry.objects.create(
            definition=definition,
            result_id='id3',
            override_value=30,
            ignore_fluctuation=False)

        user1 = User.objects.create_user('*****@*****.**', '*****@*****.**',
                                         'pass')
        user1.save()

        user2 = User.objects.create_user('*****@*****.**', '*****@*****.**',
                                         'pass')
        user2.save()

        worker1 = WorkerEntry.objects.create(user=user1)
        worker2 = WorkerEntry.objects.create(user=user2)

        BenchmarkDefinitionWorkerPassEntry.objects.create(
            definition=definition, worker=worker2)
        BenchmarkDefinitionWorkerPassEntry.objects.create(
            definition=definition, worker=worker1)

        self.assertEqual(1, BluesteelLayoutEntry.objects.all().count())
        self.assertEqual(1, BluesteelProjectEntry.objects.all().count())
        self.assertNotEqual(None, definition.command_set)
        self.assertEqual(
            3,
            CommandEntry.objects.filter(
                command_set=definition.command_set).count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())
        self.assertEqual(BenchmarkDefinitionEntry.VERY_HIGH,
                         definition.priority)
        self.assertEqual(True, definition.active)
        self.assertEqual(3, definition.revision)
        self.assertEqual(28, definition.max_fluctuation_percent)
        self.assertEqual(2, definition.max_weeks_old_notify)
        self.assertEqual('default-name', definition.name)
        self.assertEqual(
            3,
            BenchmarkFluctuationOverrideEntry.objects.all().count())
        self.assertEqual(
            2,
            BenchmarkDefinitionWorkerPassEntry.objects.filter(
                definition=definition).count())

        new_definition = BenchmarkDefinitionController.duplicate_benchmark_definition(
            definition.id)

        self.assertNotEqual(None, new_definition)
        self.assertEqual(2, BenchmarkDefinitionEntry.objects.all().count())
        self.assertEqual(
            3,
            CommandEntry.objects.filter(
                command_set=definition.command_set).count())
        self.assertEqual(
            3,
            CommandEntry.objects.filter(
                command_set=new_definition.command_set).count())
        self.assertEqual(BenchmarkDefinitionEntry.VERY_HIGH,
                         definition.priority)
        self.assertEqual(BenchmarkDefinitionEntry.VERY_HIGH,
                         new_definition.priority)
        self.assertEqual(True, definition.active)
        self.assertEqual(False, new_definition.active)
        self.assertEqual(3, definition.revision)
        self.assertEqual(0, new_definition.revision)
        self.assertEqual(28, definition.max_fluctuation_percent)
        self.assertEqual(28, new_definition.max_fluctuation_percent)
        self.assertEqual(2, definition.max_weeks_old_notify)
        self.assertEqual(2, new_definition.max_weeks_old_notify)
        self.assertEqual('default-name', definition.name)
        self.assertEqual('default-name (duplicate)', new_definition.name)
        self.assertEqual(
            3,
            BenchmarkFluctuationOverrideEntry.objects.all().count())
        self.assertEqual(
            2,
            BenchmarkDefinitionWorkerPassEntry.objects.filter(
                definition=definition).count())
        self.assertEqual(
            2,
            BenchmarkDefinitionWorkerPassEntry.objects.filter(
                definition=new_definition).count())
Пример #12
0
    def test_save_same_benchmark_definition_does_not_increment_revision(self):
        self.assertEqual(0, CommandGroupEntry.objects.all().count())
        self.assertEqual(0, CommandSetEntry.objects.all().count())
        self.assertEqual(0, CommandEntry.objects.all().count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())

        new_layout = BluesteelLayoutEntry.objects.create(name='default-name')
        project = BluesteelProjectController.create_default_project(
            new_layout, 'project', 0)
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        definition.priority = BenchmarkDefinitionEntry.HIGH

        self.assertEqual(1, BluesteelLayoutEntry.objects.all().count())
        self.assertEqual(1, BluesteelProjectEntry.objects.all().count())
        self.assertNotEqual(None, definition.command_set)
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git checkout {commit_hash}').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git submodule update --init --recursive').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='<add_more_commands_here>').count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())
        self.assertEqual(BenchmarkDefinitionEntry.HIGH, definition.priority)
        self.assertEqual(False, definition.active)
        self.assertEqual(0, definition.revision)
        self.assertEqual(0, definition.max_fluctuation_percent)
        self.assertEqual(1, definition.max_weeks_old_notify)
        self.assertEqual('default-name', definition.name)
        self.assertEqual(
            0,
            BenchmarkFluctuationOverrideEntry.objects.all().count())

        commands = self.get_default_commands()

        overrides = []
        overrides.append({
            'result_id': 'id1',
            'override_value': 28,
            'ignore_fluctuation': False
        })
        overrides.append({
            'result_id': 'id2',
            'override_value': 29,
            'ignore_fluctuation': False
        })

        result = BenchmarkDefinitionController.save_benchmark_definition(
            'default-name', definition.id, new_layout.id, project.id,
            BenchmarkDefinitionEntry.VERY_HIGH, True, commands, 0, overrides,
            8, [])
        definition = BenchmarkDefinitionEntry.objects.all().first()

        self.assertEqual(definition, result)
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git checkout {commit_hash}').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='git submodule update --init --recursive').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(
                command_set=definition.command_set,
                command='<add_more_commands_here>').count())
        self.assertEqual(BenchmarkDefinitionEntry.VERY_HIGH,
                         definition.priority)
        self.assertEqual(True, definition.active)
        self.assertEqual(0, definition.revision)
        self.assertEqual(0, definition.max_fluctuation_percent)
        self.assertEqual(8, definition.max_weeks_old_notify)
        self.assertEqual('default-name', definition.name)
        self.assertEqual(
            2,
            BenchmarkFluctuationOverrideEntry.objects.all().count())
Пример #13
0
    def test_save_benchmark_definition(self):
        self.assertEqual(0, CommandGroupEntry.objects.all().count())
        self.assertEqual(0, CommandSetEntry.objects.all().count())
        self.assertEqual(0, CommandEntry.objects.all().count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())

        new_layout = BluesteelLayoutEntry.objects.create(name='default-name')
        project = BluesteelProjectController.create_default_project(
            new_layout, 'project', 0)
        definition = BenchmarkDefinitionController.create_default_benchmark_definition(
        )

        self.assertEqual(1, BluesteelLayoutEntry.objects.all().count())
        self.assertEqual(1, BluesteelProjectEntry.objects.all().count())
        self.assertNotEqual(None, definition.command_set)
        self.assertEqual(
            3,
            CommandEntry.objects.filter(
                command_set=definition.command_set).count())
        self.assertEqual(0, CommandResultEntry.objects.all().count())
        self.assertEqual(BenchmarkDefinitionEntry.NORMAL, definition.priority)
        self.assertEqual(False, definition.active)
        self.assertEqual(0, definition.revision)
        self.assertEqual(0, definition.max_fluctuation_percent)
        self.assertEqual(1, definition.max_weeks_old_notify)
        self.assertEqual('default-name', definition.name)
        self.assertEqual(
            0,
            BenchmarkFluctuationOverrideEntry.objects.all().count())

        commands = []
        commands.append('command-28')
        commands.append('command-29')
        commands.append('command-30')

        overrides = []
        overrides.append({
            'result_id': 'id1',
            'override_value': 28,
            'ignore_fluctuation': False
        })
        overrides.append({
            'result_id': 'id2',
            'override_value': 29,
            'ignore_fluctuation': False
        })

        definition = BenchmarkDefinitionController.save_benchmark_definition(
            'new-name', definition.id, new_layout.id, project.id,
            BenchmarkDefinitionEntry.VERY_HIGH, True, commands, 28, overrides,
            8, [])

        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-28').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-29').count())
        self.assertEqual(
            1,
            CommandEntry.objects.filter(command_set=definition.command_set,
                                        command='command-30').count())
        self.assertEqual(BenchmarkDefinitionEntry.VERY_HIGH,
                         definition.priority)
        self.assertEqual(True, definition.active)
        self.assertEqual(1, definition.revision)
        self.assertEqual(28, definition.max_fluctuation_percent)
        self.assertEqual(8, definition.max_weeks_old_notify)
        self.assertEqual('new-name', definition.name)
        self.assertEqual(
            2,
            BenchmarkFluctuationOverrideEntry.objects.all().count())