Exemple #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'])
Exemple #2
0
 def setUp(self):
     super(TestClusterActionPolicyDetach, self).setUp()
     profile_id = utils.create_a_profile(self)
     self.addCleanup(utils.delete_a_profile, self, profile_id)
     self.cluster_id = utils.create_a_cluster(self, profile_id)
     self.addCleanup(utils.delete_a_cluster, self, self.cluster_id)
     self.policy_id = utils.create_a_policy(self)
     self.addCleanup(utils.delete_a_policy, self, self.policy_id)
     utils.cluster_attach_policy(self, self.cluster_id, self.policy_id)
 def setUp(self):
     super(TestClusterActionPolicyDetach, self).setUp()
     profile_id = utils.create_a_profile(self)
     self.addCleanup(utils.delete_a_profile, self, profile_id)
     self.cluster_id = utils.create_a_cluster(self, profile_id)
     self.addCleanup(utils.delete_a_cluster, self, self.cluster_id)
     self.policy_id = utils.create_a_policy(self)
     self.addCleanup(utils.delete_a_policy, self, self.policy_id)
     utils.cluster_attach_policy(self, self.cluster_id, self.policy_id)
Exemple #4
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'])
Exemple #5
0
    def setUp(self):
        super(TestClusterDeleteNegativePolicyConflict, self).setUp()
        profile_id = utils.create_a_profile(self)
        self.addCleanup(utils.delete_a_profile, self, profile_id)

        self.cluster_id = utils.create_a_cluster(self, profile_id)
        self.addCleanup(utils.delete_a_cluster, self, self.cluster_id)

        policy_id = utils.create_a_policy(self)
        self.addCleanup(utils.delete_a_policy, self, policy_id)

        utils.cluster_attach_policy(self, self.cluster_id, policy_id)
        self.addCleanup(utils.cluster_detach_policy, self, self.cluster_id,
                        policy_id)
    def setUp(self):
        super(TestPolicyDeleteNegativeConflict, self).setUp()
        profile_id = utils.create_a_profile(self)
        self.addCleanup(utils.delete_a_profile, self, profile_id)

        cluster_id = utils.create_a_cluster(self, profile_id)
        self.addCleanup(utils.delete_a_cluster, self, cluster_id)

        self.policy_id = utils.create_a_policy(self)
        self.addCleanup(utils.delete_a_policy, self, self.policy_id)

        utils.cluster_attach_policy(self, cluster_id, self.policy_id)
        self.addCleanup(utils.cluster_detach_policy, self, cluster_id,
                        self.policy_id)
Exemple #7
0
    def setUp(self):
        super(TestClusterPolicyShowNegativeBadRequest, self).setUp()
        profile_id = utils.create_a_profile(self)
        self.addCleanup(utils.delete_a_profile, self, profile_id)

        self.cluster_id = utils.create_a_cluster(self, profile_id)
        self.addCleanup(utils.delete_a_cluster, self, self.cluster_id)

        self.policy_id1 = utils.create_a_policy(self, name='test-policy')
        self.addCleanup(utils.delete_a_policy, self, self.policy_id1)
        self.policy_id2 = utils.create_a_policy(self, name='test-policy')
        self.addCleanup(utils.delete_a_policy, self, self.policy_id2)

        utils.cluster_attach_policy(self, self.cluster_id, self.policy_id1)
        self.addCleanup(utils.cluster_detach_policy, self, self.cluster_id,
                        self.policy_id1)
        utils.cluster_attach_policy(self, self.cluster_id, self.policy_id2)
        self.addCleanup(utils.cluster_detach_policy, self, self.cluster_id,
                        self.policy_id2)
    def test_batch_policy(self):
        # Create a batch policy targets on CLUSTER_UPDATE action
        spec = constants.spec_batch_policy
        policy_id = utils.create_a_policy(self, spec)
        self.addCleanup(utils.delete_a_policy, self, policy_id)

        # Attach batch policy to cluster
        utils.cluster_attach_policy(self, self.cluster_id, policy_id)
        self.addCleanup(utils.cluster_detach_policy, self, self.cluster_id,
                        policy_id)

        utils.update_a_cluster(self,
                               self.cluster_id,
                               profile_id=self.new_profile)

        # Verify cluster update result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual('ACTIVE', cluster['status'])
        self.assertEqual(2, len(cluster['nodes']))
        self.assertEqual(self.new_profile, cluster['profile_id'])
Exemple #9
0
    def test_scaling_policy(self):
        # Create a scaling policy targets on CLUSTER_SCALE_OUT action
        spec = constants.spec_scaling_policy
        spec['properties'] = {
            'event': 'CLUSTER_SCALE_OUT',
            'adjustment': {
                'type': 'CHANGE_IN_CAPACITY',
                'number': 2,
                'min_step': 1,
                'best_effort': True
            }
        }
        policy_id = utils.create_a_policy(self, spec)
        scaleout_policy = utils.get_a_policy(self, policy_id)
        self.addCleanup(utils.delete_a_policy, self, scaleout_policy['id'])

        # Create a scaling policy targets on CLUSTER_SCALE_IN action
        spec['properties'] = {
            'event': 'CLUSTER_SCALE_IN',
            'adjustment': {
                'type': 'CHANGE_IN_PERCENTAGE',
                'number': 50,
                'min_step': 2,
                'best_effort': False
            }
        }
        policy_id = utils.create_a_policy(self, spec)
        scalein_policy = utils.get_a_policy(self, policy_id)
        self.addCleanup(utils.delete_a_policy, self, scalein_policy['id'])

        # Attach scale in/out policies to cluster
        for policy in [scaleout_policy, scalein_policy]:
            utils.cluster_attach_policy(self, self.cluster_id, policy['id'])
            self.addCleanup(utils.cluster_detach_policy, self,
                            self.cluster_id, policy['id'])

        # Scale out cluster without count specified
        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']))

        # Scale out cluster with count set to 1
        utils.cluster_scale_out(self, self.cluster_id, count=1)

        # Verify scale out result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual('ACTIVE', cluster['status'])
        self.assertEqual(4, cluster['desired_capacity'])
        self.assertEqual(4, len(cluster['nodes']))

        # Keep scaling out cluster with count set to 2 to
        # verify best_effort parameter
        utils.cluster_scale_out(self, self.cluster_id, count=2)

        # Verify scale out result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual('ACTIVE', cluster['status'])
        self.assertEqual(5, cluster['desired_capacity'])
        self.assertEqual(5, len(cluster['nodes']))

        # Scale in cluster without count specified
        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(3, cluster['desired_capacity'])
        self.assertEqual(3, len(cluster['nodes']))

        # Scale in cluster without count specified to
        # verify min_step parameter
        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(1, cluster['desired_capacity'])
        self.assertEqual(1, len(cluster['nodes']))

        # Keep scaling in cluster with count set to 2 to
        # verify best_effort parameter
        res = utils.cluster_scale_in(self, self.cluster_id, count=2,
                                     expected_status='FAILED')

        # Verify action result and action failure reason
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual('ACTIVE', cluster['status'])
        self.assertEqual(1, cluster['desired_capacity'])
        self.assertEqual(1, len(cluster['nodes']))
        reason = _("Policy check failure: The target capacity (-1) is less "
                   "than the cluster's min_size (0).")
        self.assertEqual(reason, res)