def test_extract_bay_definition_coreos_with_disovery( self, mock_objects_baymodel_get_by_uuid, reqget): cfg.CONF.set_override('cluster_type', 'coreos', group='k8s_heat') cfg.CONF.set_override('discovery_token_url', 'http://tokentest', group='k8s_heat') mock_req = mock.MagicMock(text='/h1/h2/h3') reqget.return_value = mock_req baymodel = objects.BayModel(self.context, **self.baymodel_dict) mock_objects_baymodel_get_by_uuid.return_value = baymodel bay = objects.Bay(self.context, **self.bay_dict) bay_definition = bay_k8s_heat._extract_bay_definition( self.context, bay) expected = { 'ssh_key_name': 'keypair_id', 'external_network_id': 'external_network_id', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'server_flavor': 'flavor_id', 'master_flavor': 'master_flavor_id', 'number_of_minions': '1', 'fixed_network': 'private', 'docker_volume_size': 20, 'ssh_authorized_key': 'ssh_authorized_key', 'token': 'h3' } self.assertEqual(expected, bay_definition)
def test_extract_bay_definition_coreos_no_discoveryurl( self, mock_objects_baymodel_get_by_uuid, mock_uuid): cfg.CONF.set_override('cluster_type', 'coreos', group='k8s_heat') cfg.CONF.set_override('discovery_token_url', None, group='k8s_heat') mock_uuid.return_value = mock.MagicMock( hex='ba3d1866282848ddbedc76112110c208') baymodel = objects.BayModel(self.context, **self.baymodel_dict) mock_objects_baymodel_get_by_uuid.return_value = baymodel bay = objects.Bay(self.context, **self.bay_dict) bay_definition = bay_k8s_heat._extract_bay_definition( self.context, bay) expected = { 'ssh_key_name': 'keypair_id', 'external_network_id': 'external_network_id', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'server_flavor': 'flavor_id', 'master_flavor': 'master_flavor_id', 'number_of_minions': '1', 'fixed_network': 'private', 'docker_volume_size': 20, 'ssh_authorized_key': 'ssh_authorized_key', 'token': 'ba3d1866282848ddbedc76112110c208' } self.assertEqual(expected, bay_definition)
def test_extract_bay_definition_coreos_with_disovery(self, mock_objects_baymodel_get_by_uuid, reqget): cfg.CONF.set_override('cluster_type', 'coreos', group='k8s_heat') cfg.CONF.set_override('discovery_token_url', 'http://tokentest', group='k8s_heat') mock_req = mock.MagicMock(text='/h1/h2/h3') reqget.return_value = mock_req baymodel = objects.BayModel(self.context, **self.baymodel_dict) mock_objects_baymodel_get_by_uuid.return_value = baymodel bay = objects.Bay(self.context, **self.bay_dict) bay_definition = bay_k8s_heat._extract_bay_definition(self.context, bay) expected = { 'ssh_key_name': 'keypair_id', 'external_network_id': 'external_network_id', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'server_flavor': 'flavor_id', 'master_flavor': 'master_flavor_id', 'number_of_minions': '1', 'fixed_network': 'private', 'docker_volume_size': 20, 'ssh_authorized_key': 'ssh_authorized_key', 'token': 'h3' } self.assertEqual(expected, bay_definition)
def test_extract_bay_definition_coreos_no_discoveryurl(self, mock_objects_baymodel_get_by_uuid, mock_uuid): cfg.CONF.set_override('cluster_type', 'coreos', group='k8s_heat') cfg.CONF.set_override('discovery_token_url', None, group='k8s_heat') mock_uuid.return_value = mock.MagicMock( hex='ba3d1866282848ddbedc76112110c208') baymodel = objects.BayModel(self.context, **self.baymodel_dict) mock_objects_baymodel_get_by_uuid.return_value = baymodel bay = objects.Bay(self.context, **self.bay_dict) bay_definition = bay_k8s_heat._extract_bay_definition(self.context, bay) expected = { 'ssh_key_name': 'keypair_id', 'external_network_id': 'external_network_id', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'server_flavor': 'flavor_id', 'master_flavor': 'master_flavor_id', 'number_of_minions': '1', 'fixed_network': 'private', 'docker_volume_size': 20, 'ssh_authorized_key': 'ssh_authorized_key', 'token': 'ba3d1866282848ddbedc76112110c208' } self.assertEqual(expected, bay_definition)
def test_extract_bay_definition(self, mock_objects_baymodel_get_by_uuid): baymodel = objects.BayModel(self.context, **self.baymodel_dict) mock_objects_baymodel_get_by_uuid.return_value = baymodel bay = objects.Bay(self.context, **self.bay_dict) bay_definition = bay_k8s_heat._extract_bay_definition( self.context, bay) expected = { 'ssh_key_name': 'keypair_id', 'external_network_id': 'external_network_id', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'server_flavor': 'flavor_id', 'master_flavor': 'master_flavor_id', 'number_of_minions': '1', 'fixed_network': 'private', 'docker_volume_size': 20, 'ssh_authorized_key': 'ssh_authorized_key', } self.assertEqual(expected, bay_definition)
def test_extract_bay_definition(self, mock_objects_baymodel_get_by_uuid): baymodel = objects.BayModel(self.context, **self.baymodel_dict) mock_objects_baymodel_get_by_uuid.return_value = baymodel bay = objects.Bay(self.context, **self.bay_dict) bay_definition = bay_k8s_heat._extract_bay_definition(self.context, bay) expected = { 'ssh_key_name': 'keypair_id', 'external_network_id': 'external_network_id', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'server_flavor': 'flavor_id', 'master_flavor': 'master_flavor_id', 'number_of_minions': '1', 'fixed_network': 'private', 'docker_volume_size': 20, 'ssh_authorized_key': 'ssh_authorized_key', } self.assertEqual(expected, bay_definition)