コード例 #1
0
  def setUp(self):
    mocked_flags = mock_flags.PatchTestCaseFlags(self)
    mocked_flags.cloud = providers.AWS
    mocked_flags.os_type = os_types.DEBIAN
    mocked_flags.run_uri = 'aaaaaa'
    p = mock.patch('perfkitbenchmarker.providers.aws.'
                   'util.IssueRetryableCommand')
    p.start()
    self.addCleanup(p.stop)

    # VM Creation depends on there being a BenchmarkSpec.
    config_spec = benchmark_config_spec.BenchmarkConfigSpec(
        _BENCHMARK_NAME, flag_values=mocked_flags, vm_groups={})
    self.spec = benchmark_spec.BenchmarkSpec(mock.MagicMock(), config_spec,
                                             _BENCHMARK_UID)
    self.addCleanup(context.SetThreadBenchmarkSpec, None)

    self.vm = aws_virtual_machine.AwsVirtualMachine(
        aws_virtual_machine.AwsVmSpec('test_vm_spec.AWS', zone='us-east-1a',
                                      machine_type='c3.large'))
    self.vm.id = 'i-foo'
    path = os.path.join(os.path.dirname(__file__),
                        'data', 'aws-describe-instance.json')
    with open(path) as f:
      self.response = f.read()
コード例 #2
0
 def _CreateMockVm(self):
   self._CreatePatched(aws_network, 'AwsNetwork')
   self._CreatePatched(aws_network, 'AwsFirewall')
   vm_spec = aws_virtual_machine.AwsVmSpec(
       _COMPONENT, zone=_AWS_ZONE, machine_type='m2.2xlarge')
   aws_machine = aws_virtual_machine.RhelBasedAwsVirtualMachine(vm_spec)
   aws_machine.RemoteCommand = mock.Mock()
   aws_machine.RemoteHostCommand = mock.Mock()
   return aws_machine
コード例 #3
0
def CreateVm():
  """Returns the AWS run-instances command line."""
  vm_util.IssueCommand.side_effect = [('', '', 0)]
  util.IssueRetryableCommand.side_effect = [('', '', 0)]
  vm_spec = aws_virtual_machine.AwsVmSpec(
      'test_vm_spec.AWS', zone='us-west-1a', machine_type='c5n.18xlarge')
  vm = aws_virtual_machine.AwsVirtualMachine(vm_spec)
  vm.network.regional_network = mock.Mock()
  vm.network.subnet = mock.Mock(id='subnet-1234')
  vm.network.placement_group = mock.Mock()
  vm.network.Create()
  vm._Create()
  return ' '.join(vm_util.IssueCommand.call_args[0][0])
コード例 #4
0
  def DoAwsDiskTest(self, disk_type, machine_type,
                    goal_media, goal_replication):
    disk_spec = aws_disk.AwsDiskSpec(_COMPONENT, disk_size=2,
                                     disk_type=disk_type)

    vm_spec = aws_virtual_machine.AwsVmSpec(
        'test_vm_spec.AWS', zone='us-east-1a', machine_type=machine_type)
    vm = aws_virtual_machine.Ubuntu1804BasedAwsVirtualMachine(vm_spec)

    vm.CreateScratchDisk(disk_spec)

    self.assertDictContainsSubset(
        {disk.MEDIA: goal_media, disk.REPLICATION: goal_replication},
        vm.scratch_disks[0].metadata
    )
コード例 #5
0
ファイル: aws_test.py プロジェクト: ukinau/PerfKitBenchmarker
    def setUp(self):
        super(AwsVirtualMachineTestCase, self).setUp()
        FLAGS.cloud = providers.AWS
        FLAGS.os_type = os_types.DEBIAN
        FLAGS.run_uri = 'aaaaaa'
        FLAGS.temp_dir = 'tmp'
        p = mock.patch('perfkitbenchmarker.providers.aws.'
                       'util.IssueRetryableCommand')
        p.start()
        self.addCleanup(p.stop)
        p2 = mock.patch('perfkitbenchmarker.' 'vm_util.IssueCommand')
        p2.start()
        self.addCleanup(p2.stop)

        # VM Creation depends on there being a BenchmarkSpec.
        config_spec = benchmark_config_spec.BenchmarkConfigSpec(
            _BENCHMARK_NAME, flag_values=FLAGS, vm_groups={})
        self.spec = benchmark_spec.BenchmarkSpec(mock.MagicMock(), config_spec,
                                                 _BENCHMARK_UID)
        self.addCleanup(context.SetThreadBenchmarkSpec, None)

        self.vm = aws_virtual_machine.AwsVirtualMachine(
            aws_virtual_machine.AwsVmSpec('test_vm_spec.AWS',
                                          zone='us-east-1a',
                                          machine_type='c3.large',
                                          spot_price=123.45))
        self.vm.id = 'i-foo'
        self.vm.image = 'ami-12345'
        self.vm.client_token = '00000000-1111-2222-3333-444444444444'
        network_mock = mock.MagicMock()
        network_mock.subnet = mock.MagicMock(id='subnet-id')
        placement_group = mock.MagicMock()
        placement_group.name = 'placement_group_name'
        placement_group.strategy = 'cluster'
        network_mock.placement_group = placement_group
        self.vm.network = network_mock
        self.vm.placement_group = placement_group

        self.response = self.open_json_data('aws-describe-instance.json')
        self.sir_response = self.open_json_data(
            'aws-describe-spot-instance-requests.json')
        self.vm.network.is_static = False
        self.vm.network.regional_network.vpc.default_security_group_id = 'sg-1234'
