blob: c8640b3f1daf13c09794a0ad0cc321255ee14e34 [file] [log] [blame]
Malini Kamalambal7458b4b2014-05-29 11:47:28 -04001# Copyright (c) 2014 Rackspace, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import logging
17
Matthew Treinish01472ff2015-02-20 17:26:52 -050018from tempest_lib.common.utils import data_utils
19
Victoria Martínez de la Cruz1173b6e2014-09-22 18:32:13 -030020from tempest.api.messaging import base
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040021from tempest import config
22from tempest import test
23
24
25LOG = logging.getLogger(__name__)
26CONF = config.CONF
27
28
Victoria Martínez de la Cruz1173b6e2014-09-22 18:32:13 -030029class TestMessages(base.BaseMessagingTest):
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040030
31 @classmethod
Andrea Frittoli23ee1c62014-09-15 13:14:54 +010032 def resource_setup(cls):
33 super(TestMessages, cls).resource_setup()
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040034 cls.queue_name = data_utils.rand_name('Queues-Test')
35 # Create Queue
36 cls.client.create_queue(cls.queue_name)
37
Victoria Martínez de la Cruz1173b6e2014-09-22 18:32:13 -030038 def _post_messages(self, repeat=CONF.messaging.max_messages_per_page):
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040039 message_body = self.generate_message_body(repeat=repeat)
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +010040 resp, body = self.post_messages(queue_name=self.queue_name,
41 rbody=message_body)
42 return resp, body
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040043
44 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080045 @test.idempotent_id('93867172-a414-4eb3-a639-96e943c516b4')
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040046 def test_post_messages(self):
47 # Post Messages
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +010048 resp, _ = self._post_messages()
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040049
50 # Get on the posted messages
51 message_uri = resp['location']
Ken'ichi Ohmichi7e3ccd52015-04-06 23:55:46 +000052 resp, _ = self.client.show_multiple_messages(message_uri)
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040053 # The test has an assertion here, because the response cannot be 204
54 # in this case (the client allows 200 or 204 for this API call).
55 self.assertEqual('200', resp['status'])
56
57 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080058 @test.idempotent_id('c967d59a-e919-41cb-994b-1c4300452c80')
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040059 def test_list_messages(self):
60 # Post Messages
61 self._post_messages()
62
63 # List Messages
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +010064 resp, _ = self.list_messages(queue_name=self.queue_name)
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040065 # The test has an assertion here, because the response cannot be 204
66 # in this case (the client allows 200 or 204 for this API call).
67 self.assertEqual('200', resp['status'])
68
69 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080070 @test.idempotent_id('2a68e3de-24df-47c3-9039-ec4156656bf8')
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040071 def test_get_message(self):
72 # Post Messages
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +010073 _, body = self._post_messages()
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040074 message_uri = body['resources'][0]
75
76 # Get posted message
Ken'ichi Ohmichi7e3ccd52015-04-06 23:55:46 +000077 resp, _ = self.client.show_single_message(message_uri)
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040078 # The test has an assertion here, because the response cannot be 204
79 # in this case (the client allows 200 or 204 for this API call).
80 self.assertEqual('200', resp['status'])
81
82 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080083 @test.idempotent_id('c4b0a30b-efda-4b87-a395-0c43140df74d')
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040084 def test_get_multiple_messages(self):
85 # Post Messages
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +010086 resp, _ = self._post_messages()
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040087 message_uri = resp['location']
88
89 # Get posted messages
Ken'ichi Ohmichi7e3ccd52015-04-06 23:55:46 +000090 resp, _ = self.client.show_multiple_messages(message_uri)
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040091 # The test has an assertion here, because the response cannot be 204
92 # in this case (the client allows 200 or 204 for this API call).
93 self.assertEqual('200', resp['status'])
94
95 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080096 @test.idempotent_id('fc0fca47-dd8b-4ecc-8522-d9c191f9bc9f')
Malini Kamalambal7458b4b2014-05-29 11:47:28 -040097 def test_delete_single_message(self):
98 # Post Messages
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +010099 _, body = self._post_messages()
Malini Kamalambal7458b4b2014-05-29 11:47:28 -0400100 message_uri = body['resources'][0]
101
102 # Delete posted message & verify the delete operration
103 self.client.delete_messages(message_uri)
104
105 message_uri = message_uri.replace('/messages/', '/messages?ids=')
Ken'ichi Ohmichi7e3ccd52015-04-06 23:55:46 +0000106 resp, _ = self.client.show_multiple_messages(message_uri)
Malini Kamalambal7458b4b2014-05-29 11:47:28 -0400107 # The test has an assertion here, because the response has to be 204
108 # in this case (the client allows 200 or 204 for this API call).
109 self.assertEqual('204', resp['status'])
110
111 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800112 @test.idempotent_id('00cca069-5c8f-4b42-bff1-c577da2a4546')
Malini Kamalambal7458b4b2014-05-29 11:47:28 -0400113 def test_delete_multiple_messages(self):
114 # Post Messages
Flavio Percoco5ee9f2f2015-02-25 08:36:09 +0100115 resp, _ = self._post_messages()
Malini Kamalambal7458b4b2014-05-29 11:47:28 -0400116 message_uri = resp['location']
117
118 # Delete multiple messages
119 self.client.delete_messages(message_uri)
Ken'ichi Ohmichi7e3ccd52015-04-06 23:55:46 +0000120 resp, _ = self.client.show_multiple_messages(message_uri)
Malini Kamalambal7458b4b2014-05-29 11:47:28 -0400121 # The test has an assertion here, because the response has to be 204
122 # in this case (the client allows 200 or 204 for this API call).
123 self.assertEqual('204', resp['status'])
124
125 @classmethod
Andrea Frittoli23ee1c62014-09-15 13:14:54 +0100126 def resource_cleanup(cls):
Malini Kamalambal7458b4b2014-05-29 11:47:28 -0400127 cls.delete_queue(cls.queue_name)
Andrea Frittoli23ee1c62014-09-15 13:14:54 +0100128 super(TestMessages, cls).resource_cleanup()