diff options
| author | lihaijing <lihaijing@fiberhome.com> | 2017-09-18 17:04:48 +0800 |
|---|---|---|
| committer | Steve Martinelli <s.martinelli@gmail.com> | 2017-09-18 12:30:12 +0000 |
| commit | edebe558ee817a5378f808115e8b5d5409303f23 (patch) | |
| tree | f30f0cc4cb1ff9f4c41bca513dc76a776f63a641 /openstackclient/tests/functional/volume/v2 | |
| parent | 21542d1e6ec08250a2b6f7ae5bfda5080f00931a (diff) | |
| download | python-openstackclient-edebe558ee817a5378f808115e8b5d5409303f23.tar.gz | |
Add functional test cases for "volume qos associate/disassociate"
Change-Id: I07b25bebb8a0ea18cdf042357be65c4ec6e1cfed
Closes-Bug: #1717874
Diffstat (limited to 'openstackclient/tests/functional/volume/v2')
| -rw-r--r-- | openstackclient/tests/functional/volume/v2/test_qos.py | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/openstackclient/tests/functional/volume/v2/test_qos.py b/openstackclient/tests/functional/volume/v2/test_qos.py index aee10dca..888f12b1 100644 --- a/openstackclient/tests/functional/volume/v2/test_qos.py +++ b/openstackclient/tests/functional/volume/v2/test_qos.py @@ -122,4 +122,96 @@ class QosTests(common.BaseVolumeTests): cmd_output['properties'] ) - # TODO(qiangjiahui): Add tests for associate and disassociate volume type + def test_volume_qos_asso_disasso(self): + """Tests associate and disassociate qos with volume type""" + vol_type1 = uuid.uuid4().hex + vol_type2 = uuid.uuid4().hex + cmd_output = json.loads(self.openstack( + 'volume type create -f json ' + + vol_type1 + )) + self.assertEqual( + vol_type1, + cmd_output['name'] + ) + cmd_output = json.loads(self.openstack( + 'volume type create -f json ' + + vol_type2 + )) + self.assertEqual( + vol_type2, + cmd_output['name'] + ) + self.addCleanup(self.openstack, 'volume type delete ' + vol_type1) + self.addCleanup(self.openstack, 'volume type delete ' + vol_type2) + + name = uuid.uuid4().hex + cmd_output = json.loads(self.openstack( + 'volume qos create -f json ' + + name + )) + self.assertEqual( + name, + cmd_output['name'] + ) + self.addCleanup(self.openstack, 'volume qos delete ' + name) + + # Test associate + raw_output = self.openstack( + 'volume qos associate ' + + name + ' ' + vol_type1 + ) + self.assertOutput('', raw_output) + raw_output = self.openstack( + 'volume qos associate ' + + name + ' ' + vol_type2 + ) + self.assertOutput('', raw_output) + + cmd_output = json.loads(self.openstack( + 'volume qos show -f json ' + + name + )) + types = cmd_output["associations"] + self.assertIn(vol_type1, types) + self.assertIn(vol_type2, types) + + # Test disassociate + raw_output = self.openstack( + 'volume qos disassociate ' + + '--volume-type ' + vol_type1 + + ' ' + name + ) + self.assertOutput('', raw_output) + cmd_output = json.loads(self.openstack( + 'volume qos show -f json ' + + name + )) + types = cmd_output["associations"] + self.assertNotIn(vol_type1, types) + self.assertIn(vol_type2, types) + + # Test disassociate --all + raw_output = self.openstack( + 'volume qos associate ' + + name + ' ' + vol_type1 + ) + self.assertOutput('', raw_output) + cmd_output = json.loads(self.openstack( + 'volume qos show -f json ' + + name + )) + types = cmd_output["associations"] + self.assertIn(vol_type1, types) + self.assertIn(vol_type2, types) + + raw_output = self.openstack( + 'volume qos disassociate ' + + '--all ' + name + ) + self.assertOutput('', raw_output) + cmd_output = json.loads(self.openstack( + 'volume qos show -f json ' + + name + )) + self.assertNotIn("associations", cmd_output.keys()) |