コード例 #6
0
    def doAwsDiskTest(self, disk_type, machine_type, goal_media,
                      goal_replication, goal_legacy_disk_type):
        disk_spec = aws_disk.AwsDiskSpec(_COMPONENT,
                                         disk_size=2,
                                         disk_type=disk_type)

        vm_spec = aws_virtual_machine.AwsVmSpec('test_vm_spec.AWS',
                                                zone='us-east-1a',
                                                machine_type=machine_type)
        vm = aws_virtual_machine.DebianBasedAwsVirtualMachine(vm_spec)

        vm.CreateScratchDisk(disk_spec)

        self.assertEqual(
            vm.scratch_disks[0].metadata, {
                disk.MEDIA: goal_media,
                disk.REPLICATION: goal_replication,
                disk.LEGACY_DISK_TYPE: goal_legacy_disk_type
            })
コード例 #7
0
    def setUp(self):
        mocked_flags = mock_flags.PatchTestCaseFlags(self)
        mocked_flags.cloud = providers.AWS
        mocked_flags.os_type = os_types.DEBIAN
        mocked_flags.run_uri = 'aaaaaa'
        mocked_flags.temp_dir = 'tmp'
        p = mock.patch('perfkitbenchmarker.providers.aws.'
                       'util.IssueRetryableCommand')
        p.start()
        self.addCleanup(p.stop)
        p2 = mock.patch('perfkitbenchmarker.' 'vm_util.IssueCommand')
        p2.start()
        self.addCleanup(p2.stop)

        # VM Creation depends on there being a BenchmarkSpec.
        config_spec = benchmark_config_spec.BenchmarkConfigSpec(
            _BENCHMARK_NAME, flag_values=mocked_flags, vm_groups={})
        self.spec = benchmark_spec.BenchmarkSpec(mock.MagicMock(), config_spec,
                                                 _BENCHMARK_UID)
        self.addCleanup(context.SetThreadBenchmarkSpec, None)

        self.vm = aws_virtual_machine.AwsVirtualMachine(
            aws_virtual_machine.AwsVmSpec('test_vm_spec.AWS',
                                          zone='us-east-1a',
                                          machine_type='c3.large',
                                          spot_price=123.45))
        self.vm.id = 'i-foo'
        self.vm.image = 'ami-12345'
        self.vm.client_token = '00000000-1111-2222-3333-444444444444'
        network_mock = mock.MagicMock()
        network_mock.subnet = mock.MagicMock(id='subnet-id')
        placement_group = mock.MagicMock()
        placement_group.name = 'placement_group_name'
        network_mock.placement_group = placement_group
        self.vm.network = network_mock

        self.response = self.openJsonData('aws-describe-instance.json')
        self.sir_response =\
            self.openJsonData('aws-describe-spot-instance-requests.json')
コード例 #8
0
 def _CreateVm(self):
     vm_spec = aws_virtual_machine.AwsVmSpec(
         'test_vm_spec.AWS',
         zone='us-east-1a',
         machine_type='test_machine_type')
     return aws_virtual_machine.DebianBasedAwsVirtualMachine(vm_spec)
コード例 #9
0
def CreateTestAwsVm():
    vm_spec = aws_virtual_machine.AwsVmSpec('test_vm_spec.AWS',
                                            zone='us-east-1a',
                                            machine_type='c3.large',
                                            spot_price=123.45)
    return TestAwsVirtualMachine(vm_spec=vm_spec)
コード例 #10
0
def TestVmSpec():
    return aws_virtual_machine.AwsVmSpec('test_vm_spec.AWS',
                                         zone='us-east-1a',
                                         machine_type='c3.large',
                                         spot_price=123.45)