Ejemplo n.º 1
0
    def test_value_single_platform(self):
        webkit_trunk = Branch.create_if_possible('webkit-trunk',
                                                 'WebKit trunk')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        self.assertEqual(
            DashboardJSONGenerator().value(), {
                'defaultBranch': 'WebKit trunk',
                'branchToId': {
                    'WebKit trunk': webkit_trunk.id
                },
                'platformToId': {
                    'Some Platform': some_platform.id
                },
                'testToId': {},
            })

        Test.update_or_insert('some-test', webkit_trunk, some_platform)
        self.assertEqual(
            DashboardJSONGenerator().value(), {
                'defaultBranch': 'WebKit trunk',
                'branchToId': {
                    'WebKit trunk': webkit_trunk.id
                },
                'platformToId': {
                    'Some Platform': some_platform.id
                },
                'testToId': {
                    'some-test': Test.get_by_key_name('some-test').id
                },
            })
Ejemplo n.º 2
0
    def test_merge(self):
        branch, platform, builder = _create_some_builder()
        some_build = _create_build(branch, platform, builder)
        some_result = TestResult.get_or_insert_from_parsed_json('some-test', some_build, 50)
        some_test = Test.update_or_insert('some-test', branch, platform)

        other_build = _create_build(branch, platform, builder, 'other-build')
        other_result = TestResult.get_or_insert_from_parsed_json('other-test', other_build, 30)
        other_test = Test.update_or_insert('other-test', branch, platform)

        self.assertOnlyInstances([some_result, other_result])
        self.assertNotEqual(some_result.key(), other_result.key())
        self.assertOnlyInstances([some_test, other_test])

        self.assertRaises(AssertionError, some_test.merge, (some_test))
        self.assertOnlyInstances([some_test, other_test])

        some_test.merge(other_test)
        results_for_some_test = TestResult.all()
        results_for_some_test.filter('name =', 'some-test')
        results_for_some_test = results_for_some_test.fetch(5)
        self.assertEqual(len(results_for_some_test), 2)

        self.assertEqual(results_for_some_test[0].name, 'some-test')
        self.assertEqual(results_for_some_test[1].name, 'some-test')

        if results_for_some_test[0].value == 50:
            self.assertEqual(results_for_some_test[1].value, 30)
        else:
            self.assertEqual(results_for_some_test[1].value, 50)
Ejemplo n.º 3
0
    def test_merge(self):
        branch, platform, builder = _create_some_builder()
        some_build = _create_build(branch, platform, builder)
        some_result = TestResult.get_or_insert_from_parsed_json('some-test', some_build, 50)
        some_test = Test.update_or_insert('some-test', branch, platform)

        other_build = _create_build(branch, platform, builder, 'other-build')
        other_result = TestResult.get_or_insert_from_parsed_json('other-test', other_build, 30)
        other_test = Test.update_or_insert('other-test', branch, platform)

        self.assertOnlyInstances([some_result, other_result])
        self.assertNotEqual(some_result.key(), other_result.key())
        self.assertOnlyInstances([some_test, other_test])

        self.assertRaises(AssertionError, some_test.merge, (some_test))
        self.assertOnlyInstances([some_test, other_test])

        some_test.merge(other_test)
        results_for_some_test = TestResult.all()
        results_for_some_test.filter('name =', 'some-test')
        results_for_some_test = results_for_some_test.fetch(5)
        self.assertEqual(len(results_for_some_test), 2)

        self.assertEqual(results_for_some_test[0].name, 'some-test')
        self.assertEqual(results_for_some_test[1].name, 'some-test')

        if results_for_some_test[0].value == 50:
            self.assertEqual(results_for_some_test[1].value, 30)
        else:
            self.assertEqual(results_for_some_test[1].value, 50)
Ejemplo n.º 4
0
def _create_results(branch, platform, builder, test_name, values):
    results = []
    for i, value in enumerate(values):
        build = Build(branch=branch, platform=platform, builder=builder,
            buildNumber=i, revision=100 + i, timestamp=datetime.now())
        build.put()
        result = TestResult(name=test_name, build=build, value=value)
        result.put()
        Test.update_or_insert(test_name, branch, platform)
        results.append(result)
    return results
