예제 #1
0
    def __init__(self, test_result, api):
        """Create an instance of a test run."""
        super(PerformanceTestRun, self).__init__(test_result, api)

        # Microbenchmarks stores the 'start' and 'end' time of the test in the inner 'results' field
        # while sys-perf stores it in the outer 'results' field.
        self.start = parse_evergreen_datetime(
            test_result.get('start',
                            test_result.get('results', {}).get('start')))
        self.end = parse_evergreen_datetime(
            test_result.get('end',
                            test_result.get('results', {}).get('end')))
예제 #2
0
    def test_patches_by_project_time_window(self, mocked_api, sample_patch,
                                            mocked_api_response):
        patch_list = [
            deepcopy(sample_patch),
            deepcopy(sample_patch),
            deepcopy(sample_patch),
        ]
        # Create a window of 1 day, and set the dates so that only the middle items should be
        # returned.
        one_day = timedelta(days=1)
        one_hour = timedelta(hours=1)
        before_date = parse_evergreen_datetime(patch_list[1]["create_time"])
        after_date = before_date - one_day

        patch_list[0]["create_time"] = (before_date +
                                        one_day).strftime(EVG_DATETIME_FORMAT)
        patch_list[1]["create_time"] = (before_date -
                                        one_hour).strftime(EVG_DATETIME_FORMAT)
        patch_list[2]["create_time"] = (after_date -
                                        one_day).strftime(EVG_DATETIME_FORMAT)

        mocked_api_response.json.return_value = patch_list

        windowed_versions = mocked_api.patches_by_project_time_window(
            "project_id", before_date, after_date)

        windowed_list = list(windowed_versions)

        assert len(windowed_list) == 1
        assert patch_list[1]["patch_id"] == windowed_list[0].patch_id
예제 #3
0
파일: base.py 프로젝트: zamj/evergreen.py
 def __getattr__(self, item):
     """Lookup an attribute if it exists."""
     if item != 'json' and item in self.json:
         if self._is_field_a_date(item):
             return parse_evergreen_datetime(self.json[item])
         return self.json[item]
     raise AttributeError('Unknown attribute {0}'.format(item))
예제 #4
0
    def test_deserialization(self, sample_performance_results):
        performance_data = PerformanceData(sample_performance_results, None)

        assert performance_data.name == sample_performance_results['name']
        assert performance_data.task_name == sample_performance_results['task_name']
        assert performance_data.project_id == sample_performance_results['project_id']
        assert performance_data.task_id == sample_performance_results['task_id']
        assert performance_data.build_id == sample_performance_results['build_id']
        assert performance_data.variant == sample_performance_results['variant']
        assert performance_data.version_id == sample_performance_results['version_id']
        assert performance_data.create_time == parse_evergreen_short_datetime(
            sample_performance_results['create_time'])
        assert performance_data.is_patch == sample_performance_results['is_patch']
        assert performance_data.order == sample_performance_results['order']
        assert performance_data.revision == sample_performance_results['revision']
        assert performance_data.tag == sample_performance_results['tag']

        test_batch = performance_data.test_batch
        test_batch_json = sample_performance_results['data']

        assert test_batch.start == parse_evergreen_datetime(test_batch_json['start'])
        assert test_batch.end == parse_evergreen_datetime(test_batch_json['end'])
        assert test_batch.errors == test_batch_json['errors']
        assert test_batch.storage_engine == test_batch_json['storageEngine']

        test_run = test_batch.test_runs[0]
        test_run_json = test_batch_json['results'][0]

        assert test_run.start == parse_evergreen_datetime(
            test_run_json['start'] if 'start' in test_run_json else test_run_json['results'][
                'start'])
        assert test_run.end == parse_evergreen_datetime(
            test_run_json['end'] if 'end' in test_run_json else test_run_json['results'][
                'end'])
        assert test_run.name == test_run_json['name']
        assert test_run.workload == test_run_json[
            'workload'] if 'workload' in test_run_json else 'microbenchmarks'
        assert test_run.results == test_run_json['results']

        test_result = test_run.test_results[0]
        test_result_json = test_run_json['results']['1']

        assert test_result.measurement == 'ops_per_sec'
        assert test_result.mean_value == test_result_json['ops_per_sec']
        assert test_result.recorded_values == test_result_json['ops_per_sec_values']
        assert test_result.thread_level == '1'
예제 #5
0
 def test_no_datetime(self):
     assert not under_test.parse_evergreen_datetime(None)
예제 #6
0
    def test_returns_a_datetime_object(self):
        now = datetime.now()
        now_str = now.strftime(under_test.EVG_DATETIME_FORMAT)

        assert now == under_test.parse_evergreen_datetime(now_str)
예제 #7
0
 def test_float(self):
     now = datetime.now()
     timestamp = time.mktime(now.timetuple()) + now.microsecond / 1000000.0
     assert now == under_test.parse_evergreen_datetime(timestamp)
예제 #8
0
 def test_no_milliseconds_evergreen_format(self):
     assert isinstance(
         under_test.parse_evergreen_datetime("2019-02-13T14:55:37Z"),
         datetime)
예제 #9
0
 def test_int(self):
     now = datetime.now()
     timestamp = int(
         (time.mktime(now.timetuple()) + now.microsecond / 1000000.0))
     assert datetime.fromtimestamp(
         timestamp) == under_test.parse_evergreen_datetime(timestamp)