Example #1
0
    def test_node_check_recover(self):
        # Create a node
        node1 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'],
                                     role='master')
        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')

        # Check node health status
        action_id = test_api.action_node(self.client, node1['id'], 'check')
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')
        node1 = test_api.get_node(self.client, node1['id'])
        self.assertEqual('ACTIVE', node1['status'])

        # Perform node recovering operation
        action_id = test_api.action_node(self.client, node1['id'], 'recover')
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')
        action_id = test_api.action_node(self.client, node1['id'], 'recover',
                                         {'operation': 'REBUILD'})
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        # Delete node
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client, node1['id'])
Example #2
0
    def test_node_check_recover(self):
        # Create a node
        node1 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'],
                                     role='master')
        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')

        # Check node health status
        action_id = test_api.action_node(self.client, node1['id'], 'check')
        test_utils.wait_for_status(test_api.get_action, self.client, action_id,
                                   'SUCCEEDED')
        node1 = test_api.get_node(self.client, node1['id'])
        self.assertEqual('ACTIVE', node1['status'])

        # Perform node recovering operation
        action_id = test_api.action_node(self.client, node1['id'], 'recover')
        test_utils.wait_for_status(test_api.get_action, self.client, action_id,
                                   'SUCCEEDED')
        action_id = test_api.action_node(self.client, node1['id'], 'recover',
                                         {'operation': 'REBUILD'})
        test_utils.wait_for_status(test_api.get_action, self.client, action_id,
                                   'SUCCEEDED')

        # Delete node
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client, node1['id'])
Example #3
0
    def test_node_create_join_leave_cluster(self):
        # Create a cluster
        desired_capacity = 0
        min_size = 0
        max_size = 3
        cluster = test_api.create_cluster(self.client, 'test-cluster',
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create a node and let it join the cluster
        node1 = test_api.create_node(self.client, 'node1', self.profile['id'])
        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        action_id = test_api.action_node(self.client, node1['id'], 'join',
                                         {'cluster_id': cluster['id']})
        test_utils.wait_for_status(test_api.get_action, self.client, action_id,
                                   'SUCCEEDED')

        node1 = test_api.get_node(self.client, node1['id'])
        self.assertEqual(cluster['id'], node1['cluster_id'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])

        # Let node1 leave the cluster
        action_id = test_api.action_node(self.client, node1['id'], 'leave')
        test_utils.wait_for_status(test_api.get_action, self.client, action_id,
                                   'SUCCEEDED')

        node1 = test_api.get_node(self.client, node1['id'])
        self.assertIsNone(node1['cluster_id'])
        self.assertEqual(-1, node1['index'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(0, len(cluster['nodes']))

        # Delete node1
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_status(test_api.get_node,
                                   self.client,
                                   node1['id'],
                                   'DELETED',
                                   ignore_missing=True)

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_status(test_api.get_cluster,
                                   self.client,
                                   cluster['id'],
                                   'DELETED',
                                   ignore_missing=True)
Example #4
0
    def test_node_create_join_leave_cluster(self):
        # Create a cluster
        desired_capacity = 0
        min_size = 0
        max_size = 3
        cluster = test_api.create_cluster(self.client, 'test-cluster',
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create a node and let it join the cluster
        node1 = test_api.create_node(self.client, 'node1',
                                     self.profile['id'])
        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        action_id = test_api.action_node(self.client, node1['id'], 'join',
                                         {'cluster_id': cluster['id']})
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        node1 = test_api.get_node(self.client, node1['id'])
        self.assertEqual(cluster['id'], node1['cluster_id'])
        self.assertEqual(1, node1['index'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])

        # Let node1 leave the cluster
        action_id = test_api.action_node(self.client, node1['id'], 'leave')
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        node1 = test_api.get_node(self.client, node1['id'])
        self.assertIsNone(node1['cluster_id'])
        self.assertEqual(-1, node1['index'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(0, len(cluster['nodes']))

        # Delete node1
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_status(test_api.get_node, self.client,
                                   node1['id'], 'DELETED',
                                   ignore_missing=True)

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_status(test_api.get_cluster, self.client,
                                   cluster['id'], 'DELETED',
                                   ignore_missing=True)
Example #5
0
    def test_node_create_delete_with_target_cluster(self):
        # Create a cluster
        desired_capacity = 1
        min_size = 1
        max_size = 3
        cluster = test_api.create_cluster(self.client,
                                          test_utils.random_name('cluster'),
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create a node belongs to the cluster
        node1 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'],
                                     cluster_id=cluster['id'],
                                     role='master')

        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        self.assertEqual(cluster['id'], node1['cluster_id'])
        self.assertEqual(2, node1['index'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(2, cluster['desired_capacity'])
        self.assertEqual(2, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])

        # List nodes
        nodes = test_api.list_nodes(self.client)
        nodes_id = [n['id'] for n in nodes]
        self.assertIn(node1['id'], nodes_id)
        for n_id in cluster['nodes']:
            self.assertIn(n_id, nodes_id)

        # Delete node1 from cluster
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client, node1['id'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertNotIn(node1['id'], cluster['nodes'])

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_delete(test_api.get_cluster, self.client,
                                   cluster['id'])
Example #6
0
    def test_node_create_delete_with_target_cluster(self):
        # Create a cluster
        desired_capacity = 1
        min_size = 1
        max_size = 3
        cluster = test_api.create_cluster(self.client,
                                          test_utils.random_name('cluster'),
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create a node belongs to the cluster
        node1 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'],
                                     cluster_id=cluster['id'],
                                     role='master')

        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        self.assertEqual(cluster['id'], node1['cluster_id'])
        self.assertEqual(2, node1['index'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(2, cluster['desired_capacity'])
        self.assertEqual(2, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])

        # List nodes
        nodes = test_api.list_nodes(self.client)
        nodes_id = [n['id'] for n in nodes]
        self.assertIn(node1['id'], nodes_id)
        for n_id in cluster['nodes']:
            self.assertIn(n_id, nodes_id)

        # Delete node1 from cluster
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client, node1['id'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertNotIn(node1['id'], cluster['nodes'])

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_delete(test_api.get_cluster, self.client,
                                   cluster['id'])
Example #7
0
    def test_node_create_delete_with_target_cluster(self):
        # Create a cluster
        desired_capacity = 1
        min_size = 1
        max_size = 3
        cluster = test_api.create_cluster(self.client, 'test-cluster',
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create a node belongs to the cluster
        node1 = test_api.create_node(self.client,
                                     'node1',
                                     self.profile['id'],
                                     cluster_id=cluster['id'],
                                     role='master')

        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        self.assertEqual(cluster['id'], node1['cluster_id'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(2, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])

        # Delete node1 from cluster
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_status(test_api.get_node,
                                   self.client,
                                   node1['id'],
                                   'DELETED',
                                   ignore_missing=True)
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertNotIn(node1['id'], cluster['nodes'])

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_status(test_api.get_cluster,
                                   self.client,
                                   cluster['id'],
                                   'DELETED',
                                   ignore_missing=True)
Example #8
0
    def test_node_get_detail(self):
        node = test_api.create_node(self.client,
                                    test_utils.random_name('node'),
                                    self.profile['id'])
        test_utils.wait_for_status(test_api.get_node, self.client,
                                   node['id'], 'ACTIVE')

        # Get node detail and verify
        node = test_api.get_node(self.client, node['id'], show_details=True)
        self.assertIn('details', node)
        self.assertEqual("new-server-test", node['details']['name'])
        self.assertEqual("1", node['details']['flavor'])
        self.assertEqual("FAKE_IMAGE_ID", node['details']['image'])
        self.assertEqual("ACTIVE", node['details']['status'])
        self.assertEqual({"My Server Name": "Apache1"},
                         node['details']['metadata'])

        # Delete node from cluster
        test_api.delete_node(self.client, node['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client, node['id'])
Example #9
0
    def test_node_get_detail(self):
        node = test_api.create_node(self.client,
                                    test_utils.random_name('node'),
                                    self.profile['id'])
        test_utils.wait_for_status(test_api.get_node, self.client, node['id'],
                                   'ACTIVE')

        # Get node detail and verify
        node = test_api.get_node(self.client, node['id'], show_details=True)
        self.assertIn('details', node)
        self.assertEqual("new-server-test", node['details']['name'])
        self.assertEqual("1", node['details']['flavor'])
        self.assertEqual("FAKE_IMAGE_ID", node['details']['image'])
        self.assertEqual("ACTIVE", node['details']['status'])
        self.assertEqual({"My Server Name": "Apache1"},
                         node['details']['metadata'])

        # Delete node from cluster
        test_api.delete_node(self.client, node['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client, node['id'])
Example #10
0
    def test_node_create_delete_with_target_cluster(self):
        # Create a cluster
        desired_capacity = 1
        min_size = 1
        max_size = 3
        cluster = test_api.create_cluster(self.client, 'test-cluster',
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create a node belongs to the cluster
        node1 = test_api.create_node(self.client, 'node1',
                                     self.profile['id'],
                                     cluster_id=cluster['id'],
                                     role='master')

        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        self.assertEqual(cluster['id'], node1['cluster_id'])
        self.assertEqual(2, node1['index'])
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(2, cluster['desired_capacity'])
        self.assertEqual(2, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])

        # Delete node1 from cluster
        test_api.delete_node(self.client, node1['id'])
        test_utils.wait_for_status(test_api.get_node, self.client,
                                   node1['id'], 'DELETED',
                                   ignore_missing=True)
        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertNotIn(node1['id'], cluster['nodes'])

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_status(test_api.get_cluster, self.client,
                                   cluster['id'], 'DELETED',
                                   ignore_missing=True)
    def test_cluster_node_add_del(self):
        # Create cluster
        desired_capacity = 1
        min_size = 1
        max_size = 3
        cluster_name = test_utils.random_name('cluster')
        cluster = test_api.create_cluster(self.client, cluster_name,
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create two orphan nodes
        node1 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'])
        node2 = test_api.create_node(self.client,
                                     test_utils.random_name('node2'),
                                     self.profile['id'])

        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        node2 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node2['id'], 'ACTIVE')

        self.assertEqual('', node1['cluster_id'])
        self.assertEqual(-1, node1['index'])
        self.assertEqual('', node2['cluster_id'])
        self.assertEqual(-1, node2['index'])

        # Add orphan nodes to cluster
        params = {
            'nodes': [node1['id'], node2['id']],
        }
        action_id = test_api.action_cluster(self.client, cluster['id'],
                                            'add_nodes', params)
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(3, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])
        self.assertIn(node2['id'], cluster['nodes'])

        node1 = test_api.get_node(self.client, node1['id'])
        node2 = test_api.get_node(self.client, node2['id'])
        self.assertEqual(cluster['id'], node1['cluster_id'])
        self.assertEqual(cluster['id'], node2['cluster_id'])
        self.assertEqual(2, node1['index'])
        self.assertEqual(3, node2['index'])

        # Remove nodes from cluster
        params = {
            'nodes': [node1['id'], node2['id']],
        }
        action_id = test_api.action_cluster(self.client, cluster['id'],
                                            'del_nodes', params)
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertNotIn(node1['id'], cluster['nodes'])
        self.assertNotIn(node2['id'], cluster['nodes'])

        node1 = test_api.get_node(self.client, node1['id'])
        node2 = test_api.get_node(self.client, node2['id'])
        self.assertEqual('', node1['cluster_id'])
        self.assertEqual('', node2['cluster_id'])
        self.assertEqual(-1, node1['index'])
        self.assertEqual(-1, node2['index'])

        # Delete orphan nodes
        test_api.delete_node(self.client, node1['id'])
        test_api.delete_node(self.client, node2['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client,
                                   node1['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client,
                                   node2['id'])

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_delete(test_api.get_cluster, self.client,
                                   cluster['id'])
    def test_cluster_node_add_del(self):
        # Create cluster
        desired_capacity = 1
        min_size = 1
        max_size = 3
        cluster_name = test_utils.random_name('cluster')
        cluster = test_api.create_cluster(self.client, cluster_name,
                                          self.profile['id'], desired_capacity,
                                          min_size, max_size)
        cluster = test_utils.wait_for_status(test_api.get_cluster, self.client,
                                             cluster['id'], 'ACTIVE')

        # Create two orphan nodes
        node1 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'])
        node2 = test_api.create_node(self.client,
                                     test_utils.random_name('node2'),
                                     self.profile['id'])

        node1 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node1['id'], 'ACTIVE')
        node2 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node2['id'], 'ACTIVE')

        self.assertEqual('', node1['cluster_id'])
        self.assertEqual(-1, node1['index'])
        self.assertEqual('', node2['cluster_id'])
        self.assertEqual(-1, node2['index'])

        # Add orphan nodes to cluster
        params = {
            'nodes': [node1['id'], node2['id']],
        }
        action_id = test_api.action_cluster(self.client, cluster['id'],
                                            'add_nodes', params)
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(3, cluster['desired_capacity'])
        self.assertEqual(3, len(cluster['nodes']))
        self.assertIn(node1['id'], cluster['nodes'])
        self.assertIn(node2['id'], cluster['nodes'])

        node1 = test_api.get_node(self.client, node1['id'])
        node2 = test_api.get_node(self.client, node2['id'])
        self.assertEqual(cluster['id'], node1['cluster_id'])
        self.assertEqual(cluster['id'], node2['cluster_id'])
        self.assertEqual([2, 3], sorted([node1['index'], node2['index']]))

        # Create one more orphan node and add it to cluster
        node3 = test_api.create_node(self.client,
                                     test_utils.random_name('node1'),
                                     self.profile['id'])
        node3 = test_utils.wait_for_status(test_api.get_node, self.client,
                                           node3['id'], 'ACTIVE')
        params = {
            'nodes': [node3['id']],
        }
        res = test_api.action_cluster(self.client, cluster['id'], 'add_nodes',
                                      params)
        reason = _("The target capacity (4) is greater than the cluster's "
                   "max_size (3).")
        self.assertIn(reason, res)

        # Remove two nodes from cluster
        params = {
            'nodes': [node1['id'], node2['id']],
        }
        action_id = test_api.action_cluster(self.client, cluster['id'],
                                            'del_nodes', params)
        test_utils.wait_for_status(test_api.get_action, self.client,
                                   action_id, 'SUCCEEDED')

        cluster = test_api.get_cluster(self.client, cluster['id'])
        self.assertEqual(1, cluster['desired_capacity'])
        self.assertEqual(1, len(cluster['nodes']))
        self.assertNotIn(node1['id'], cluster['nodes'])
        self.assertNotIn(node2['id'], cluster['nodes'])

        node1 = test_api.get_node(self.client, node1['id'])
        node2 = test_api.get_node(self.client, node2['id'])
        self.assertEqual('', node1['cluster_id'])
        self.assertEqual('', node2['cluster_id'])
        self.assertEqual(-1, node1['index'])
        self.assertEqual(-1, node2['index'])

        # Try to delete the last node from cluster
        last_node_id = cluster['nodes'][0]
        params = {
            'nodes': [last_node_id]
        }
        res = test_api.action_cluster(self.client, cluster['id'], 'del_nodes',
                                      params)
        reason = _("The target capacity (0) is less than the cluster's "
                   "min_size (1).")
        self.assertIn(reason, res)

        # Delete orphan nodes
        test_api.delete_node(self.client, node1['id'])
        test_api.delete_node(self.client, node2['id'])
        test_api.delete_node(self.client, node3['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client,
                                   node1['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client,
                                   node2['id'])
        test_utils.wait_for_delete(test_api.get_node, self.client,
                                   node3['id'])

        # Delete cluster
        test_api.delete_cluster(self.client, cluster['id'])
        test_utils.wait_for_delete(test_api.get_cluster, self.client,
                                   cluster['id'])