def _CreateVm(self): vm_spec = azure_virtual_machine.AzureVmSpec( 'test_vm_spec.Azure', zone='eastus2', machine_type='test_machine_type') return azure_virtual_machine.Ubuntu1604BasedAzureVirtualMachine( vm_spec)
def DoAzureDiskTest(self, storage_type, disk_type, machine_type, goal_media, goal_replication, goal_host_caching, disk_size=2, goal_size=2, goal_stripes=1): FLAGS.azure_storage_type = storage_type FLAGS.azure_host_caching = goal_host_caching disk_spec = disk.BaseDiskSpec(_COMPONENT, disk_size=disk_size, disk_type=disk_type, num_striped_disks=goal_stripes) vm_spec = azure_virtual_machine.AzureVmSpec( 'test_vm_spec.AZURE', zone='eastus2', machine_type=machine_type) vm = azure_virtual_machine.DebianBasedAzureVirtualMachine( vm_spec) azure_disk.AzureDisk.Create = mock.Mock() azure_disk.AzureDisk.Attach = mock.Mock() vm.StripeDisks = mock.Mock() vm.CreateScratchDisk(disk_spec) expected = {disk.MEDIA: goal_media, disk.REPLICATION: goal_replication, 'num_stripes': goal_stripes, 'size': goal_size} if goal_host_caching: expected[azure_disk.HOST_CACHING] = goal_host_caching self.assertDictContainsSubset(expected, vm.scratch_disks[0].metadata)
def testQuotaExceeded(self, _, stderror, retcode): spec = azure_virtual_machine.AzureVmSpec( _COMPONENT, machine_type='test_machine_type', zone='testing') vm = azure_virtual_machine.AzureVirtualMachine(spec) self.mock_cmd.side_effect = [(_, stderror, retcode)] with self.assertRaises(errors.Benchmarks.QuotaFailure): vm._Create()
def testVmCreationError(self, stderror, expected_error): spec = azure_virtual_machine.AzureVmSpec( _COMPONENT, machine_type='test_machine_type', zone='testing') vm = TestAzureVirtualMachine(spec) self.mock_cmd.side_effect = [('', stderror, 1)] with self.assertRaises(expected_error): vm._Create()
def testInsufficientSpotCapacity(self): spec = azure_virtual_machine.AzureVmSpec( _COMPONENT, machine_type='test_machine_type', zone='testing', low_priority=True) vm = TestAzureVirtualMachine(spec) self.mock_cmd.side_effect = [('', 'OverconstrainedAllocationRequest', 1)] with self.assertRaises(errors.Benchmarks.InsufficientCapacityCloudFailure): vm._Create()
def _CreateVm(self): vm_spec = azure_virtual_machine.AzureVmSpec( 'test_vm_spec.Azure', machine_type='test_machine_type') return azure_virtual_machine.DebianBasedAzureVirtualMachine(vm_spec)