Ejemplo n.º 5
0
 def test_value_two_platforms(self):
     webkit_trunk = Branch.create_if_possible('webkit-trunk', 'WebKit trunk')
     some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
     other_platform = Platform.create_if_possible('other-platform', 'Other Platform')
     Test.update_or_insert('some-test', webkit_trunk, some_platform)
     Test.update_or_insert('some-test', webkit_trunk, other_platform)
     self.assertEqual(DashboardJSONGenerator().value(), {
         'defaultBranch': 'WebKit trunk',
         'branchToId': {'WebKit trunk': webkit_trunk.id},
         'platformToId': {'Some Platform': some_platform.id, 'Other Platform': other_platform.id},
         'testToId': {'some-test': Test.get_by_key_name('some-test').id},
     })
Ejemplo n.º 6
0
    def test_update_or_insert_to_update(self):
        branch = Branch.create_if_possible('some-branch', 'Some Branch')
        platform = Platform.create_if_possible('some-platform', 'Some Platform')
        test = Test.update_or_insert('some-test', branch, platform)
        self.assertOnlyInstance(test)

        other_branch = Branch.create_if_possible('other-branch', 'Other Branch')
        other_platform = Platform.create_if_possible('other-platform', 'Other Platform')
        test = Test.update_or_insert('some-test', other_branch, other_platform, 'ms')
        self.assertOnlyInstance(test)
        self.assertEqualUnorderedList(test.branches, [branch.key(), other_branch.key()])
        self.assertEqualUnorderedList(test.platforms, [platform.key(), other_platform.key()])
        self.assertEqualUnorderedList(test.unit, 'ms')
Ejemplo n.º 7
0
    def test_update_or_insert_to_update(self):
        branch = Branch.create_if_possible('some-branch', 'Some Branch')
        platform = Platform.create_if_possible('some-platform', 'Some Platform')
        test = Test.update_or_insert('some-test', branch, platform)
        self.assertOnlyInstance(test)

        other_branch = Branch.create_if_possible('other-branch', 'Other Branch')
        other_platform = Platform.create_if_possible('other-platform', 'Other Platform')
        test = Test.update_or_insert('some-test', other_branch, other_platform, 'ms')
        self.assertOnlyInstance(test)
        self.assertEqualUnorderedList(test.branches, [branch.key(), other_branch.key()])
        self.assertEqualUnorderedList(test.platforms, [platform.key(), other_platform.key()])
        self.assertEqualUnorderedList(test.unit, 'ms')
