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)
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)
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)
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)
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')
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')
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')
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)
def testDefaultBackupEnabled(self): result = benchmark_config_spec._RelationalDbSpec(_COMPONENT, flag_values=FLAGS, **self.minimal_spec) self.assertEqual(result.backup_enabled, True)
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)
def testDefaultDatabaseName(self): result = benchmark_config_spec._RelationalDbSpec(_COMPONENT, flag_values=FLAGS, **self.minimal_spec) self.assertEqual(result.database_name, 'pkb-db-123')
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)
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')
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)
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')
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')
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')
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)
def testDefaultBackupTime(self): result = benchmark_config_spec._RelationalDbSpec(_COMPONENT, flag_values=FLAGS, **self.minimal_spec) self.assertEqual(result.backup_start_time, '07:00')
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')
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)
def testDefaultHighAvailability(self): result = benchmark_config_spec._RelationalDbSpec(_COMPONENT, flag_values=FLAGS, **self.minimal_spec) self.assertEqual(result.high_availability, False)
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')
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)