def setup_poll_test(self, mock_driver, mock_openstack_client, mock_conf, mock_retrieve_cluster_template): mock_conf.cluster_heat.max_attempts = 10 worker_ng = mock.MagicMock( uuid='5d12f6fd-a196-4bf0-ae4c-1f639a523a53', role='worker', node_count=1, ) master_ng = mock.MagicMock( uuid='5d12f6fd-a196-4bf0-ae4c-1f639a523a54', role='master', node_count=1, ) cluster = mock.MagicMock(nodegroups=[worker_ng, master_ng], default_ng_worker=worker_ng, default_ng_master=master_ng) mock_heat_stack = mock.MagicMock() mock_heat_client = mock.MagicMock() mock_heat_client.stacks.get.return_value = mock_heat_stack mock_openstack_client.heat.return_value = mock_heat_client mock_driver.return_value = mesos_dr.Driver() cluster_template = objects.ClusterTemplate( self.context, **self.cluster_template_dict) mock_retrieve_cluster_template.return_value = cluster_template poller = heat_driver.HeatPoller(mock_openstack_client, mock.MagicMock(), cluster, mesos_dr.Driver()) poller.template_def.add_nodegroup_params(cluster) poller.get_version_info = mock.MagicMock() return (mock_heat_stack, cluster, poller)
def test_get_vm_ubuntu_mesos_definition(self, mock_driver): mock_driver.return_value = mesos_dr.Driver() cluster_driver = driver.Driver.get_driver('vm', 'ubuntu', 'mesos') definition = cluster_driver.get_template_definition() self.assertIsInstance(definition, mesos_tdef.UbuntuMesosTemplateDefinition)
def test_extract_template_definition_with_lb_neutron( self, mock_kc, mock_driver, mock_objects_nodegroup_list, mock_objects_cluster_template_get_by_uuid): self.cluster_template_dict['master_lb_enabled'] = True cluster_template = objects.ClusterTemplate( self.context, **self.cluster_template_dict) mock_objects_cluster_template_get_by_uuid.return_value = \ cluster_template cluster = objects.Cluster(self.context, **self.cluster_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) mock_objects_nodegroup_list.return_value = [master_ng, worker_ng] mock_driver.return_value = mesos_dr.Driver() mock_kc.return_value.client.services.list.return_value = [] (template_path, definition, env_files) = mock_driver()._extract_template_definition( self.context, cluster) expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', 'fixed_network': 'fixed_network', 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', 'slave_flavor': 'flavor_id', 'number_of_slaves': 1, 'number_of_masters': 1, 'http_proxy': 'http_proxy', 'https_proxy': 'https_proxy', 'no_proxy': 'no_proxy', 'cluster_name': 'cluster1', 'trustee_domain_id': self.mock_keystone.trustee_domain_id, 'trustee_username': '******', 'trustee_password': '******', 'trustee_user_id': '7b489f04-b458-4541-8179-6a48a553e656', 'trust_id': '', 'volume_driver': 'volume_driver', 'auth_url': 'http://192.168.10.10:5000/v3', 'region_name': self.mock_osc.cinder_region_name.return_value, 'username': '******', 'tenant_name': 'admin', 'domain_name': 'domainname', 'rexray_preempt': 'False', 'mesos_slave_executor_env_variables': '{}', 'mesos_slave_isolation': 'docker/runtime,filesystem/linux', 'mesos_slave_work_dir': '/tmp/mesos/slave', 'mesos_slave_image_providers': 'docker', 'verify_ca': True, 'openstack_ca': '', 'nodes_affinity_policy': 'soft-anti-affinity' } self.assertEqual(expected, definition) self.assertEqual([ '../../common/templates/environments/no_private_network.yaml', '../../common/templates/environments/with_master_lb.yaml' ], env_files)
def setup_poll_test(self, mock_driver, mock_openstack_client, mock_conf, mock_retrieve_cluster_template): mock_conf.cluster_heat.max_attempts = 10 cluster = mock.MagicMock() mock_heat_stack = mock.MagicMock() mock_heat_client = mock.MagicMock() mock_heat_client.stacks.get.return_value = mock_heat_stack mock_openstack_client.heat.return_value = mock_heat_client mock_driver.return_value = mesos_dr.Driver() cluster_template = objects.ClusterTemplate( self.context, **self.cluster_template_dict) mock_retrieve_cluster_template.return_value = cluster_template poller = cluster_conductor.HeatPoller(mock_openstack_client, cluster, mesos_dr.Driver()) poller.get_version_info = mock.MagicMock() return (mock_heat_stack, cluster, poller)
def test_extract_template_definition_multi_master( self, mock_driver, mock_objects_cluster_template_get_by_uuid): self.cluster_template_dict['master_lb_enabled'] = True self.cluster_dict['master_count'] = 2 cluster_template = objects.ClusterTemplate( self.context, **self.cluster_template_dict) mock_objects_cluster_template_get_by_uuid.return_value = \ cluster_template cluster = objects.Cluster(self.context, **self.cluster_dict) mock_driver.return_value = mesos_dr.Driver() (template_path, definition, env_files) = mock_driver()._extract_template_definition( self.context, cluster) expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', 'fixed_network': 'fixed_network', 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', 'slave_flavor': 'flavor_id', 'number_of_slaves': 1, 'number_of_masters': 2, 'http_proxy': 'http_proxy', 'https_proxy': 'https_proxy', 'no_proxy': 'no_proxy', 'cluster_name': 'cluster1', 'trustee_domain_id': self.mock_keystone.trustee_domain_id, 'trustee_username': '******', 'trustee_password': '******', 'trustee_user_id': '7b489f04-b458-4541-8179-6a48a553e656', 'trust_id': 'bd11efc5-d4e2-4dac-bbce-25e348ddf7de', 'volume_driver': 'volume_driver', 'auth_url': 'http://192.168.10.10:5000/v3', 'region_name': self.mock_osc.cinder_region_name.return_value, 'username': '******', 'tenant_name': 'admin', 'domain_name': 'domainname', 'rexray_preempt': 'False', 'mesos_slave_executor_env_variables': '{}', 'mesos_slave_isolation': 'docker/runtime,filesystem/linux', 'mesos_slave_work_dir': '/tmp/mesos/slave', 'mesos_slave_image_providers': 'docker' } self.assertEqual(expected, definition) self.assertEqual([ '../../common/templates/environments/no_private_network.yaml', '../../common/templates/environments/with_master_lb.yaml' ], env_files)