Ejemplo n.º 8
0
    def test_value_two_platforms(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        other_platform = Platform.create_if_possible('other-platform',
                                                     'Other Platform')
        some_test = Test.update_or_insert('some-test', some_branch,
                                          some_platform)

        self._assert_single_test(ManifestJSONGenerator().value(), some_branch,
                                 some_platform, some_test)

        some_test = Test.update_or_insert('some-test', some_branch,
                                          other_platform)
        self.assertEqualUnorderedList(
            some_test.platforms,
            [some_platform.key(), other_platform.key()])

        value = ManifestJSONGenerator().value()
        expected_platform_ids = [some_platform.id, other_platform.id]
        self.assertEqualUnorderedList(value.keys(),
                                      ['branchMap', 'platformMap', 'testMap'])
        self.assertEqualUnorderedList(
            value['branchMap'], {
                some_branch.id: {
                    'name': some_branch.name,
                    'testIds': [some_test.id],
                    'platformIds': expected_platform_ids
                }
            })
        self.assertEqual(
            value['platformMap'], {
                some_platform.id: {
                    'name': some_platform.name,
                    'branchIds': [some_branch.id],
                    'testIds': [some_test.id]
                },
                other_platform.id: {
                    'name': other_platform.name,
                    'branchIds': [some_branch.id],
                    'testIds': [some_test.id]
                }
            })
        self.assertEqual(
            value['testMap'], {
                some_test.id: {
                    'name': some_test.name,
                    'branchIds': [some_branch.id],
                    'platformIds': expected_platform_ids
                }
            })
Ejemplo n.º 9
0
def _create_results(branch, platform, builder, test_name, values):
    results = []
    for i, value in enumerate(values):
        build = Build(branch=branch,
                      platform=platform,
                      builder=builder,
                      buildNumber=i,
                      revision=100 + i,
                      timestamp=datetime.now())
        build.put()
        result = TestResult(name=test_name, build=build, value=value)
        result.put()
        Test.update_or_insert(test_name, branch, platform)
        results.append(result)
    return results
Ejemplo n.º 10
0
    def test_value_single_platform(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        self.assertEqual(ManifestJSONGenerator().value(), {'branchMap': {}, 'platformMap': {}, 'testMap': {}})

        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self._assert_single_test(ManifestJSONGenerator().value(), some_branch, some_platform, some_test)
Ejemplo n.º 11
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        log_id = int(self.request.get('id', 0))

        log = ReportLog.get_by_id(log_id)
        if not log or not log.commit:
            self.response.out.write("Not processed")
            return

        branch = log.branch()
        platform = log.platform()
        build = Build.get_or_insert_from_log(log)

        for test_name, result_value in log.results().iteritems():
            test = Test.update_or_insert(test_name, branch, platform)
            result = TestResult.get_or_insert_from_parsed_json(test_name, build, result_value)
            runs = Runs.get_by_objects(branch, platform, test)
            regenerate_runs = True
            if runs:
                runs.update_incrementally(build, result)
                regenerate_runs = False
            schedule_runs_update(test.id, branch.id, platform.id, regenerate_runs)

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
Ejemplo n.º 12
0
    def test_update_or_insert(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self.assertThereIsNoInstanceOf(Runs)

        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertEqual(runs.json_runs, '')
        self.assertEqual(runs.json_averages, '')
        self.assertEqual(runs.json_min, None)
        self.assertEqual(runs.json_max, None)
        old_memcache_value = memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id))
        self.assertTrue(old_memcache_value)

        runs.delete()
        self.assertThereIsNoInstanceOf(Runs)

        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0])
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertTrue(runs.json_runs.startswith('[5, [4, 0, 100, null],'))
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0})
        self.assertEqual(runs.json_min, 50.0)
        self.assertEqual(runs.json_max, 50.0)
        self.assertNotEqual(memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id)), old_memcache_value)
Ejemplo n.º 13
0
    def test_to_json_with_results(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])

        value = json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json())
        self.assertEqualUnorderedList(value.keys(), ['test_runs', 'averages', 'min', 'max', 'unit', 'date_range', 'stat'])
        self.assertEqual(value['stat'], 'ok')
        self.assertEqual(value['min'], 48.0)
        self.assertEqual(value['max'], 52.0)
        self.assertEqual(value['unit'], None)
        self.assertEqual(value['date_range'], None)  # date_range is never given

        self.assertEqual(len(value['test_runs']), len(results))
        for i, run in enumerate(value['test_runs']):
            result = results[i]
            self.assertEqual(run[0], result.key().id())
            self.assertEqual(run[1][1], i)  # Build number
            self.assertEqual(run[1][2], 100 + i)  # Revision
            self.assertEqual(run[1][3], None)  # Supplementary revision
            self.assertEqual(run[3], result.value)
            self.assertEqual(run[6], some_builder.key().id())
            self.assertEqual(run[7], None)  # Statistics
Ejemplo n.º 14
0
    def test_update_incrementally(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self.assertThereIsNoInstanceOf(Runs)

        timestamps = [datetime.now(), datetime.now()]
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 52.0], timestamps)
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertEqual(json.loads('[' + runs.json_runs + ']'),
            [[5, [4, 0, 100, None], mktime(timestamps[0].timetuple()), 50.0, 0, [], None, None],
            [7, [6, 1, 101, None], mktime(timestamps[1].timetuple()), 52.0, 0, [], None, None]])
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0, "101": 52.0})
        self.assertEqual(runs.json_min, 50.0)
        self.assertEqual(runs.json_max, 52.0)

        timestamps.append(datetime.now())
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [48.0],
            timestamps[2:], starting_revision=102)
        runs.update_incrementally(builds[0], results[0])

        self.assertOnlyInstance(runs)
        self.assertEqual(json.loads('[' + runs.json_runs + ']'),
            [[5, [4, 0, 100, None], mktime(timestamps[0].timetuple()), 50.0, 0, [], None, None],
            [7, [6, 1, 101, None], mktime(timestamps[1].timetuple()), 52.0, 0, [], None, None],
            [9, [8, 0, 102, None], mktime(timestamps[2].timetuple()), 48.0, 0, [], None, None]])
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0, "101": 52.0, "102": 48.0})
        self.assertEqual(runs.json_min, 48.0)
        self.assertEqual(runs.json_max, 52.0)
