def setUp(self): super(TestReceiverShowNegativeBadRequest, 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.receiver_id2 = utils.create_a_receiver(self, cluster_id, 'CLUSTER_RESIZE', name='r-01') self.addCleanup(self.client.delete_obj, 'receivers', self.receiver_id1) self.addCleanup(self.client.delete_obj, 'receivers', self.receiver_id2)
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 with timeutils.StopWatch(timeout) as timeout_watch: 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 = timeout_watch.leftover(True) if timeout <= 0: raise Exception('Failed in triggering cluster action.')
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, cluster_id, 'CLUSTER_RESIZE')
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)
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']
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']))