def test_lb_policy(self): # Verify there is no lb information in node data cluster = utils.get_a_cluster(self, self.cluster_id) for n in cluster['nodes']: node = utils.get_a_node(self, n) self.assertNotIn('lb_member', node['data']) # Create a lb policy spec = constants.spec_lb_policy policy_id = utils.create_a_policy(self, spec) lb_policy = utils.get_a_policy(self, policy_id) self.addCleanup(utils.delete_a_policy, self, lb_policy['id']) # Attach lb policy to cluster utils.cluster_attach_policy(self, self.cluster_id, lb_policy['id']) # Verify lb information is added into node data cluster = utils.get_a_cluster(self, self.cluster_id) for n in cluster['nodes']: node = utils.get_a_node(self, n) self.assertIn('lb_member', node['data']) # Scale out cluster utils.cluster_scale_out(self, self.cluster_id) # Verify scale out result cluster = utils.get_a_cluster(self, self.cluster_id) self.assertEqual('ACTIVE', cluster['status']) self.assertEqual(3, cluster['desired_capacity']) self.assertEqual(3, len(cluster['nodes'])) # Verify lb information in all nodes' data cluster = utils.get_a_cluster(self, self.cluster_id) for n in cluster['nodes']: node = utils.get_a_node(self, n) self.assertIn('lb_member', node['data']) # Scale in cluster utils.cluster_scale_in(self, self.cluster_id) # Verify scale in result cluster = utils.get_a_cluster(self, self.cluster_id) self.assertEqual('ACTIVE', cluster['status']) self.assertEqual(2, cluster['desired_capacity']) self.assertEqual(2, len(cluster['nodes'])) for n in cluster['nodes']: node = utils.get_a_node(self, n) self.assertIn('lb_member', node['data']) # Detach lb policy from cluster utils.cluster_detach_policy(self, self.cluster_id, lb_policy['id']) # Verify lb information has been removed from node data cluster = utils.get_a_cluster(self, self.cluster_id) for n in cluster['nodes']: node = utils.get_a_node(self, n) self.assertNotIn('lb_member', node['data'])
def test_cluster_create_delete(self): # Create a cluster desired_capacity = 2 min_size = 1 max_size = 3 metadata = {'k1': 'v1'} timeout = 600 cluster_id = utils.create_a_cluster( self, self.profile_id, desired_capacity, min_size, max_size, timeout, metadata) # Verify creation result cluster = utils.get_a_cluster(self, cluster_id) self.assertIsNotNone(cluster) self.assertEqual(desired_capacity, cluster['desired_capacity']) self.assertEqual(desired_capacity, len(cluster['nodes'])) for nid in cluster['nodes']: node = utils.get_a_node(self, nid, show_details=True) self.assertEqual('ACTIVE', node['status']) self.assertEqual(cluster_id, node['cluster_id']) self.assertIsNotNone(node['details']) self.assertEqual('ACTIVE', node['details']['status']) self.assertEqual(self.spec['properties']['flavor'], node['details']['flavor']) self.assertEqual(self.spec['properties']['name'], node['details']['name']) metadata = { 'cluster_id': cluster['id'], 'cluster_node_id': node['id'], 'cluster_node_index': six.text_type(node['index']) } self.assertEqual(metadata, node['details']['metadata']) # Delete cluster utils.delete_a_cluster(self, cluster_id)
def test_cluster_update_profile(self): # Update cluster utils.update_a_cluster(self, self.cluster_id, profile_id=self.profile_id_new) # Verify update result cluster = utils.get_a_cluster(self, self.cluster_id) self.assertEqual(self.profile_id_new, cluster['profile_id']) nodes = cluster['nodes'] for n in nodes: node = utils.get_a_node(self, n) self.assertEqual(self.profile_id_new, node['profile_id'])
def test_cluster_create_delete(self): # Create a cluster desired_capacity = 2 min_size = 1 max_size = 3 metadata = {'k1': 'v1'} timeout = 300 cluster_id = utils.create_a_cluster(self, self.profile_id, desired_capacity, min_size, max_size, timeout, metadata) # Verify creation result cluster = utils.get_a_cluster(self, cluster_id) self.assertIsNotNone(cluster) self.assertEqual(desired_capacity, cluster['desired_capacity']) self.assertEqual(desired_capacity, len(cluster['nodes'])) for nid in cluster['nodes']: node = utils.get_a_node(self, nid) self.assertEqual('ACTIVE', node['status']) self.assertEqual(cluster_id, node['cluster_id']) # Delete cluster utils.delete_a_cluster(self, cluster_id)