Ejemplo n.º 15
0
    def test_to_json_with_results(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])

        value = json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json())
        self.assertEqualUnorderedList(value.keys(), ['test_runs', 'averages', 'min', 'max', 'unit', 'date_range', 'stat'])
        self.assertEqual(value['stat'], 'ok')
        self.assertEqual(value['min'], 48.0)
        self.assertEqual(value['max'], 52.0)
        self.assertEqual(value['unit'], None)
        self.assertEqual(value['date_range'], None)  # date_range is never given

        self.assertEqual(len(value['test_runs']), len(results))
        for i, run in enumerate(value['test_runs']):
            result = results[i]
            self.assertEqual(run[0], result.key().id())
            self.assertEqual(run[1][1], i)  # Build number
            self.assertEqual(run[1][2], 100 + i)  # Revision
            self.assertEqual(run[1][3], None)  # Supplementary revision
            self.assertEqual(run[3], result.value)
            self.assertEqual(run[6], some_builder.key().id())
            self.assertEqual(run[7], None)  # Statistics
Ejemplo n.º 16
0
    def test_json_by_ids(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        some_builder = Builder.get(
            Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch,
                                          some_platform)

        self._create_results(some_branch, some_platform, some_builder,
                             'some-test', [50.0])
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        runs_json = runs.to_json()

        key_name = Runs._key_name(some_branch.id, some_platform.id,
                                  some_test.id)
        self.assertEqual(
            Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id),
            runs_json)
        self.assertEqual(memcache.get(key_name), runs_json)

        memcache.set(key_name, 'blah')
        self.assertEqual(
            Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id),
            'blah')

        memcache.delete(key_name)
        self.assertEqual(
            Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id),
            runs_json)
        self.assertEqual(memcache.get(key_name), runs_json)
