summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional
diff options
context:
space:
mode:
authorjay <jayadityagupta11@gmail.com>2020-06-04 14:09:03 +0200
committerjgupta <jayadityagupta11@gmail.com>2020-09-14 15:22:27 +0200
commitbae89b30144fdf40d0fea31e1a595b507e32c4f3 (patch)
treeef1d3ecf7453e3b98aefc90a426ef6b8d83e9397 /openstackclient/tests/functional
parent533af9f1b2de40d98f69e83cdf89ecf254cf3879 (diff)
downloadpython-openstackclient-bae89b30144fdf40d0fea31e1a595b507e32c4f3.tar.gz
Output correct json for security groups in 'openstack server show'
Fixes incorrect json output for 'openstack server show -f json'. The security group json output groups all the json as one for e.g. "security_groups": "name='group1'\nname='group2'" The correct output should be "security_groups" : [{"name" : "group1"}, {"name" : "group2"}] properties and volumes_attached fields also has similar issue. Story: 2007755 Change-Id: I1b1cac716329e0530400aff782c08000b21d8e1d
Diffstat (limited to 'openstackclient/tests/functional')
-rw-r--r--openstackclient/tests/functional/compute/v2/test_server.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py
index 6e080e9b..50c59c17 100644
--- a/openstackclient/tests/functional/compute/v2/test_server.py
+++ b/openstackclient/tests/functional/compute/v2/test_server.py
@@ -230,7 +230,7 @@ class ServerTests(common.ComputeTestCase):
))
# Really, shouldn't this be a list?
self.assertEqual(
- "a='b', c='d'",
+ {'a': 'b', 'c': 'd'},
cmd_output['properties'],
)
@@ -244,7 +244,7 @@ class ServerTests(common.ComputeTestCase):
name
))
self.assertEqual(
- "c='d'",
+ {'c': 'd'},
cmd_output['properties'],
)
@@ -619,8 +619,8 @@ class ServerTests(common.ComputeTestCase):
server_name
))
volumes_attached = cmd_output['volumes_attached']
- self.assertTrue(volumes_attached.startswith('id='))
- attached_volume_id = volumes_attached.replace('id=', '')
+ self.assertIsNotNone(volumes_attached)
+ attached_volume_id = volumes_attached[0]["id"]
# check the volume that attached on server
cmd_output = json.loads(self.openstack(
@@ -699,8 +699,8 @@ class ServerTests(common.ComputeTestCase):
server_name
))
volumes_attached = cmd_output['volumes_attached']
- self.assertTrue(volumes_attached.startswith('id='))
- attached_volume_id = volumes_attached.replace('id=', '')
+ self.assertIsNotNone(volumes_attached)
+ attached_volume_id = volumes_attached[0]["id"]
# check the volume that attached on server
cmd_output = json.loads(self.openstack(
@@ -773,10 +773,12 @@ class ServerTests(common.ComputeTestCase):
server_name
))
volumes_attached = cmd_output['volumes_attached']
- self.assertTrue(volumes_attached.startswith('id='))
- attached_volume_id = volumes_attached.replace('id=', '')
- # Don't leak the volume when the test exits.
- self.addCleanup(self.openstack, 'volume delete ' + attached_volume_id)
+ self.assertIsNotNone(volumes_attached)
+ attached_volume_id = volumes_attached[0]["id"]
+ for vol in volumes_attached:
+ self.assertIsNotNone(vol['id'])
+ # Don't leak the volume when the test exits.
+ self.addCleanup(self.openstack, 'volume delete ' + vol['id'])
# Since the server is volume-backed the GET /servers/{server_id}
# response will have image=''.
@@ -785,7 +787,7 @@ class ServerTests(common.ComputeTestCase):
# check the volume that attached on server
cmd_output = json.loads(self.openstack(
'volume show -f json ' +
- attached_volume_id
+ volumes_attached[0]["id"]
))
# The volume size should be what we specified on the command line.
self.assertEqual(1, int(cmd_output['size']))
@@ -879,14 +881,21 @@ class ServerTests(common.ComputeTestCase):
self.assertIsNotNone(server['id'])
self.assertEqual(server_name, server['name'])
- self.assertIn(str(security_group1['id']), server['security_groups'])
- self.assertIn(str(security_group2['id']), server['security_groups'])
+ sec_grp = ""
+ for sec in server['security_groups']:
+ sec_grp += sec['name']
+ self.assertIn(str(security_group1['id']), sec_grp)
+ self.assertIn(str(security_group2['id']), sec_grp)
self.wait_for_status(server_name, 'ACTIVE')
server = json.loads(self.openstack(
'server show -f json ' + server_name
))
- self.assertIn(sg_name1, server['security_groups'])
- self.assertIn(sg_name2, server['security_groups'])
+ # check if security group exists in list
+ sec_grp = ""
+ for sec in server['security_groups']:
+ sec_grp += sec['name']
+ self.assertIn(sg_name1, sec_grp)
+ self.assertIn(sg_name2, sec_grp)
def test_server_create_with_empty_network_option_latest(self):
"""Test server create with empty network option in nova 2.latest."""