From c7233241ce41c9e629a9046ce2b40d4288ad7896 Mon Sep 17 00:00:00 2001 From: Eric Hankland Date: Thu, 25 Jun 2015 09:46:33 -0700 Subject: [PATCH] Move defaults from benchmark_spec to vm classes Also moves network instantiation from benchmark_spec which will allow GCE to have one global network --- perfkitbenchmarker/aws/aws_virtual_machine.py | 49 ++++++++++---- .../azure/azure_virtual_machine.py | 25 ++++++- perfkitbenchmarker/benchmark_spec.py | 67 +++++-------------- .../digitalocean_virtual_machine.py | 18 ++++- perfkitbenchmarker/gcp/gce_virtual_machine.py | 31 +++++++-- perfkitbenchmarker/network.py | 24 ++++++- perfkitbenchmarker/pkb.py | 2 +- perfkitbenchmarker/publisher.py | 3 +- perfkitbenchmarker/static_virtual_machine.py | 2 +- perfkitbenchmarker/virtual_machine.py | 17 +++-- tests/aws_test.py | 5 +- tests/publisher_test.py | 3 +- tests/scratch_disk_test.py | 8 +-- 13 files changed, 166 insertions(+), 88 deletions(-) diff --git a/perfkitbenchmarker/aws/aws_virtual_machine.py b/perfkitbenchmarker/aws/aws_virtual_machine.py index 3f03ca965b..5cadb68e24 100644 --- a/perfkitbenchmarker/aws/aws_virtual_machine.py +++ b/perfkitbenchmarker/aws/aws_virtual_machine.py @@ -29,6 +29,7 @@ from perfkitbenchmarker import virtual_machine from perfkitbenchmarker import vm_util from perfkitbenchmarker.aws import aws_disk +from perfkitbenchmarker.aws import aws_network from perfkitbenchmarker.aws import util FLAGS = flags.FLAGS @@ -49,7 +50,7 @@ AP_SOUTHEAST_1 = 'ap-southeast-1' AP_SOUTHEAST_2 = 'ap-southeast-2' SA_EAST_1 = 'sa-east-1' -AMIS = { +UBUNTU_AMIS = { HVM: { US_EAST_1: 'ami-acff23c4', US_WEST_1: 'ami-05717d40', @@ -113,15 +114,6 @@ def GetBlockDeviceMap(machine_type): return None -def GetImage(machine_type, region): - """Gets an ami compatible with the machine type and zone.""" - prefix = machine_type.split('.')[0] - if prefix in NON_HVM_PREFIXES: - return AMIS[PV][region] - else: - return AMIS[HVM][region] - - def IsPlacementGroupCompatible(machine_type): """Returns True if VMs of 'machine_type' can be put in a placement group.""" prefix = machine_type.split('.')[0] @@ -131,6 +123,9 @@ def IsPlacementGroupCompatible(machine_type): class AwsVirtualMachine(virtual_machine.BaseVirtualMachine): """Object representing an AWS Virtual Machine.""" + DEFAULT_ZONE = 'us-east-1a' + DEFAULT_MACHINE_TYPE = 'm3.medium' + _lock = threading.Lock() imported_keyfile_set = set() deleted_keyfile_set = set() @@ -143,11 +138,30 @@ def __init__(self, vm_spec): """ super(AwsVirtualMachine, self).__init__(vm_spec) self.region = self.zone[:-1] - self.image = self.image or GetImage(self.machine_type, self.region) self.user_name = FLAGS.aws_user_name + self.network = aws_network.AwsNetwork.GetNetwork(self.zone) if self.machine_type in NUM_LOCAL_VOLUMES: self.max_local_disks = NUM_LOCAL_VOLUMES[self.machine_type] + @classmethod + def SetVmSpecDefaults(cls, vm_spec): + """Updates the VM spec with cloud specific defaults.""" + if vm_spec.machine_type is None: + vm_spec.machine_type = cls.DEFAULT_MACHINE_TYPE + if vm_spec.zone is None: + vm_spec.zone = cls.DEFAULT_ZONE + if vm_spec.image is None: + region = vm_spec.zone[:-1] + vm_spec.image = cls._GetDefaultImage(vm_spec.machine_type, region) + + @staticmethod + def _GetDefaultImage(machine_type, region): + """Returns the default image given the machine type and region. + + If no default is configured, this will return None. + """ + return None + def ImportKeyfile(self): """Imports the public keyfile to AWS.""" with self._lock: @@ -297,7 +311,18 @@ def AddMetadata(self, **kwargs): class DebianBasedAwsVirtualMachine(AwsVirtualMachine, linux_virtual_machine.DebianMixin): - pass + + @staticmethod + def _GetDefaultImage(machine_type, region): + """Returns the default image given the machine type and region. + + If no default is configured, this will return None. + """ + prefix = machine_type.split('.')[0] + if prefix in NON_HVM_PREFIXES: + return UBUNTU_AMIS[PV][region] + else: + return UBUNTU_AMIS[HVM][region] class RhelBasedAwsVirtualMachine(AwsVirtualMachine, diff --git a/perfkitbenchmarker/azure/azure_virtual_machine.py b/perfkitbenchmarker/azure/azure_virtual_machine.py index 1654bd5fef..b6e3bf2135 100644 --- a/perfkitbenchmarker/azure/azure_virtual_machine.py +++ b/perfkitbenchmarker/azure/azure_virtual_machine.py @@ -35,10 +35,15 @@ from perfkitbenchmarker import virtual_machine from perfkitbenchmarker import vm_util from perfkitbenchmarker.azure import azure_disk +from perfkitbenchmarker.azure import azure_network FLAGS = flags.FLAGS AZURE_PATH = 'azure' +UBUNTU_IMAGE = ('b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-' + '14_04_1-LTS-amd64-server-20150123-en-us-30GB') +CENTOS_IMAGE = ('0b11de9248dd4d87b18621318e037d37__RightImage-' + 'CentOS-7.0-x64-v14.2.1') class AzureService(resource.BaseResource): @@ -85,6 +90,11 @@ def _Exists(self): class AzureVirtualMachine(virtual_machine.BaseVirtualMachine): """Object representing an Azure Virtual Machine.""" + DEFAULT_ZONE = 'East US' + DEFAULT_MACHINE_TYPE = 'Small' + # Subclasses should override the default image. + DEFAULT_IMAGE = None + def __init__(self, vm_spec): """Initialize a Azure virtual machine. @@ -92,6 +102,7 @@ def __init__(self, vm_spec): vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super(AzureVirtualMachine, self).__init__(vm_spec) + self.network = azure_network.AzureNetwork.GetNetwork(self.zone) self.service = AzureService(self.name, self.network.affinity_group.name) disk_spec = disk.BaseDiskSpec(None, None, None) @@ -99,6 +110,16 @@ def __init__(self, vm_spec): self.max_local_disks = 1 self.local_disk_counter = 0 + @classmethod + def SetVmSpecDefaults(cls, vm_spec): + """Updates the VM spec with cloud specific defaults.""" + if vm_spec.machine_type is None: + vm_spec.machine_type = cls.DEFAULT_MACHINE_TYPE + if vm_spec.zone is None: + vm_spec.zone = cls.DEFAULT_ZONE + if vm_spec.image is None: + vm_spec.image = cls.DEFAULT_IMAGE + def _CreateDependencies(self): """Create VM dependencies.""" self.service.Create() @@ -190,9 +211,9 @@ def GetLocalDisks(self): class DebianBasedAzureVirtualMachine(AzureVirtualMachine, linux_virtual_machine.DebianMixin): - pass + DEFAULT_IMAGE = UBUNTU_IMAGE class RhelBasedAzureVirtualMachine(AzureVirtualMachine, linux_virtual_machine.RhelMixin): - pass + DEFAULT_IMAGE = CENTOS_IMAGE diff --git a/perfkitbenchmarker/benchmark_spec.py b/perfkitbenchmarker/benchmark_spec.py index c9b51c69d3..2e9d78b60e 100644 --- a/perfkitbenchmarker/benchmark_spec.py +++ b/perfkitbenchmarker/benchmark_spec.py @@ -19,6 +19,7 @@ from perfkitbenchmarker import disk from perfkitbenchmarker import flags +from perfkitbenchmarker import network from perfkitbenchmarker import static_virtual_machine from perfkitbenchmarker import virtual_machine from perfkitbenchmarker import vm_util @@ -45,36 +46,12 @@ VIRTUAL_MACHINE = 'virtual_machine' NETWORK = 'network' FIREWALL = 'firewall' -DEFAULTS = { - GCP: { - IMAGE: 'ubuntu-14-04', - MACHINE_TYPE: 'n1-standard-1', - ZONE: 'us-central1-a', - }, - AZURE: { - IMAGE: ('b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-' - '14_04_1-LTS-amd64-server-20150123-en-us-30GB'), - MACHINE_TYPE: 'Small', - ZONE: 'East US', - }, - AWS: { - IMAGE: None, - MACHINE_TYPE: 'm3.medium', - ZONE: 'us-east-1a' - }, - DIGITALOCEAN: { - IMAGE: 'ubuntu-14-04-x64', - MACHINE_TYPE: '2gb', - ZONE: 'sfo1' - } -} CLASSES = { GCP: { VIRTUAL_MACHINE: { DEBIAN: gce_virtual_machine.DebianBasedGceVirtualMachine, RHEL: gce_virtual_machine.RhelBasedGceVirtualMachine }, - NETWORK: gce_network.GceNetwork, FIREWALL: gce_network.GceFirewall }, AZURE: { @@ -82,7 +59,6 @@ DEBIAN: azure_virtual_machine.DebianBasedAzureVirtualMachine, RHEL: azure_virtual_machine.RhelBasedAzureVirtualMachine }, - NETWORK: azure_network.AzureNetwork, FIREWALL: azure_network.AzureFirewall }, AWS: { @@ -90,7 +66,6 @@ DEBIAN: aws_virtual_machine.DebianBasedAwsVirtualMachine, RHEL: aws_virtual_machine.RhelBasedAwsVirtualMachine }, - NETWORK: aws_network.AwsNetwork, FIREWALL: aws_network.AwsFirewall }, DIGITALOCEAN: { @@ -100,7 +75,6 @@ RHEL: digitalocean_virtual_machine.RhelBasedDigitalOceanVirtualMachine, }, - NETWORK: digitalocean_network.DigitalOceanNetwork, FIREWALL: digitalocean_network.DigitalOceanFirewall }, } @@ -130,7 +104,6 @@ def __init__(self, benchmark_info): FLAGS.benchmark_config_pair[benchmark_info['name']]) self.vms = [] self.vm_dict = {'default': []} - self.networks = {} self.benchmark_name = benchmark_info['name'] if hasattr(self, 'config'): config_dict = {} @@ -155,11 +128,9 @@ def __init__(self, benchmark_info): else: self.cloud = FLAGS.cloud self.project = FLAGS.project - defaults = DEFAULTS[self.cloud] - self.zones = FLAGS.zones or [defaults[ZONE]] - self.image = FLAGS.image or defaults[IMAGE] - self.machine_type = FLAGS.machine_type or defaults[ - MACHINE_TYPE] + self.zones = FLAGS.zones + self.image = FLAGS.image + self.machine_type = FLAGS.machine_type if benchmark_info['num_machines'] is None: self.num_vms = FLAGS.num_vms else: @@ -199,9 +170,9 @@ def __init__(self, benchmark_info): def Prepare(self): """Prepares the VMs and networks necessary for the benchmark to run.""" - if self.networks: - prepare_args = [self.networks[zone] for zone in self.networks] - vm_util.RunThreaded(self.PrepareNetwork, prepare_args) + prepare_args = network.BaseNetwork.networks.values() + vm_util.RunThreaded(self.PrepareNetwork, prepare_args) + if self.vms: prepare_args = [((vm, self.firewall), {}) for vm in self.vms] vm_util.RunThreaded(self.PrepareVm, prepare_args) @@ -222,9 +193,9 @@ def Delete(self): except Exception: logging.exception('Got an exception disabling firewalls. ' 'Attempting to continue tearing down.') - for zone in self.networks: + for net in network.BaseNetwork.networks.itervalues(): try: - self.networks[zone].Delete() + net.Delete() except Exception: logging.exception('Got an exception deleting networks. ' 'Attempting to continue tearing down.') @@ -234,12 +205,12 @@ def PrepareNetwork(self, network): """Initialize the network.""" network.Create() - def CreateVirtualMachine(self, opt_zone=None): + def CreateVirtualMachine(self, zone): """Create a vm in zone. Args: - opt_zone: The zone in which the vm will be created. If not provided, - FLAGS.zone or the revelant zone from DEFAULT will be used. + zone: The zone in which the vm will be created. If zone is None, + the VM class's DEFAULT_ZONE will be used instead. Returns: A vm object. """ @@ -248,14 +219,12 @@ def CreateVirtualMachine(self, opt_zone=None): return vm vm_class = CLASSES[self.cloud][VIRTUAL_MACHINE][FLAGS.os_type] - zone = opt_zone or self.zones[0] - if zone not in self.networks: - network_class = CLASSES[self.cloud][NETWORK] - self.networks[zone] = network_class(zone) - self.vm_spec = virtual_machine.BaseVirtualMachineSpec( - self.project, zone, self.machine_type, self.image, - self.networks[zone]) - return vm_class(self.vm_spec) + + vm_spec = virtual_machine.BaseVirtualMachineSpec( + self.project, zone, self.machine_type, self.image) + vm_class.SetVmSpecDefaults(vm_spec) + + return vm_class(vm_spec) def CreateVirtualMachineFromNodeSection(self, node_section, node_name): """Create a VirtualMachine object from NodeSection. diff --git a/perfkitbenchmarker/digitalocean/digitalocean_virtual_machine.py b/perfkitbenchmarker/digitalocean/digitalocean_virtual_machine.py index 7a96239582..9ea12c0793 100644 --- a/perfkitbenchmarker/digitalocean/digitalocean_virtual_machine.py +++ b/perfkitbenchmarker/digitalocean/digitalocean_virtual_machine.py @@ -29,6 +29,7 @@ FLAGS = flags.FLAGS +UBUNTU_IMAGE = 'ubuntu-14-04-x64' CLOUD_CONFIG_TEMPLATE = '''#cloud-config users: - name: {0} @@ -60,6 +61,11 @@ def GetErrorMessage(stdout): class DigitalOceanVirtualMachine(virtual_machine.BaseVirtualMachine): """Object representing a DigitalOcean Virtual Machine (Droplet).""" + DEFAULT_ZONE = 'sfo1' + DEFAULT_MACHINE_TYPE = '2gb' + # Subclasses should override the default image. + DEFAULT_IMAGE = None + def __init__(self, vm_spec): """Initialize a DigitalOcean virtual machine. @@ -71,6 +77,16 @@ def __init__(self, vm_spec): self.max_local_disks = 1 self.local_disk_counter = 0 + @classmethod + def SetVmSpecDefaults(cls, vm_spec): + """Updates the VM spec with cloud specific defaults.""" + if vm_spec.machine_type is None: + vm_spec.machine_type = cls.DEFAULT_MACHINE_TYPE + if vm_spec.zone is None: + vm_spec.zone = cls.DEFAULT_ZONE + if vm_spec.image is None: + vm_spec.image = cls.DEFAULT_IMAGE + def _Create(self): """Create a DigitalOcean VM instance (droplet).""" with open(self.ssh_public_key) as f: @@ -206,7 +222,7 @@ def CreateScratchDisk(self, disk_spec): class DebianBasedDigitalOceanVirtualMachine(DigitalOceanVirtualMachine, linux_virtual_machine.DebianMixin): - pass + DEFAULT_IMAGE = UBUNTU_IMAGE class RhelBasedDigitalOceanVirtualMachine(DigitalOceanVirtualMachine, diff --git a/perfkitbenchmarker/gcp/gce_virtual_machine.py b/perfkitbenchmarker/gcp/gce_virtual_machine.py index 591017c4ab..063dd67ef5 100644 --- a/perfkitbenchmarker/gcp/gce_virtual_machine.py +++ b/perfkitbenchmarker/gcp/gce_virtual_machine.py @@ -34,6 +34,7 @@ from perfkitbenchmarker import virtual_machine from perfkitbenchmarker import vm_util from perfkitbenchmarker.gcp import gce_disk +from perfkitbenchmarker.gcp import gce_network from perfkitbenchmarker.gcp import util @@ -46,16 +47,24 @@ FLAGS = flags.FLAGS -SET_INTERRUPTS_SH = 'set-interrupts.sh' BOOT_DISK_SIZE_GB = 10 BOOT_DISK_TYPE = disk.STANDARD NVME = 'nvme' SCSI = 'SCSI' +UBUNTU_IMAGE = 'ubuntu-14-04' +RHEL_IMAGE = 'rhel-7' class GceVirtualMachine(virtual_machine.BaseVirtualMachine): """Object representing a Google Compute Engine Virtual Machine.""" + DEFAULT_ZONE = 'us-central1-a' + DEFAULT_MACHINE_TYPE = 'n1-standard-1' + # Subclasses should override the default image. + DEFAULT_IMAGE = None + BOOT_DISK_SIZE_GB = 10 + BOOT_DISK_TYPE = disk.STANDARD + def __init__(self, vm_spec): """Initialize a GCE virtual machine. @@ -63,11 +72,23 @@ def __init__(self, vm_spec): vm_spec: virtual_machine.BaseVirtualMachineSpec object of the vm. """ super(GceVirtualMachine, self).__init__(vm_spec) - disk_spec = disk.BaseDiskSpec(BOOT_DISK_SIZE_GB, BOOT_DISK_TYPE, None) + disk_spec = disk.BaseDiskSpec( + self.BOOT_DISK_SIZE_GB, self.BOOT_DISK_TYPE, None) + self.network = gce_network.GceNetwork.GetNetwork(None) self.boot_disk = gce_disk.GceDisk( disk_spec, self.name, self.zone, self.project, self.image) self.max_local_disks = FLAGS.gce_num_local_ssds - self.local_disk_counter = 0 + + + @classmethod + def SetVmSpecDefaults(cls, vm_spec): + """Updates the VM spec with cloud specific defaults.""" + if vm_spec.machine_type is None: + vm_spec.machine_type = cls.DEFAULT_MACHINE_TYPE + if vm_spec.zone is None: + vm_spec.zone = cls.DEFAULT_ZONE + if vm_spec.image is None: + vm_spec.image = cls.DEFAULT_IMAGE def _CreateDependencies(self): """Create VM dependencies.""" @@ -196,9 +217,9 @@ def AddMetadata(self, **kwargs): class DebianBasedGceVirtualMachine(GceVirtualMachine, linux_virtual_machine.DebianMixin): - pass + DEFAULT_IMAGE = UBUNTU_IMAGE class RhelBasedGceVirtualMachine(GceVirtualMachine, linux_virtual_machine.RhelMixin): - pass + DEFAULT_IMAGE = RHEL_IMAGE diff --git a/perfkitbenchmarker/network.py b/perfkitbenchmarker/network.py index 9574aefd8b..b2a5f3ead6 100644 --- a/perfkitbenchmarker/network.py +++ b/perfkitbenchmarker/network.py @@ -20,6 +20,8 @@ same project. """ +import threading + from perfkitbenchmarker import flags FLAGS = flags.FLAGS @@ -53,13 +55,31 @@ def DisallowAllPorts(self): class BaseNetwork(object): """Object representing a Base Network.""" + # Dictionary holding all BaseNetwork objects. + networks = {} + + # Lock used to serialize the instantiation of new BaseNetwork objects. + _class_lock = threading.Lock() + def __init__(self, zone=None): self.zone = zone - self.created = False + + @classmethod + def GetNetwork(cls, zone): + """Returns the network corresponding to the given zone.""" + with cls._class_lock: + # This probably will never happen, but we want to ensure that + # networks from different clouds never share the same entry, so + # in addition to using the zone, we also use the class as part + # of the key. + key = (cls, zone) + if key not in cls.networks: + cls.networks[key] = cls(zone) + return cls.networks[key] def Create(self): """Creates the actual network.""" - self.created = True + pass def Delete(self): """Deletes the actual network.""" diff --git a/perfkitbenchmarker/pkb.py b/perfkitbenchmarker/pkb.py index 6e7f0caf4d..20bee1387c 100644 --- a/perfkitbenchmarker/pkb.py +++ b/perfkitbenchmarker/pkb.py @@ -91,7 +91,7 @@ flags.DEFINE_string('project', None, 'GCP project ID under which ' 'to create the virtual machines') flags.DEFINE_list( - 'zones', None, + 'zones', [None], 'A list of zones within which to run PerfKitBenchmarker.' ' This is specific to the cloud provider you are running on. ' 'If multiple zones are given, PerfKitBenchmarker will create 1 VM in ' diff --git a/perfkitbenchmarker/publisher.py b/perfkitbenchmarker/publisher.py index c289fda685..c5302d2ce9 100644 --- a/perfkitbenchmarker/publisher.py +++ b/perfkitbenchmarker/publisher.py @@ -132,7 +132,8 @@ def AddMetadata(self, metadata, benchmark_spec): metadata = metadata.copy() metadata['perfkitbenchmarker_version'] = version.VERSION metadata['cloud'] = benchmark_spec.cloud - metadata['zones'] = ','.join(benchmark_spec.zones) + # 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 diff --git a/perfkitbenchmarker/static_virtual_machine.py b/perfkitbenchmarker/static_virtual_machine.py index 6445145fc6..6c80a789c2 100644 --- a/perfkitbenchmarker/static_virtual_machine.py +++ b/perfkitbenchmarker/static_virtual_machine.py @@ -59,7 +59,7 @@ def __init__(self, ip_address, user_name, keyfile_path, internal_ip=None, useful if benchmark dependencies have already been installed. """ vm_spec = virtual_machine.BaseVirtualMachineSpec( - None, None, None, None, None) + None, None, None, None) super(StaticVirtualMachine, self).__init__(vm_spec) self.ip_address = ip_address self.internal_ip = internal_ip diff --git a/perfkitbenchmarker/virtual_machine.py b/perfkitbenchmarker/virtual_machine.py index 362f9ed8f3..e89f7c1347 100644 --- a/perfkitbenchmarker/virtual_machine.py +++ b/perfkitbenchmarker/virtual_machine.py @@ -44,16 +44,13 @@ class BaseVirtualMachineSpec(object): zone: The region / zone the in which to launch the VM. machine_type: The provider-specific instance type (e.g. n1-standard-8). image: The disk image to boot from. - network: A BaseNetwork instance. The VM will be launched within this - network. """ - def __init__(self, project, zone, machine_type, image, network): + def __init__(self, project, zone, machine_type, image): self.project = project self.zone = zone self.machine_type = machine_type self.image = image - self.network = network class BaseVirtualMachine(resource.BaseResource): @@ -68,7 +65,6 @@ class BaseVirtualMachine(resource.BaseResource): internal_ip: Internal IP address. ip: Public (external) IP address. machine_type: The provider-specific instance type (e.g. n1-standard-8). - network: A BaseNetwork instance. project: The provider-specific project associated with the VM (e.g. artisanal-lightbulb-883). ssh_public_key: Path to SSH public key file. @@ -102,7 +98,6 @@ def __init__(self, vm_spec): self.zone = vm_spec.zone self.machine_type = vm_spec.machine_type self.image = vm_spec.image - self.network = vm_spec.network self.ip_address = None self.internal_ip = None self.user_name = DEFAULT_USERNAME @@ -113,6 +108,16 @@ def __init__(self, vm_spec): self.max_local_disks = 0 self.local_disk_counter = 0 + @classmethod + def SetVmSpecDefaults(cls, vm_spec): + """Updates the VM spec with cloud specific defaults. + + If any of the VM spec attributes haven't been set by the time this is + called, this should set them. This method should not override any + attributes which have been set. + """ + pass + def __repr__(self): return ''.format( self.ip_address, self.internal_ip) diff --git a/tests/aws_test.py b/tests/aws_test.py index feeeab2258..31c49197ec 100644 --- a/tests/aws_test.py +++ b/tests/aws_test.py @@ -81,7 +81,8 @@ class AwsVirtualMachineExistsTestCase(unittest.TestCase): def setUp(self): for module in ('perfkitbenchmarker.virtual_machine', - 'perfkitbenchmarker.vm_util'): + 'perfkitbenchmarker.vm_util', + 'perfkitbenchmarker.aws.aws_network'): p = mock.patch('{0}.FLAGS'.format(module)) mock_flags = p.start() mock_flags.run_uri = 'aaaaaa' @@ -91,7 +92,7 @@ def setUp(self): self.addCleanup(p.stop) self.vm = aws_virtual_machine.AwsVirtualMachine( virtual_machine.BaseVirtualMachineSpec( - None, 'us-east-1a', 'c3.large', None, None)) + None, 'us-east-1a', 'c3.large', None)) self.vm.id = 'i-foo' path = os.path.join(os.path.dirname(__file__), 'data', 'aws-describe-instance.json') diff --git a/tests/publisher_test.py b/tests/publisher_test.py index 584204871f..da393cefd4 100644 --- a/tests/publisher_test.py +++ b/tests/publisher_test.py @@ -239,8 +239,9 @@ def setUp(self): p.start() self.addCleanup(p.stop) + mock_vm = mock.MagicMock(zone='us-central1-a') self.mock_spec = mock.MagicMock(cloud='GCP', - zones=['us-central1-a'], + vms=[mock_vm], machine_type='n1-standard-1', image='ubuntu-14-04') diff --git a/tests/scratch_disk_test.py b/tests/scratch_disk_test.py index 559d318013..0acfcb7a8e 100644 --- a/tests/scratch_disk_test.py +++ b/tests/scratch_disk_test.py @@ -28,7 +28,6 @@ from perfkitbenchmarker.aws import aws_virtual_machine from perfkitbenchmarker.aws import util as aws_util from perfkitbenchmarker.azure import azure_disk -from perfkitbenchmarker.azure import azure_network from perfkitbenchmarker.azure import azure_virtual_machine from perfkitbenchmarker.gcp import gce_disk from perfkitbenchmarker.gcp import gce_virtual_machine @@ -129,9 +128,8 @@ def _PatchCloudSpecific(self): self.patches.append(mock.patch(azure_disk.__name__ + '.AzureDisk')) def _CreateVm(self): - network = azure_network.AzureNetwork(None) vm_spec = virtual_machine.BaseVirtualMachineSpec( - None, None, None, None, network) + None, None, None, None) return azure_virtual_machine.DebianBasedAzureVirtualMachine(vm_spec) def _GetDiskClass(self): @@ -145,7 +143,7 @@ def _PatchCloudSpecific(self): def _CreateVm(self): vm_spec = virtual_machine.BaseVirtualMachineSpec( - None, None, None, None, None) + None, None, None, None) return gce_virtual_machine.DebianBasedGceVirtualMachine(vm_spec) def _GetDiskClass(self): @@ -160,7 +158,7 @@ def _PatchCloudSpecific(self): def _CreateVm(self): vm_spec = virtual_machine.BaseVirtualMachineSpec( - None, 'zone', None, 'image', None) + None, 'zone', None, 'image') return aws_virtual_machine.DebianBasedAwsVirtualMachine(vm_spec) def _GetDiskClass(self):