Ejemplo n.º 17
0
    def test_chart_params_with_value(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        start_time = datetime(2011, 2, 21, 12, 0, 0)
        end_time = datetime(2011, 2, 28, 12, 0, 0)
        results = self._create_results(some_branch, some_platform, some_builder, 'some-test',
            [50.0, 51.0, 52.0, 49.0, 48.0, 51.9, 50.7, 51.1],
            [start_time + timedelta(day) for day in range(0, 8)])

        # Use int despite of its impreciseness since tests may fail due to rounding errors otherwise.
        def split_as_int(string):
            return [int(float(value)) for value in string.split(',')]

        params = Runs.update_or_insert(some_branch, some_platform, some_test).chart_params(7)
        self.assertEqual(params['chxl'], '0:|Feb 21|Feb 22|Feb 23|Feb 24|Feb 25|Feb 26|Feb 27|Feb 28')
        self.assertEqual(split_as_int(params['chxr']), [1, 0, 57, int(52 * 1.1 / 5 + 0.5)])
        x_min, x_max, y_min, y_max = split_as_int(params['chds'])
        self.assertEqual(datetime.fromtimestamp(x_min), start_time)
        self.assertEqual(datetime.fromtimestamp(x_max), end_time)
        self.assertEqual(y_min, 0)
        self.assertEqual(y_max, int(52 * 1.1))
        self.assertEqual(split_as_int(params['chg']), [int(100 / 7), 20, 0, 0])

        params = Runs.update_or_insert(some_branch, some_platform, some_test).chart_params(14)
        self.assertEqual(params['chxl'], '0:|Feb 14|Feb 16|Feb 18|Feb 20|Feb 22|Feb 24|Feb 26|Feb 28')
        self.assertEqual(split_as_int(params['chxr']), [1, 0, 57, int(52 * 1.1 / 5 + 0.5)])
        x_min, x_max, y_min, y_max = split_as_int(params['chds'])
        self.assertEqual(datetime.fromtimestamp(x_min), datetime(2011, 2, 14, 12, 0, 0))
        self.assertEqual(datetime.fromtimestamp(x_max), end_time)
        self.assertEqual(y_min, 0)
        self.assertEqual(y_max, int(52 * 1.1))
        self.assertEqual(split_as_int(params['chg']), [int(100 / 7), 20, 0, 0])
Ejemplo n.º 18
0
    def test_chart_params_with_value(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        start_time = datetime(2011, 2, 21, 12, 0, 0)
        end_time = datetime(2011, 2, 28, 12, 0, 0)
        results = self._create_results(some_branch, some_platform, some_builder, 'some-test',
            [50.0, 51.0, 52.0, 49.0, 48.0, 51.9, 50.7, 51.1],
            [start_time + timedelta(day) for day in range(0, 8)])

        # Use int despite of its impreciseness since tests may fail due to rounding errors otherwise.
        def split_as_int(string):
            return [int(float(value)) for value in string.split(',')]

        params = Runs.update_or_insert(some_branch, some_platform, some_test).chart_params(7)
        self.assertEqual(params['chxl'], '0:|Feb 21|Feb 22|Feb 23|Feb 24|Feb 25|Feb 26|Feb 27|Feb 28')
        self.assertEqual(split_as_int(params['chxr']), [1, 0, 57, int(52 * 1.1 / 5 + 0.5)])
        x_min, x_max, y_min, y_max = split_as_int(params['chds'])
        self.assertEqual(datetime.fromtimestamp(x_min), start_time)
        self.assertEqual(datetime.fromtimestamp(x_max), end_time)
        self.assertEqual(y_min, 0)
        self.assertEqual(y_max, int(52 * 1.1))
        self.assertEqual(split_as_int(params['chg']), [int(100 / 7), 20, 0, 0])

        params = Runs.update_or_insert(some_branch, some_platform, some_test).chart_params(14)
        self.assertEqual(params['chxl'], '0:|Feb 14|Feb 16|Feb 18|Feb 20|Feb 22|Feb 24|Feb 26|Feb 28')
        self.assertEqual(split_as_int(params['chxr']), [1, 0, 57, int(52 * 1.1 / 5 + 0.5)])
        x_min, x_max, y_min, y_max = split_as_int(params['chds'])
        self.assertEqual(datetime.fromtimestamp(x_min), datetime(2011, 2, 14, 12, 0, 0))
        self.assertEqual(datetime.fromtimestamp(x_max), end_time)
        self.assertEqual(y_min, 0)
        self.assertEqual(y_max, int(52 * 1.1))
        self.assertEqual(split_as_int(params['chg']), [int(100 / 7), 20, 0, 0])
Ejemplo n.º 19
0
    def test_update_incrementally(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self.assertThereIsNoInstanceOf(Runs)

        timestamps = [datetime.now(), datetime.now()]
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 52.0], timestamps)
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertEqual(json.loads('[' + runs.json_runs + ']'),
            [[5, [4, 0, 100, None], mktime(timestamps[0].timetuple()), 50.0, 0, [], None, None],
            [7, [6, 1, 101, None], mktime(timestamps[1].timetuple()), 52.0, 0, [], None, None]])
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0, "101": 52.0})
        self.assertEqual(runs.json_min, 50.0)
        self.assertEqual(runs.json_max, 52.0)

        timestamps.append(datetime.now())
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [48.0],
            timestamps[2:], starting_revision=102)
        runs.update_incrementally(builds[0], results[0])

        self.assertOnlyInstance(runs)
        self.assertEqual(json.loads('[' + runs.json_runs + ']'),
            [[5, [4, 0, 100, None], mktime(timestamps[0].timetuple()), 50.0, 0, [], None, None],
            [7, [6, 1, 101, None], mktime(timestamps[1].timetuple()), 52.0, 0, [], None, None],
            [9, [8, 0, 102, None], mktime(timestamps[2].timetuple()), 48.0, 0, [], None, None]])
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0, "101": 52.0, "102": 48.0})
        self.assertEqual(runs.json_min, 48.0)
        self.assertEqual(runs.json_max, 52.0)
Ejemplo n.º 20
0
    def test_update_or_insert(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self.assertThereIsNoInstanceOf(Runs)

        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertEqual(runs.json_runs, '')
        self.assertEqual(runs.json_averages, '')
        self.assertEqual(runs.json_min, None)
        self.assertEqual(runs.json_max, None)
        old_memcache_value = memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id))
        self.assertTrue(old_memcache_value)

        runs.delete()
        self.assertThereIsNoInstanceOf(Runs)

        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0])
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertTrue(runs.json_runs.startswith('[5,[4,0,100,null],'))
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0})
        self.assertEqual(runs.json_min, 50.0)
        self.assertEqual(runs.json_max, 50.0)
        self.assertNotEqual(memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id)), old_memcache_value)
