Esempio n. 1
0
    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'])
Esempio n. 2
0
    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'])
Esempio n. 3
0
    def test_node_create_show_list_delete(self):
        # Create an orphan node
        name = data_utils.rand_name('node')
        metadata = {'k1': 'v1'}
        role = 'individual'
        node_id1 = utils.create_a_node(self,
                                       self.profile_id,
                                       metadata=metadata,
                                       role=role,
                                       name=name)

        # Verify creation result
        node1 = utils.get_a_node(self, node_id1)
        self.assertIsNotNone(node1)
        self.assertEqual(name, node1['name'])
        self.assertEqual(metadata, node1['metadata'])
        self.assertEqual(role, node1['role'])
        self.assertEqual('', node1['cluster_id'])
        self.assertNotIn('details', node1)

        # Get node with detail
        node1 = utils.get_a_node(self, node_id1, show_details=True)
        self.assertIn('details', node1)
        self.assertIsNotNone(node1['details'])

        # Create second node with target cluster
        name = data_utils.rand_name('node')
        node_id2 = utils.create_a_node(self,
                                       self.profile_id,
                                       cluster_id=self.cluster_id,
                                       metadata=metadata,
                                       role=role,
                                       name=name)

        # Verify creation result
        node2 = utils.get_a_node(self, node_id2)
        self.assertIsNotNone(node2)
        self.assertEqual(self.cluster_id, node2['cluster_id'])
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertIn(node_id2, cluster['nodes'])

        # List nodes
        nodes = utils.list_nodes(self)
        self.assertIsNotNone(nodes)
        self.assertEqual(2, len(nodes))
        node_ids = [n['id'] for n in nodes]
        self.assertIn(node_id1, node_ids)
        self.assertIn(node_id2, node_ids)

        # Delete nodes
        utils.delete_a_node(self, node_id1)
        utils.delete_a_node(self, node_id2)
    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_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']:
            # TODO(Yanyan Hu)verify nova server property as well
            # after node show datail works.
            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)
Esempio n. 6
0
    def test_node_create_show_list_delete(self):
        # Create an orphan node
        name = data_utils.rand_name('node')
        metadata = {'k1': 'v1'}
        role = 'individual'
        node_id1 = utils.create_a_node(
            self, self.profile_id, metadata=metadata, role=role, name=name)

        # Verify creation result
        node1 = utils.get_a_node(self, node_id1)
        self.assertIsNotNone(node1)
        self.assertEqual(name, node1['name'])
        self.assertEqual(metadata, node1['metadata'])
        self.assertEqual(role, node1['role'])
        self.assertEqual('', node1['cluster_id'])
        self.assertNotIn('details', node1)

        # Get node with detail
        node1 = utils.get_a_node(self, node_id1, show_details=True)
        self.assertIn('details', node1)
        self.assertIsNotNone(node1['details'])

        # Create second node with target cluster
        name = data_utils.rand_name('node')
        node_id2 = utils.create_a_node(
            self, self.profile_id, cluster_id=self.cluster_id,
            metadata=metadata, role=role, name=name)

        # Verify creation result
        node2 = utils.get_a_node(self, node_id2)
        self.assertIsNotNone(node2)
        self.assertEqual(self.cluster_id, node2['cluster_id'])
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertIn(node_id2, cluster['nodes'])

        # List nodes
        nodes = utils.list_nodes(self)
        self.assertIsNotNone(nodes)
        self.assertEqual(2, len(nodes))
        node_ids = [n['id'] for n in nodes]
        self.assertIn(node_id1, node_ids)
        self.assertIn(node_id2, node_ids)

        # Delete nodes
        utils.delete_a_node(self, node_id1)
        utils.delete_a_node(self, node_id2)
Esempio n. 7
0
    def test_node_update_profile(self):

        # Update node
        utils.update_a_node(self, self.node_id, profile_id=self.profile_id_new)

        # Verify update result
        node = utils.get_a_node(self, self.node_id)
        self.assertEqual(self.profile_id_new, node['profile_id'])
Esempio n. 8
0
    def test_node_update_profile(self):

        # Update node
        utils.update_a_node(self, self.node_id, profile_id=self.profile_id_new)

        # Verify update result
        node = utils.get_a_node(self, self.node_id)
        self.assertEqual(self.profile_id_new, node['profile_id'])
Esempio n. 9
0
    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'])
Esempio n. 10
0
    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'])
Esempio n. 11
0
    def test_node_update_basic_properties(self):
        name = 'new-name'
        role = 'new-role'
        metadata = {'k2': 'v2'}

        # Update node
        utils.update_a_node(self, self.node_id, name=name, metadata=metadata,
                            role=role)

        # Verify update result
        node = utils.get_a_node(self, self.node_id)
        self.assertEqual(name, node['name'])
        self.assertEqual(metadata, node['metadata'])
        self.assertEqual(role, node['role'])
Esempio n. 12
0
    def test_node_update_basic_properties(self):
        name = 'new-name'
        role = 'new-role'
        metadata = {'k2': 'v2'}

        # Update node
        utils.update_a_node(self,
                            self.node_id,
                            name=name,
                            metadata=metadata,
                            role=role)

        # Verify update result
        node = utils.get_a_node(self, self.node_id)
        self.assertEqual(name, node['name'])
        self.assertEqual(metadata, node['metadata'])
        self.assertEqual(role, node['role'])
