From ff8a2be77e47d0d81843876f3e5f846f0fd4983d Mon Sep 17 00:00:00 2001 From: Eric Hankland Date: Tue, 30 Jun 2015 17:04:22 -0700 Subject: [PATCH] Fix publisher to publish default image and machine type if they arent overridden --- perfkitbenchmarker/publisher.py | 10 +++++++--- tests/publisher_test.py | 14 +++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/perfkitbenchmarker/publisher.py b/perfkitbenchmarker/publisher.py index c5302d2ce9..7b4b6c46f0 100644 --- a/perfkitbenchmarker/publisher.py +++ b/perfkitbenchmarker/publisher.py @@ -1,4 +1,4 @@ -# Copyright 2014 Google Inc. All rights reserved. +# Copyright 2015 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -134,8 +134,12 @@ def AddMetadata(self, metadata, benchmark_spec): metadata['cloud'] = benchmark_spec.cloud # Get the unique zone names from the VMs. metadata['zones'] = ','.join(set([vm.zone for vm in benchmark_spec.vms])) - metadata['machine_type'] = benchmark_spec.machine_type - metadata['image'] = benchmark_spec.image + # Get a representative VM so that we can publish the machine type and + # image. If we support different machine types/images in the same benchmark + # this will need to be updated. + vm = benchmark_spec.vms[0] + metadata['machine_type'] = vm.machine_type + metadata['image'] = vm.image # Scratch disk is not defined when a benchmark config is provided. if getattr(benchmark_spec, 'scratch_disk', None): diff --git a/tests/publisher_test.py b/tests/publisher_test.py index da393cefd4..8b02a0a2f3 100644 --- a/tests/publisher_test.py +++ b/tests/publisher_test.py @@ -1,4 +1,4 @@ -# Copyright 2014 Google Inc. All rights reserved. +# Copyright 2015 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -239,17 +239,17 @@ def setUp(self): p.start() self.addCleanup(p.stop) - mock_vm = mock.MagicMock(zone='us-central1-a') + mock_vm = mock.MagicMock(zone='us-central1-a', + machine_type='n1-standard-1', + image='ubuntu-14-04') self.mock_spec = mock.MagicMock(cloud='GCP', - vms=[mock_vm], - machine_type='n1-standard-1', - image='ubuntu-14-04') + vms=[mock_vm]) self.default_meta = {'perfkitbenchmarker_version': 'v1', 'cloud': self.mock_spec.cloud, 'zones': 'us-central1-a', - 'machine_type': self.mock_spec.machine_type, - 'image': self.mock_spec.image, + 'machine_type': mock_vm.machine_type, + 'image': mock_vm.image, 'num_striped_disks': 1} def _RunTest(self, spec, expected, input_metadata=None):