Ejemplo n.º 21
0
 def test_update_or_insert_with_unit(self):
     branch = Branch.create_if_possible('some-branch', 'Some Branch')
     platform = Platform.create_if_possible('some-platform',
                                            'Some Platform')
     test = Test.update_or_insert('some-test', branch, platform, 'runs/s')
     self.assertOnlyInstance(test)
     self.assertEqualUnorderedList(test.unit, 'runs/s')
Ejemplo n.º 22
0
    def test_to_json_with_unit(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform, 'runs/s')
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])

        value = json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json())
        self.assertEqual(value['unit'], 'runs/s')
Ejemplo n.º 23
0
    def test_to_json_with_unit(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform, 'runs/s')
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])

        value = json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json())
        self.assertEqual(value['unit'], 'runs/s')
Ejemplo n.º 24
0
    def test_value_two_tests(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        self._assert_single_test(ManifestJSONGenerator().value(), some_branch, some_platform, some_test)

        other_test = Test.update_or_insert('other-test', some_branch, some_platform)

        value = ManifestJSONGenerator().value()
        expected_test_ids = [some_test.id, other_test.id]
        self.assertEqualUnorderedList(value.keys(), ['branchMap', 'platformMap', 'testMap'])
        self.assertEqualUnorderedList(value['branchMap'],
            {some_branch.id: {'name': some_branch.name, 'testIds': expected_test_ids, 'platformIds': [some_platform.id]}})
        self.assertEqual(value['platformMap'],
            {some_platform.id: {'name': some_platform.name, 'branchIds': [some_branch.id], 'testIds': expected_test_ids}})
        self.assertEqual(value['testMap'],
            {some_test.id: {'name': some_test.name, 'branchIds': [some_branch.id], 'platformIds': [some_platform.id]},
            other_test.id: {'name': other_test.name, 'branchIds': [some_branch.id], 'platformIds': [some_platform.id]}})
Ejemplo n.º 25
0
    def test_update_or_insert(self):
        branch = Branch.create_if_possible('some-branch', 'Some Branch')
        platform = Platform.create_if_possible('some-platform', 'Some Platform')

        self.assertThereIsNoInstanceOf(Test)

        test = Test.update_or_insert('some-test', branch, platform)
        self.assertTrue(test)
        self.assertEqual(test.branches, [branch.key()])
        self.assertEqual(test.platforms, [platform.key()])
        self.assertOnlyInstance(test)
Ejemplo n.º 26
0
    def test_update_or_insert(self):
        branch = Branch.create_if_possible('some-branch', 'Some Branch')
        platform = Platform.create_if_possible('some-platform', 'Some Platform')

        self.assertThereIsNoInstanceOf(Test)

        test = Test.update_or_insert('some-test', branch, platform)
        self.assertTrue(test)
        self.assertEqual(test.branches, [branch.key()])
        self.assertEqual(test.platforms, [platform.key()])
        self.assertEqual(test.unit, None)
        self.assertOnlyInstance(test)
Ejemplo n.º 27
0
 def test_to_json_without_results(self):
     some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
     some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
     some_test = Test.update_or_insert('some-test', some_branch, some_platform)
     self.assertOnlyInstance(some_test)
     self.assertThereIsNoInstanceOf(TestResult)
     self.assertEqual(json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json()), {
         'test_runs': [],
         'averages': {},
         'min': None,
         'max': None,
         'date_range': None,
         'stat': 'ok'})
Ejemplo n.º 28
0
 def test_to_json_without_results(self):
     some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
     some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
     some_test = Test.update_or_insert('some-test', some_branch, some_platform)
     self.assertOnlyInstance(some_test)
     self.assertThereIsNoInstanceOf(TestResult)
     self.assertEqual(json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json()), {
         'test_runs': [],
         'averages': {},
         'min': None,
         'max': None,
         'unit': None,
         'date_range': None,
         'stat': 'ok'})
