コード例 #1
0
 def testDiskSpecRequired(self):
     del self.spec['db_disk_spec']
     with self.assertRaisesRegexp(errors.Config.MissingOption,
                                  'db_disk_spec'):
         benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                 flag_values=FLAGS,
                                                 **self.spec)
コード例 #2
0
    def setUp(self):
        super(RelationalDbUnmanagedTestCase, self).setUp()
        FLAGS['run_uri'].value = '123456'
        self.min_mysql_spec = {
            'cloud': 'GCP',
            'engine': 'mysql',
            'engine_version': '5.7',
            'db_spec': {
                'GCP': {
                    'machine_type': 'n1-standard-1'
                }
            },
            'db_disk_spec': {
                'GCP': {
                    'disk_size': 500
                }
            }
        }

        self.min_postgres_spec = {
            'cloud': 'GCP',
            'engine': 'postgres',
            'engine_version': '11',
            'db_spec': {
                'GCP': {
                    'machine_type': 'n1-standard-1'
                }
            },
            'db_disk_spec': {
                'GCP': {
                    'disk_size': 500
                }
            }
        }

        self.min_sqlserver_spec = {
            'cloud': 'GCP',
            'engine': 'sqlserver',
            'engine_version': '2019',
            'db_spec': {
                'GCP': {
                    'machine_type': 'n1-standard-1'
                }
            },
            'db_disk_spec': {
                'GCP': {
                    'disk_size': 500
                }
            }
        }

        self.mysql_spec = benchmark_config_spec._RelationalDbSpec(
            _COMPONENT, flag_values=FLAGS, **self.min_mysql_spec)

        self.postgres_spec = benchmark_config_spec._RelationalDbSpec(
            _COMPONENT, flag_values=FLAGS, **self.min_postgres_spec)

        self.sqlserver_spec = benchmark_config_spec._RelationalDbSpec(
            _COMPONENT, flag_values=FLAGS, **self.min_sqlserver_spec)
コード例 #3
0
 def testMinimalConfig(self):
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.minimal_spec)
     self.assertEqual(result.engine, 'mysql')
     self.assertEqual(result.cloud, 'GCP')
     self.assertIsInstance(result.vm_spec, gce_virtual_machine.GceVmSpec)
コード例 #4
0
 def testDiskSizeFlag(self):
     FLAGS['managed_db_disk_size'].parse(2000)
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.db_disk_spec.disk_size, 2000)
     self.assertEqual(result.vm_groups['servers'].disk_spec.disk_size, 2000)
コード例 #5
0
 def testClientVmZoneFlag(self):
     FLAGS['client_vm_zone'].parse('us-east1-b')
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.vm_groups['clients'].vm_spec.zone,
                      'us-east1-b')
コード例 #6
0
 def testRandomDatabasePassword(self):
     spec = _mergeDicts(self.minimal_spec,
                        {'database_password': '******'})
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **spec)
     self.assertEqual(result.database_password, 'fakepassword')
コード例 #7
0
 def testZoneFlag(self):
     FLAGS['managed_db_zone'].parse('us-east1-b')
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.db_spec.zone, 'us-east1-b')
     self.assertEqual(result.vm_groups['servers'].vm_spec.zone,
                      'us-east1-b')
コード例 #8
0
  def setUp(self):
    super(RelationalDbUnamangedTestCase, self).setUp()
    self.minimal_spec = {
        'cloud': 'GCP',
        'engine': 'mysql',
        'engine_version': '5.7',
        'db_spec': {
            'GCP': {
                'machine_type': 'n1-standard-1'
            }
        },
        'db_disk_spec': {
            'GCP': {
                'disk_size': 500
            }
        }
    }

    self.spec = benchmark_config_spec._RelationalDbSpec(
        _COMPONENT, flag_values=FLAGS, **self.minimal_spec)
コード例 #9
0
 def testDefaultBackupEnabled(self):
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.minimal_spec)
     self.assertEqual(result.backup_enabled, True)
コード例 #10
0
 def testClientVmDiskSizeFlag(self):
   FLAGS['client_vm_disk_size'].parse(2000)
   result = benchmark_config_spec._RelationalDbSpec(
       _COMPONENT, flag_values=FLAGS, **self.full_spec)
   self.assertEqual(result.vm_groups['clients'].disk_spec.disk_size, 2000)
コード例 #11
0
 def testDefaultDatabaseName(self):
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.minimal_spec)
     self.assertEqual(result.database_name, 'pkb-db-123')
コード例 #12
0
 def testBackupEnabledFlag(self):
     FLAGS['managed_db_backup_enabled'].parse(False)
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.backup_enabled, False)
コード例 #13
0
 def testBackupStartTimeFlag(self):
     FLAGS['managed_db_backup_start_time'].parse('12:23')
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.backup_start_time, '12:23')
コード例 #14
0
 def testHighAvailabilityFlag(self):
     FLAGS['managed_db_high_availability'].parse(True)
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.high_availability, True)
コード例 #15
0
 def testDatabaseVersionFlag(self):
     FLAGS['managed_db_engine_version'].parse('5.6')
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.engine_version, '5.6')
コード例 #16
0
 def testCustomBackupTime(self):
     spec = _mergeDicts(self.minimal_spec, {'backup_start_time': '08:00'})
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **spec)
     self.assertEqual(result.backup_start_time, '08:00')
コード例 #17
0
 def testDatabasePasswordFlag(self):
     FLAGS['managed_db_database_password'].parse('fakepassword')
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.full_spec)
     self.assertEqual(result.database_password, 'fakepassword')
コード例 #18
0
 def testCustomBackupEnabled(self):
     spec = _mergeDicts(self.minimal_spec, {'backup_enabled': False})
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **spec)
     self.assertEqual(result.backup_enabled, False)
コード例 #19
0
 def testDefaultBackupTime(self):
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.minimal_spec)
     self.assertEqual(result.backup_start_time, '07:00')
コード例 #20
0
 def testCustomDatabaseName(self):
     spec = _mergeDicts(self.minimal_spec, {'database_name': 'fakename'})
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **spec)
     self.assertEqual(result.database_name, 'fakename')
コード例 #21
0
 def testCustomHighAvailability(self):
     spec = _mergeDicts(self.minimal_spec, {'high_availability': True})
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **spec)
     self.assertEqual(result.high_availability, True)
コード例 #22
0
 def testDefaultHighAvailability(self):
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.minimal_spec)
     self.assertEqual(result.high_availability, False)
コード例 #23
0
 def testCustomDatabaseVersion(self):
     spec = _mergeDicts(self.minimal_spec, {'engine_version': '6.6'})
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **spec)
     self.assertEqual(result.engine_version, '6.6')
コード例 #24
0
 def testDefaultDatabasePassword(self):
     result = benchmark_config_spec._RelationalDbSpec(_COMPONENT,
                                                      flag_values=FLAGS,
                                                      **self.minimal_spec)
     self.assertIsInstance(result.database_password, str)
     self.assertTrue(len(result.database_password) == 10)