diff --git a/doc/api_samples/os-server-tags/v2.26/server-tags-index-resp.json b/doc/api_samples/os-server-tags/v2.26/server-tags-index-resp.json index dee5cd391fd8..d3bfe89eb534 100644 --- a/doc/api_samples/os-server-tags/v2.26/server-tags-index-resp.json +++ b/doc/api_samples/os-server-tags/v2.26/server-tags-index-resp.json @@ -1,3 +1,3 @@ { - "tags": ["sometag"] + "tags": ["tag1", "tag2"] } diff --git a/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json b/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json index 54757dd00858..d3bfe89eb534 100644 --- a/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json +++ b/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json @@ -1,5 +1,3 @@ { - "tags": [ - "sometag" - ] + "tags": ["tag1", "tag2"] } diff --git a/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-resp.json b/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-resp.json new file mode 100644 index 000000000000..d3bfe89eb534 --- /dev/null +++ b/doc/api_samples/os-server-tags/v2.26/server-tags-put-all-resp.json @@ -0,0 +1,3 @@ +{ + "tags": ["tag1", "tag2"] +} diff --git a/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json b/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json index 2e6e3680f563..6eb5c8956009 100644 --- a/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json +++ b/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json @@ -1,8 +1,6 @@ { "server": { - "tags": [ - "sometag" - ], + "tags": ["tag1", "tag2"], "accessIPv4": "1.2.3.4", "accessIPv6": "80fe::", "addresses": { diff --git a/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json b/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json index dc22eeb13fcb..4ac9958d3fd5 100644 --- a/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json +++ b/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json @@ -55,7 +55,7 @@ "updated": "2013-09-03T04:01:32Z", "user_id": "fake", "locked": false, - "tags": ["sometag"], + "tags": ["tag1", "tag2"], "description": null, "config_drive": "", "OS-DCF:diskConfig": "AUTO", diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-index-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-index-resp.json.tpl index 1cfb48373346..65320d266a7b 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-index-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-index-resp.json.tpl @@ -1,3 +1,3 @@ { - "tags": ["%(tag)s"] + "tags": ["%(tag1)s", "%(tag2)s"] } diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json.tpl index e80aff6d8643..65320d266a7b 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-req.json.tpl @@ -1,5 +1,3 @@ { - "tags": [ - "%(tag)s" - ] + "tags": ["%(tag1)s", "%(tag2)s"] } diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-resp.json.tpl new file mode 100644 index 000000000000..65320d266a7b --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-put-all-resp.json.tpl @@ -0,0 +1,3 @@ +{ + "tags": ["%(tag1)s", "%(tag2)s"] +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl index 7b375238a914..c064bf6717e7 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl @@ -1,8 +1,6 @@ { "server": { - "tags": [ - "%(tag)s" - ], + "tags": ["%(tag1)s", "%(tag2)s"], "accessIPv4": "%(access_ip_v4)s", "accessIPv6": "%(access_ip_v6)s", "addresses": { diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl index 127baf215d5f..592ddb85841b 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl @@ -55,7 +55,7 @@ "updated": "%(isotime)s", "user_id": "fake", "locked": false, - "tags": ["%(tag)s"], + "tags": ["%(tag1)s", "%(tag2)s"], "description": null, "config_drive": "", "OS-DCF:diskConfig": "AUTO", diff --git a/nova/tests/functional/api_sample_tests/test_server_tags.py b/nova/tests/functional/api_sample_tests/test_server_tags.py index 28b9aa8498f5..bf0884a4be7f 100644 --- a/nova/tests/functional/api_sample_tests/test_server_tags.py +++ b/nova/tests/functional/api_sample_tests/test_server_tags.py @@ -13,7 +13,8 @@ from nova.db.sqlalchemy import models from nova.tests.functional.api_sample_tests import test_servers -TAG = 'sometag' +TAG1 = 'tag1' +TAG2 = 'tag2' class ServerTagsJsonTest(test_servers.ServersSampleBase): @@ -22,7 +23,22 @@ class ServerTagsJsonTest(test_servers.ServersSampleBase): scenarios = [('v2_26', {'api_major_version': 'v2.1'})] def _get_create_subs(self): - return {'tag': TAG} + return {'tag1': TAG1, + 'tag2': TAG2} + + def _get_show_subs(self): + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + subs['tag1'] = '[0-9a-zA-Z]+' + subs['tag2'] = '[0-9a-zA-Z]+' + subs['access_ip_v4'] = '1.2.3.4' + subs['access_ip_v6'] = '80fe::' + subs['hostname'] = r'[\w\.\-]+' + subs['instance_name'] = 'instance-\d{8}' + subs['hypervisor_hostname'] = r'[\w\.\-]+' + subs['cdrive'] = '.*' + subs['user_data'] = self.user_data + return subs def _put_server_tags(self): """Verify the response status and returns the UUID of the @@ -32,7 +48,7 @@ class ServerTagsJsonTest(test_servers.ServersSampleBase): subs = self._get_create_subs() response = self._do_put('servers/%s/tags' % uuid, 'server-tags-put-all-req', subs) - self.assertEqual(200, response.status_code) + self._verify_response('server-tags-put-all-resp', subs, response, 200) return uuid def test_server_tags_update_all(self): @@ -40,45 +56,28 @@ class ServerTagsJsonTest(test_servers.ServersSampleBase): def test_server_tags_show(self): uuid = self._put_server_tags() - response = self._do_get('servers/%s/tags/%s' % (uuid, TAG)) + response = self._do_get('servers/%s/tags/%s' % (uuid, TAG1)) self.assertEqual(204, response.status_code) def test_server_tags_show_with_details_information(self): uuid = self._put_server_tags() response = self._do_get('servers/%s' % uuid) - subs = self._get_regexes() - subs['hostid'] = '[a-f0-9]+' - subs['tag'] = '[0-9a-zA-Z]+' - subs['access_ip_v4'] = '1.2.3.4' - subs['access_ip_v6'] = '80fe::' - subs['hostname'] = r'[\w\.\-]+' - subs['instance_name'] = 'instance-\d{8}' - subs['hypervisor_hostname'] = r'[\w\.\-]+' - subs['cdrive'] = '.*' - subs['user_data'] = self.user_data + subs = self._get_show_subs() self._verify_response('server-tags-show-details-resp', subs, response, 200) def test_server_tags_list_with_details_information(self): self._put_server_tags() + subs = self._get_show_subs() response = self._do_get('servers/detail') - subs = self._get_regexes() - subs['hostid'] = '[a-f0-9]+' - subs['tag'] = '[0-9a-zA-Z]+' - subs['access_ip_v4'] = '1.2.3.4' - subs['access_ip_v6'] = '80fe::' - subs['hostname'] = r'[\w\.\-]+' - subs['instance_name'] = 'instance-\d{8}' - subs['hypervisor_hostname'] = r'[\w\.\-]+' - subs['cdrive'] = '.*' - subs['user_data'] = self.user_data self._verify_response('servers-tags-details-resp', subs, response, 200) def test_server_tags_index(self): uuid = self._put_server_tags() response = self._do_get('servers/%s/tags' % uuid) subs = self._get_regexes() - subs['tag'] = '[0-9a-zA-Z]+' + subs['tag1'] = '[0-9a-zA-Z]+' + subs['tag2'] = '[0-9a-zA-Z]+' self._verify_response('server-tags-index-resp', subs, response, 200) def test_server_tags_update(self): @@ -94,7 +93,7 @@ class ServerTagsJsonTest(test_servers.ServersSampleBase): def test_server_tags_delete(self): uuid = self._put_server_tags() - response = self._do_delete('servers/%s/tags/%s' % (uuid, TAG)) + response = self._do_delete('servers/%s/tags/%s' % (uuid, TAG1)) self.assertEqual(204, response.status_code) self.assertEqual('', response.content)