Ejemplo n.º 29
0
    def test_value_single_platform(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        self.assertEqual(ManifestJSONGenerator().value(), {
            'branchMap': {},
            'platformMap': {},
            'testMap': {}
        })

        some_test = Test.update_or_insert('some-test', some_branch,
                                          some_platform)
        self._assert_single_test(ManifestJSONGenerator().value(), some_branch,
                                 some_platform, some_test)
Ejemplo n.º 30
0
    def test_generate_runs(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])
        last_i = 0
        for i, (build, result) in enumerate(Runs._generate_runs(some_branch, some_platform, some_test)):
            self.assertEqual(build.buildNumber, i)
            self.assertEqual(build.revision, 100 + i)
            self.assertEqual(result.name, 'some-test')
            self.assertEqual(result.value, results[i].value)
            last_i = i
        self.assertTrue(last_i + 1, len(results))
Ejemplo n.º 31
0
    def test_generate_runs(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])
        last_i = 0
        for i, (build, result) in enumerate(Runs._generate_runs(some_branch, some_platform, some_test)):
            self.assertEqual(build.buildNumber, i)
            self.assertEqual(build.revision, 100 + i)
            self.assertEqual(result.name, 'some-test')
            self.assertEqual(result.value, results[i].value)
            last_i = i
        self.assertTrue(last_i + 1, len(results))
Ejemplo n.º 32
0
    def test_json_by_ids(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0])
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        runs_json = runs.to_json()

        key_name = Runs._key_name(some_branch.id, some_platform.id, some_test.id)
        self.assertEqual(Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id), runs_json)
        self.assertEqual(memcache.get(key_name), runs_json)

        memcache.set(key_name, 'blah')
        self.assertEqual(Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id), 'blah')

        memcache.delete(key_name)
        self.assertEqual(Runs.json_by_ids(some_branch.id, some_platform.id, some_test.id), runs_json)
        self.assertEqual(memcache.get(key_name), runs_json)
