Functional test for volume qos
Refactor functional tests for testing more command options. Change-Id: I6d5a82eb0e84f72e8da76b17c952e4daae9dbc08
This commit is contained in:
parent
e8eb0914ea
commit
9fd145edbf
@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional.volume.v1 import common
|
from openstackclient.tests.functional.volume.v1 import common
|
||||||
@ -18,38 +19,103 @@ from openstackclient.tests.functional.volume.v1 import common
|
|||||||
class QosTests(common.BaseVolumeTests):
|
class QosTests(common.BaseVolumeTests):
|
||||||
"""Functional tests for volume qos. """
|
"""Functional tests for volume qos. """
|
||||||
|
|
||||||
NAME = uuid.uuid4().hex
|
def test_volume_qos_create_list(self):
|
||||||
HEADERS = ['Name']
|
"""Test create, list, delete multiple"""
|
||||||
FIELDS = ['id', 'name']
|
name1 = uuid.uuid4().hex
|
||||||
ID = None
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos create -f json ' +
|
||||||
|
name1
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
name1,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
name2 = uuid.uuid4().hex
|
||||||
def setUpClass(cls):
|
cmd_output = json.loads(self.openstack(
|
||||||
super(QosTests, cls).setUpClass()
|
'volume qos create -f json ' +
|
||||||
opts = cls.get_opts(cls.FIELDS)
|
name2
|
||||||
raw_output = cls.openstack('volume qos create ' + cls.NAME + opts)
|
))
|
||||||
cls.ID, name, rol = raw_output.split('\n')
|
self.assertEqual(
|
||||||
cls.assertOutput(cls.NAME, name)
|
name2,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
# Test list
|
||||||
def tearDownClass(cls):
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = cls.openstack('volume qos delete ' + cls.ID)
|
'volume qos list -f json'
|
||||||
cls.assertOutput('', raw_output)
|
))
|
||||||
|
names = [x["Name"] for x in cmd_output]
|
||||||
|
self.assertIn(name1, names)
|
||||||
|
self.assertIn(name2, names)
|
||||||
|
|
||||||
def test_volume_qos_list(self):
|
# Test delete multiple
|
||||||
opts = self.get_opts(self.HEADERS)
|
del_output = self.openstack('volume qos delete ' + name1 + ' ' + name2)
|
||||||
raw_output = self.openstack('volume qos list' + opts)
|
self.assertOutput('', del_output)
|
||||||
self.assertIn(self.NAME, raw_output)
|
|
||||||
|
|
||||||
def test_volume_qos_show(self):
|
def test_volume_qos_set_show_unset(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
"""Tests create volume qos, set, unset, show, delete"""
|
||||||
raw_output = self.openstack('volume qos show ' + self.ID + opts)
|
|
||||||
self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output)
|
|
||||||
|
|
||||||
def test_volume_qos_metadata(self):
|
name = uuid.uuid4().hex
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos create -f json ' +
|
||||||
|
'--consumer front-end '
|
||||||
|
'--property Alpha=a ' +
|
||||||
|
name
|
||||||
|
))
|
||||||
|
self.addCleanup(self.openstack, 'volume qos delete ' + name)
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
"front-end",
|
||||||
|
cmd_output['consumer']
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test volume qos set
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume qos set --property a=b --property c=d ' + self.ID)
|
'volume qos set ' +
|
||||||
self.assertEqual("", raw_output)
|
'--property Alpha=c ' +
|
||||||
opts = self.get_opts(['name', 'specs'])
|
'--property Beta=b ' +
|
||||||
raw_output = self.openstack('volume qos show ' + self.ID + opts)
|
name,
|
||||||
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
|
)
|
||||||
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
# Test volume qos show
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos show -f json ' +
|
||||||
|
name
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"Alpha='c', Beta='b'",
|
||||||
|
cmd_output['specs']
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test volume qos unset
|
||||||
|
raw_output = self.openstack(
|
||||||
|
'volume qos unset ' +
|
||||||
|
'--property Alpha ' +
|
||||||
|
name,
|
||||||
|
)
|
||||||
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos show -f json ' +
|
||||||
|
name
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"Beta='b'",
|
||||||
|
cmd_output['specs']
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO(qiangjiahui): Add tests for associate and disassociate volume type
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional.volume.v2 import common
|
from openstackclient.tests.functional.volume.v2 import common
|
||||||
@ -18,45 +19,107 @@ from openstackclient.tests.functional.volume.v2 import common
|
|||||||
class QosTests(common.BaseVolumeTests):
|
class QosTests(common.BaseVolumeTests):
|
||||||
"""Functional tests for volume qos. """
|
"""Functional tests for volume qos. """
|
||||||
|
|
||||||
NAME = uuid.uuid4().hex
|
def test_volume_qos_create_delete_list(self):
|
||||||
HEADERS = ['Name']
|
"""Test create, list, delete multiple"""
|
||||||
FIELDS = ['id', 'name']
|
name1 = uuid.uuid4().hex
|
||||||
ID = None
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos create -f json ' +
|
||||||
|
name1
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
name1,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
name2 = uuid.uuid4().hex
|
||||||
def setUpClass(cls):
|
cmd_output = json.loads(self.openstack(
|
||||||
super(QosTests, cls).setUpClass()
|
'volume qos create -f json ' +
|
||||||
opts = cls.get_opts(cls.FIELDS)
|
name2
|
||||||
raw_output = cls.openstack('volume qos create ' + cls.NAME + opts)
|
))
|
||||||
cls.ID, name, rol = raw_output.split('\n')
|
self.assertEqual(
|
||||||
cls.assertOutput(cls.NAME, name)
|
name2,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
# Test list
|
||||||
def tearDownClass(cls):
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = cls.openstack('volume qos delete ' + cls.ID)
|
'volume qos list -f json'
|
||||||
cls.assertOutput('', raw_output)
|
))
|
||||||
|
names = [x["Name"] for x in cmd_output]
|
||||||
|
self.assertIn(name1, names)
|
||||||
|
self.assertIn(name2, names)
|
||||||
|
|
||||||
def test_volume_qos_list(self):
|
# Test delete multiple
|
||||||
opts = self.get_opts(self.HEADERS)
|
del_output = self.openstack('volume qos delete ' + name1 + ' ' + name2)
|
||||||
raw_output = self.openstack('volume qos list' + opts)
|
self.assertOutput('', del_output)
|
||||||
self.assertIn(self.NAME, raw_output)
|
|
||||||
|
|
||||||
def test_volume_qos_show(self):
|
def test_volume_qos_set_show_unset(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
"""Tests create volume qos, set, unset, show, delete"""
|
||||||
raw_output = self.openstack('volume qos show ' + self.ID + opts)
|
|
||||||
self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output)
|
|
||||||
|
|
||||||
def test_volume_qos_metadata(self):
|
name = uuid.uuid4().hex
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos create -f json ' +
|
||||||
|
'--consumer front-end '
|
||||||
|
'--property Alpha=a ' +
|
||||||
|
name
|
||||||
|
))
|
||||||
|
self.addCleanup(self.openstack, 'volume qos delete ' + name)
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
"front-end",
|
||||||
|
cmd_output['consumer']
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"Alpha='a'",
|
||||||
|
cmd_output['properties']
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test volume qos set
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume qos set --property a=b --property c=d ' + self.ID)
|
'volume qos set ' +
|
||||||
self.assertEqual("", raw_output)
|
'--property Alpha=c ' +
|
||||||
opts = self.get_opts(['name', 'properties'])
|
'--property Beta=b ' +
|
||||||
raw_output = self.openstack('volume qos show ' + self.ID + opts)
|
name,
|
||||||
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
|
)
|
||||||
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
# Test volume qos show
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos show -f json ' +
|
||||||
|
name
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"Alpha='c', Beta='b'",
|
||||||
|
cmd_output['properties']
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test volume qos unset
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume qos unset --property a ' + self.ID)
|
'volume qos unset ' +
|
||||||
self.assertEqual("", raw_output)
|
'--property Alpha ' +
|
||||||
opts = self.get_opts(['name', 'properties'])
|
name,
|
||||||
raw_output = self.openstack('volume qos show ' + self.ID + opts)
|
)
|
||||||
self.assertEqual(self.NAME + "\nc='d'\n", raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'volume qos show -f json ' +
|
||||||
|
name
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
cmd_output['name']
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"Beta='b'",
|
||||||
|
cmd_output['properties']
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO(qiangjiahui): Add tests for associate and disassociate volume type
|
||||||
|
Loading…
Reference in New Issue
Block a user