def setUp(self):
        super(TestReceiverDeleteNegativeBadRequest, 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.receiver_id1 = utils.create_a_receiver(self, cluster_id,
                                                    'CLUSTER_RESIZE',
                                                    name='r-01')
        self.addCleanup(utils.delete_a_receiver, self, self.receiver_id1)
        self.receiver_id2 = utils.create_a_receiver(self, cluster_id,
                                                    'CLUSTER_RESIZE',
                                                    name='r-01')
        self.addCleanup(utils.delete_a_receiver, self, self.receiver_id2)
Ejemplo n.º 2
0
    def test_message_receiver(self):
        # Create a message type of receiver
        receiver_id = utils.create_a_receiver(self, None, None,
                                              r_type='message')
        self.addCleanup(utils.delete_a_receiver, self, receiver_id)
        receiver = utils.get_a_receiver(self, receiver_id)
        queue_name = receiver['channel']['queue_name']
        self.assertTrue(queue_name.startswith('senlin-receiver-'))

        # Trigger cluster_scale_out action
        message1 = {
            'body': {
                'cluster': self.cluster_id,
                'action': 'CLUSTER_SCALE_OUT'
            },
            'ttl': 3600
        }
        utils.post_messages(self, queue_name, [message1])

        # Wait and verify result
        timeout = 120
        while timeout > 0:
            time.sleep(5)
            cluster = utils.get_a_cluster(self, self.cluster_id)
            if len(cluster['nodes']) == 2 and cluster['status'] == 'ACTIVE':
                break
            timeout -= 5
        if timeout <= 0:
            raise Exception('Failed in triggering cluster action.')
Ejemplo n.º 3
0
    def setUp(self):
        super(TestReceiverDeleteNegativeBadRequest, 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.receiver_id1 = utils.create_a_receiver(self,
                                                    cluster_id,
                                                    'CLUSTER_RESIZE',
                                                    name='r-01')
        self.addCleanup(utils.delete_a_receiver, self, self.receiver_id1)
        self.receiver_id2 = utils.create_a_receiver(self,
                                                    cluster_id,
                                                    'CLUSTER_RESIZE',
                                                    name='r-01')
        self.addCleanup(utils.delete_a_receiver, self, self.receiver_id2)
Ejemplo n.º 4
0
    def setUp(self):
        super(TestReceiverDelete, 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.receiver_id = utils.create_a_receiver(self.client, cluster_id,
                                                   'CLUSTER_RESIZE')
Ejemplo n.º 5
0
    def setUp(self):
        super(TestReceiverDelete, 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.receiver_id = utils.create_a_receiver(self.client, cluster_id,
                                                   'CLUSTER_RESIZE')
Ejemplo n.º 6
0
    def setUp(self):
        super(TestClusterDeleteNegativeReceiverConflict, 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.receiver_id = utils.create_a_receiver(self,
                                                   self.cluster_id,
                                                   'CLUSTER_SCALE_OUT',
                                                   'webhook',
                                                   'fake',
                                                   params={'count': '1'})
        self.addCleanup(utils.delete_a_receiver, self, self.receiver_id)
Ejemplo n.º 7
0
    def setUp(self):
        super(TestWebhookTrigger, 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)

        params = {'max_size': 2}
        self.receiver_id = utils.create_a_receiver(self, cluster_id,
                                                   'CLUSTER_RESIZE',
                                                   params=params)
        self.addCleanup(self.client.delete_obj, 'receivers', self.receiver_id)

        receiver = self.client.get_obj('receivers', self.receiver_id)
        self.webhook_url = receiver['body']['channel']['alarm_url']
Ejemplo n.º 8
0
    def setUp(self):
        super(TestWebhookTrigger, 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)

        params = {'max_size': 2}
        self.receiver_id = utils.create_a_receiver(self.client,
                                                   cluster_id,
                                                   'CLUSTER_RESIZE',
                                                   params=params)
        self.addCleanup(self.client.delete_obj, 'receivers', self.receiver_id)

        receiver = self.client.get_obj('receivers', self.receiver_id)
        self.webhook_url = receiver['body']['channel']['alarm_url']
Ejemplo n.º 9
0
    def test_webhook(self):
        # Create a webhook type of receiver
        receiver_id = utils.create_a_receiver(self, self.cluster_id,
                                              'CLUSTER_SCALE_OUT',
                                              r_type='webhook',
                                              params={'count': 2})
        self.addCleanup(utils.delete_a_receiver, self, receiver_id)
        receiver = utils.get_a_receiver(self, receiver_id)
        webhook_url = receiver['channel']['alarm_url']

        # Trigger webhook and wait for action execution
        res = self.client.trigger_webhook(webhook_url)
        action_id = res['location'].split('/actions/')[1]
        self.client.wait_for_status('actions', action_id, 'SUCCEEDED')

        # Verify action result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(2, cluster['desired_capacity'])
        self.assertEqual(2, len(cluster['nodes']))
Ejemplo n.º 10
0
    def test_webhook(self):
        # Create a webhook type of receiver
        receiver_id = utils.create_a_receiver(self,
                                              self.cluster_id,
                                              'CLUSTER_SCALE_OUT',
                                              r_type='webhook',
                                              params={'count': 2})
        self.addCleanup(utils.delete_a_receiver, self, receiver_id)
        receiver = utils.get_a_receiver(self, receiver_id)
        webhook_url = receiver['channel']['alarm_url']

        # Trigger webhook and wait for action execution
        res = self.client.trigger_webhook(webhook_url)
        action_id = res['location'].split('/actions/')[1]
        self.client.wait_for_status('actions', action_id, 'SUCCEEDED')

        # Verify action result
        cluster = utils.get_a_cluster(self, self.cluster_id)
        self.assertEqual(2, cluster['desired_capacity'])
        self.assertEqual(2, len(cluster['nodes']))