Esempio n. 13
0
    def test_cluster_node_add_del(self):
        # Add one node to cluster
        utils.cluster_add_nodes(self, self.cluster_id, [self.node_id1])

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(1, len(cluster['nodes']))
        self.assertIn(self.node_id1, cluster['nodes'])
        node1 = utils.get_a_node(self, self.node_id1)
        self.assertEqual(self.cluster_id, node1['cluster_id'])
        self.assertEqual(1, node1['index'])

        # Add two nodes to cluster
        nodes = [self.node_id2, self.node_id3]
        utils.cluster_add_nodes(self, self.cluster_id, nodes)

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(3, len(cluster['nodes']))
        self.assertIn(self.node_id2, cluster['nodes'])
        self.assertIn(self.node_id3, cluster['nodes'])
        node2 = utils.get_a_node(self, self.node_id2)
        node3 = utils.get_a_node(self, self.node_id3)
        self.assertEqual(self.cluster_id, node2['cluster_id'])
        self.assertEqual(self.cluster_id, node3['cluster_id'])
        self.assertEqual([2, 3], sorted([node2['index'], node3['index']]))

        # Delete one node from cluster
        utils.cluster_del_nodes(self, self.cluster_id, [self.node_id1])

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(2, len(cluster['nodes']))
        self.assertNotIn(self.node_id1, cluster['nodes'])
        node1 = utils.get_a_node(self, self.node_id1)
        self.assertEqual('', node1['cluster_id'])
        self.assertEqual(-1, node1['index'])

        # Delete two nodes from cluster
        nodes = [self.node_id2, self.node_id3]
        utils.cluster_del_nodes(self, self.cluster_id, nodes)

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(0, len(cluster['nodes']))
        node2 = utils.get_a_node(self, self.node_id2)
        node3 = utils.get_a_node(self, self.node_id3)
        self.assertEqual('', node2['cluster_id'])
        self.assertEqual('', node3['cluster_id'])
        self.assertEqual(-1, node2['index'])
        self.assertEqual(-1, node3['index'])
Esempio n. 14
0
    def test_cluster_node_add_del(self):
        # Add one node to cluster
        utils.cluster_add_nodes(self, self.cluster_id, [self.node_id1])

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(1, len(cluster['nodes']))
        self.assertIn(self.node_id1, cluster['nodes'])
        node1 = utils.get_a_node(self, self.node_id1)
        self.assertEqual(self.cluster_id, node1['cluster_id'])
        self.assertEqual(1, node1['index'])

        # Add two nodes to cluster
        nodes = [self.node_id2, self.node_id3]
        utils.cluster_add_nodes(self, self.cluster_id, nodes)

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(3, len(cluster['nodes']))
        self.assertIn(self.node_id2, cluster['nodes'])
        self.assertIn(self.node_id3, cluster['nodes'])
        node2 = utils.get_a_node(self, self.node_id2)
        node3 = utils.get_a_node(self, self.node_id3)
        self.assertEqual(self.cluster_id, node2['cluster_id'])
        self.assertEqual(self.cluster_id, node3['cluster_id'])
        self.assertEqual([2, 3], sorted([node2['index'], node3['index']]))

        # Delete one node from cluster
        utils.cluster_del_nodes(self, self.cluster_id, [self.node_id1])

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(2, len(cluster['nodes']))
        self.assertNotIn(self.node_id1, cluster['nodes'])
        node1 = utils.get_a_node(self, self.node_id1)
        self.assertEqual('', node1['cluster_id'])
        self.assertEqual(-1, node1['index'])

        # Delete two nodes from cluster
        nodes = [self.node_id2, self.node_id3]
        utils.cluster_del_nodes(self, self.cluster_id, nodes)

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(0, len(cluster['nodes']))
        node2 = utils.get_a_node(self, self.node_id2)
        node3 = utils.get_a_node(self, self.node_id3)
        self.assertEqual('', node2['cluster_id'])
        self.assertEqual('', node3['cluster_id'])
        self.assertEqual(-1, node2['index'])
        self.assertEqual(-1, node3['index'])
Esempio n. 15
0
    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)
Esempio n. 16
0
    def test_cluster_replace_node(self):
        # Verify the cluster
        cluster = utils.get_a_cluster(self, self.cluster_id)
        cluster_nodes = cluster['nodes']
        self.assertEqual(3, len(cluster_nodes))
        self.assertEqual('ACTIVE', cluster['status'])

        # Replace one node
        nodes = {self.old_id1: self.new_id1}
        utils.cluster_replace_nodes(self, self.cluster_id, nodes)
        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        cluster_nodes = cluster['nodes']
        self.assertEqual(3, len(cluster_nodes))
        self.assertIn(self.new_id1, cluster_nodes)
        new_node1 = utils.get_a_node(self, self.new_id1)
        old_node1 = utils.get_a_node(self, self.old_id1)
        self.assertEqual(self.cluster_id, new_node1['cluster_id'])
        self.assertEqual('', old_node1['cluster_id'])

        # Replace two nodes
        nodes = {self.old_id2: self.new_id2, self.old_id3: self.new_id3}
        utils.cluster_replace_nodes(self, self.cluster_id, nodes)

        # Verify result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        cluster_nodes = cluster['nodes']
        self.assertEqual(3, len(cluster_nodes))
        self.assertIn(self.new_id2, cluster_nodes)
        self.assertIn(self.new_id3, cluster_nodes)
        new_node2 = utils.get_a_node(self, self.new_id2)
        new_node3 = utils.get_a_node(self, self.new_id3)
        old_node2 = utils.get_a_node(self, self.old_id2)
        old_node3 = utils.get_a_node(self, self.old_id3)
        self.assertEqual(self.cluster_id, new_node2['cluster_id'])
        self.assertEqual(self.cluster_id, new_node3['cluster_id'])
        self.assertEqual('', old_node2['cluster_id'])
        self.assertEqual('', old_node3['cluster_id'])