Ejemplo n.º 33
0
    def test_value_with_hidden_platform_and_test(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        hidden_platform = Platform.create_if_possible('hidden-platform',
                                                      'Hidden Platform')
        hidden_platform.hidden = True
        hidden_platform.put()

        Test.update_or_insert('some-test', some_branch, some_platform)
        some_test = Test.update_or_insert('some-test', some_branch,
                                          hidden_platform)

        Test.update_or_insert('hidden-test', some_branch, some_platform)
        hidden_test = Test.update_or_insert('hidden-test', some_branch,
                                            hidden_platform)
        hidden_test.hidden = True
        hidden_test.put()

        value = ManifestJSONGenerator().value()
        expected_test_ids = []
        self.assertEqualUnorderedList(value.keys(),
                                      ['branchMap', 'platformMap', 'testMap'])
        self.assertEqual(
            value['branchMap'], {
                some_branch.id: {
                    'name': some_branch.name,
                    'testIds': [some_test.id],
                    'platformIds': [some_platform.id]
                }
            })
        self.assertEqual(
            value['platformMap'], {
                some_platform.id: {
                    'name': some_platform.name,
                    'branchIds': [some_branch.id],
                    'testIds': [some_test.id]
                }
            })
        self.assertEqual(
            value['testMap'], {
                some_test.id: {
                    'name': some_test.name,
                    'branchIds': [some_branch.id],
                    'platformIds': [some_platform.id]
                }
            })
Ejemplo n.º 34
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        log_id = int(self.request.get('id', 0))

        log = ReportLog.get_by_id(log_id)
        if not log or not log.commit:
            self.response.out.write("Not processed")
            return

        branch = log.branch()
        platform = log.platform()
        build = Build.get_or_insert_from_log(log)

        for test_name, result_value in log.results().iteritems():
            unit = result_value.get('unit') if isinstance(result_value,
                                                          dict) else None
            test = Test.update_or_insert(test_name, branch, platform, unit)
            result = TestResult.get_or_insert_from_parsed_json(
                test_name, build, result_value)
            if not result:
                continue
            runs = Runs.get_by_objects(branch, platform, test)
            regenerate_runs = True
            if runs:
                runs.update_incrementally(build, result)
                regenerate_runs = False
            schedule_runs_update(test.id, branch.id, platform.id,
                                 regenerate_runs)

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
Ejemplo n.º 35
0
    def test_value_with_hidden_platform_and_test(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        hidden_platform = Platform.create_if_possible('hidden-platform', 'Hidden Platform')
        hidden_platform.hidden = True
        hidden_platform.put()

        Test.update_or_insert('some-test', some_branch, some_platform)
        some_test = Test.update_or_insert('some-test', some_branch, hidden_platform)

        Test.update_or_insert('hidden-test', some_branch, some_platform)
        hidden_test = Test.update_or_insert('hidden-test', some_branch, hidden_platform)
        hidden_test.hidden = True
        hidden_test.put()

        value = ManifestJSONGenerator().value()
        expected_test_ids = []
        self.assertEqualUnorderedList(value.keys(), ['branchMap', 'platformMap', 'testMap'])
        self.assertEqual(value['branchMap'],
            {some_branch.id: {'name': some_branch.name, 'testIds': [some_test.id], 'platformIds': [some_platform.id]}})
        self.assertEqual(value['platformMap'],
            {some_platform.id: {'name': some_platform.name, 'branchIds': [some_branch.id], 'testIds': [some_test.id]}})
        self.assertEqual(value['testMap'],
            {some_test.id: {'name': some_test.name, 'branchIds': [some_branch.id], 'platformIds': [some_platform.id]}})
Ejemplo n.º 36
0
 def test_value_with_hidden_platform_and_tesst(self):
     webkit_trunk = Branch.create_if_possible('webkit-trunk',
                                              'WebKit trunk')
     some_platform = Platform.create_if_possible('some-platform',
                                                 'Some Platform')
     hidden_platform = Platform.create_if_possible('hidden-platform',
                                                   'Hidden Platform')
     hidden_platform.hidden = True
     hidden_platform.put()
     Test.update_or_insert('some-test', webkit_trunk, some_platform)
     Test.update_or_insert('some-test', webkit_trunk, hidden_platform)
     Test.update_or_insert('other-test', webkit_trunk, some_platform)
     Test.update_or_insert('other-test', webkit_trunk, hidden_platform)
     Test.update_or_insert('hidden-test', webkit_trunk, some_platform)
     Test.update_or_insert('hidden-test', webkit_trunk, hidden_platform)
     hidden_test = Test.get_by_key_name('hidden-test')
     hidden_test.hidden = True
     hidden_test.put()
     self.assertEqual(DashboardJSONGenerator().value()['platformToId'],
                      {'Some Platform': some_platform.id})
     self.assertEqual(
         DashboardJSONGenerator().value()['testToId'], {
             'some-test': Test.get_by_key_name('some-test').id,
             'other-test': Test.get_by_key_name('other-test').id
         })
Ejemplo n.º 37
0
 def test_value_with_hidden_platform_and_tesst(self):
     webkit_trunk = Branch.create_if_possible('webkit-trunk', 'WebKit trunk')
     some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
     hidden_platform = Platform.create_if_possible('hidden-platform', 'Hidden Platform')
     hidden_platform.hidden = True
     hidden_platform.put()
     Test.update_or_insert('some-test', webkit_trunk, some_platform)
     Test.update_or_insert('some-test', webkit_trunk, hidden_platform)
     Test.update_or_insert('other-test', webkit_trunk, some_platform)
     Test.update_or_insert('other-test', webkit_trunk, hidden_platform)
     Test.update_or_insert('hidden-test', webkit_trunk, some_platform)
     Test.update_or_insert('hidden-test', webkit_trunk, hidden_platform)
     hidden_test = Test.get_by_key_name('hidden-test')
     hidden_test.hidden = True
     hidden_test.put()
     self.assertEqual(DashboardJSONGenerator().value()['platformToId'], {'Some Platform': some_platform.id})
     self.assertEqual(DashboardJSONGenerator().value()['testToId'],
         {'some-test': Test.get_by_key_name('some-test').id, 'other-test': Test.get_by_key_name('other-test').id})
Ejemplo n.º 38
0
 def test_update_or_insert_with_unit(self):
     branch = Branch.create_if_possible('some-branch', 'Some Branch')
     platform = Platform.create_if_possible('some-platform', 'Some Platform')
     test = Test.update_or_insert('some-test', branch, platform, 'runs/s')
     self.assertOnlyInstance(test)
     self.assertEqualUnorderedList(test.unit, 'runs/s')