Convert volume functional tests into JSON format
volume_type and transfer_request func tests have not been converted into JSON func tests. This commit converts them into JSON format. Change-Id: I56820c4e15bda95e911e57657c1ff5437daf83ae
This commit is contained in:
parent
0181de38af
commit
62c793c7e4
@ -21,23 +21,19 @@ class TransferRequestTests(common.BaseVolumeTests):
|
|||||||
|
|
||||||
NAME = uuid.uuid4().hex
|
NAME = uuid.uuid4().hex
|
||||||
VOLUME_NAME = uuid.uuid4().hex
|
VOLUME_NAME = uuid.uuid4().hex
|
||||||
HEADERS = ['Name']
|
|
||||||
FIELDS = ['name']
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TransferRequestTests, cls).setUpClass()
|
super(TransferRequestTests, cls).setUpClass()
|
||||||
opts = cls.get_opts(['display_name'])
|
cmd_output = json.loads(cls.openstack(
|
||||||
raw_output = cls.openstack(
|
'volume create -f json --size 1 ' + cls.VOLUME_NAME))
|
||||||
'volume create --size 1 ' + cls.VOLUME_NAME + opts)
|
cls.assertOutput(cls.VOLUME_NAME, cmd_output['display_name'])
|
||||||
cls.assertOutput(cls.VOLUME_NAME + '\n', raw_output)
|
|
||||||
|
|
||||||
opts = cls.get_opts(cls.FIELDS)
|
cmd_output = json.loads(cls.openstack(
|
||||||
raw_output = cls.openstack(
|
'volume transfer request create -f json ' +
|
||||||
'volume transfer request create ' +
|
|
||||||
cls.VOLUME_NAME +
|
cls.VOLUME_NAME +
|
||||||
' --name ' + cls.NAME + opts)
|
' --name ' + cls.NAME))
|
||||||
cls.assertOutput(cls.NAME + '\n', raw_output)
|
cls.assertOutput(cls.NAME, cmd_output['name'])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@ -53,19 +49,18 @@ class TransferRequestTests(common.BaseVolumeTests):
|
|||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
|
|
||||||
# create a volume
|
# create a volume
|
||||||
opts = self.get_opts(['display_name'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume create -f json --size 1 ' + volume_name))
|
||||||
'volume create --size 1 ' + volume_name + opts)
|
self.assertEqual(volume_name, cmd_output['display_name'])
|
||||||
self.assertEqual(volume_name + '\n', raw_output)
|
|
||||||
|
|
||||||
# create volume transfer request for the volume
|
# create volume transfer request for the volume
|
||||||
# and get the auth_key of the new transfer request
|
# and get the auth_key of the new transfer request
|
||||||
opts = self.get_opts(['auth_key'])
|
cmd_output = json.loads(self.openstack(
|
||||||
auth_key = self.openstack(
|
'volume transfer request create -f json ' +
|
||||||
'volume transfer request create ' +
|
|
||||||
volume_name +
|
volume_name +
|
||||||
' --name ' + name + opts)
|
' --name ' + name))
|
||||||
self.assertNotEqual('', auth_key)
|
auth_key = cmd_output['auth_key']
|
||||||
|
self.assertTrue(auth_key)
|
||||||
|
|
||||||
# accept the volume transfer request
|
# accept the volume transfer request
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
@ -82,12 +77,11 @@ class TransferRequestTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
|
|
||||||
def test_volume_transfer_request_list(self):
|
def test_volume_transfer_request_list(self):
|
||||||
opts = self.get_opts(self.HEADERS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume transfer request list' + opts)
|
'volume transfer request list -f json'))
|
||||||
self.assertIn(self.NAME, raw_output)
|
self.assertIn(self.NAME, [req['Name'] for req in cmd_output])
|
||||||
|
|
||||||
def test_volume_transfer_request_show(self):
|
def test_volume_transfer_request_show(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume transfer request show -f json ' + self.NAME))
|
||||||
'volume transfer request show ' + self.NAME + opts)
|
self.assertEqual(self.NAME, cmd_output['name'])
|
||||||
self.assertEqual(self.NAME + '\n', raw_output)
|
|
||||||
|
@ -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 time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -20,16 +21,13 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
"""Functional tests for volume type. """
|
"""Functional tests for volume type. """
|
||||||
|
|
||||||
NAME = uuid.uuid4().hex
|
NAME = uuid.uuid4().hex
|
||||||
HEADERS = ['"Name"']
|
|
||||||
FIELDS = ['name']
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(VolumeTypeTests, cls).setUpClass()
|
super(VolumeTypeTests, cls).setUpClass()
|
||||||
opts = cls.get_opts(cls.FIELDS)
|
cmd_output = json.loads(cls.openstack(
|
||||||
raw_output = cls.openstack('volume type create ' + cls.NAME + opts)
|
'volume type create -f json ' + cls.NAME))
|
||||||
expected = cls.NAME + '\n'
|
cls.assertOutput(cls.NAME, cmd_output['name'])
|
||||||
cls.assertOutput(expected, raw_output)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@ -37,44 +35,45 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
cls.assertOutput('', raw_output)
|
cls.assertOutput('', raw_output)
|
||||||
|
|
||||||
def test_volume_type_list(self):
|
def test_volume_type_list(self):
|
||||||
opts = self.get_opts(self.HEADERS)
|
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||||
raw_output = self.openstack('volume type list' + opts)
|
self.assertIn(self.NAME, [t['Name'] for t in cmd_output])
|
||||||
self.assertIn(self.NAME, raw_output)
|
|
||||||
|
|
||||||
def test_volume_type_show(self):
|
def test_volume_type_show(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
'volume type show -f json ' + self.NAME))
|
||||||
self.assertEqual(self.NAME + "\n", raw_output)
|
self.assertEqual(self.NAME, cmd_output['name'])
|
||||||
|
|
||||||
def test_volume_type_set_unset_properties(self):
|
def test_volume_type_set_unset_properties(self):
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d ' + self.NAME)
|
'volume type set --property a=b --property c=d ' + self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
|
||||||
opts = self.get_opts(["properties"])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
'volume type show -f json ' + self.NAME))
|
||||||
self.assertEqual("a='b', c='d'\n", raw_output)
|
self.assertEqual("a='b', c='d'", cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack('volume type unset --property a '
|
raw_output = self.openstack('volume type unset --property a '
|
||||||
+ self.NAME)
|
+ self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
cmd_output = json.loads(self.openstack(
|
||||||
self.assertEqual("c='d'\n", raw_output)
|
'volume type show -f json ' + self.NAME))
|
||||||
|
self.assertEqual("c='d'", cmd_output['properties'])
|
||||||
|
|
||||||
def test_volume_type_set_unset_multiple_properties(self):
|
def test_volume_type_set_unset_multiple_properties(self):
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d ' + self.NAME)
|
'volume type set --property a=b --property c=d ' + self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
|
||||||
opts = self.get_opts(["properties"])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
'volume type show -f json ' + self.NAME))
|
||||||
self.assertEqual("a='b', c='d'\n", raw_output)
|
self.assertEqual("a='b', c='d'", cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --property a --property c ' + self.NAME)
|
'volume type unset --property a --property c ' + self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
cmd_output = json.loads(self.openstack(
|
||||||
self.assertEqual("\n", raw_output)
|
'volume type show -f json ' + self.NAME))
|
||||||
|
self.assertEqual("", cmd_output['properties'])
|
||||||
|
|
||||||
def test_multi_delete(self):
|
def test_multi_delete(self):
|
||||||
vol_type1 = uuid.uuid4().hex
|
vol_type1 = uuid.uuid4().hex
|
||||||
@ -84,7 +83,6 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.openstack('volume type create ' + vol_type2)
|
self.openstack('volume type create ' + vol_type2)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cmd = 'volume type delete %s %s' % (vol_type1, vol_type2)
|
cmd = 'volume type delete %s %s' % (vol_type1, vol_type2)
|
||||||
time.sleep(5)
|
|
||||||
raw_output = self.openstack(cmd)
|
raw_output = self.openstack(cmd)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
@ -95,40 +93,41 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
def test_encryption_type(self):
|
def test_encryption_type(self):
|
||||||
encryption_type = uuid.uuid4().hex
|
encryption_type = uuid.uuid4().hex
|
||||||
# test create new encryption type
|
# test create new encryption type
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type create -f json '
|
||||||
'volume type create '
|
|
||||||
'--encryption-provider LuksEncryptor '
|
'--encryption-provider LuksEncryptor '
|
||||||
'--encryption-cipher aes-xts-plain64 '
|
'--encryption-cipher aes-xts-plain64 '
|
||||||
'--encryption-key-size 128 '
|
'--encryption-key-size 128 '
|
||||||
'--encryption-control-location front-end ' +
|
'--encryption-control-location front-end ' +
|
||||||
encryption_type + opts)
|
encryption_type))
|
||||||
|
# TODO(amotoki): encryption output should be machine-readable
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test show encryption type
|
# test show encryption type
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + encryption_type))
|
||||||
'volume type show --encryption-type ' + encryption_type + opts)
|
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test list encryption type
|
# test list encryption type
|
||||||
opts = self.get_opts(['Encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type list -f json --encryption-type'))
|
||||||
'volume type list --encryption-type ' + opts)
|
encryption_output = [t['Encryption'] for t in cmd_output
|
||||||
|
if t['Name'] == encryption_type][0]
|
||||||
|
# TODO(amotoki): encryption output should be machine-readable
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, encryption_output)
|
||||||
# test set new encryption type
|
# test set new encryption type
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set '
|
'volume type set '
|
||||||
@ -138,23 +137,21 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
'--encryption-control-location front-end ' +
|
'--encryption-control-location front-end ' +
|
||||||
self.NAME)
|
self.NAME)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + self.NAME))
|
||||||
'volume type show --encryption-type ' + self.NAME + opts)
|
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test unset encryption type
|
# test unset encryption type
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --encryption-type ' + self.NAME)
|
'volume type unset --encryption-type ' + self.NAME)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + self.NAME))
|
||||||
'volume type show --encryption-type ' + self.NAME + opts)
|
self.assertEqual('', cmd_output['encryption'])
|
||||||
self.assertEqual('\n', raw_output)
|
|
||||||
# test delete encryption type
|
# test delete encryption type
|
||||||
raw_output = self.openstack('volume type delete ' + encryption_type)
|
raw_output = self.openstack('volume type delete ' + encryption_type)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
|
@ -21,23 +21,20 @@ class TransferRequestTests(common.BaseVolumeTests):
|
|||||||
|
|
||||||
NAME = uuid.uuid4().hex
|
NAME = uuid.uuid4().hex
|
||||||
VOLUME_NAME = uuid.uuid4().hex
|
VOLUME_NAME = uuid.uuid4().hex
|
||||||
HEADERS = ['Name']
|
|
||||||
FIELDS = ['name']
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TransferRequestTests, cls).setUpClass()
|
super(TransferRequestTests, cls).setUpClass()
|
||||||
opts = cls.get_opts(cls.FIELDS)
|
|
||||||
|
|
||||||
raw_output = cls.openstack(
|
cmd_output = json.loads(cls.openstack(
|
||||||
'volume create --size 1 ' + cls.VOLUME_NAME + opts)
|
'volume create -f json --size 1 ' + cls.VOLUME_NAME))
|
||||||
cls.assertOutput(cls.VOLUME_NAME + '\n', raw_output)
|
cls.assertOutput(cls.VOLUME_NAME, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = cls.openstack(
|
cmd_output = json.loads(cls.openstack(
|
||||||
'volume transfer request create ' +
|
'volume transfer request create -f json ' +
|
||||||
cls.VOLUME_NAME +
|
cls.VOLUME_NAME +
|
||||||
' --name ' + cls.NAME + opts)
|
' --name ' + cls.NAME))
|
||||||
cls.assertOutput(cls.NAME + '\n', raw_output)
|
cls.assertOutput(cls.NAME, cmd_output['name'])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@ -53,27 +50,26 @@ class TransferRequestTests(common.BaseVolumeTests):
|
|||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
|
|
||||||
# create a volume
|
# create a volume
|
||||||
opts = self.get_opts(self.FIELDS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume create -f json --size 1 ' + volume_name))
|
||||||
'volume create --size 1 ' + volume_name + opts)
|
self.assertEqual(volume_name, cmd_output['name'])
|
||||||
self.assertEqual(volume_name + '\n', raw_output)
|
|
||||||
|
|
||||||
# create volume transfer request for the volume
|
# create volume transfer request for the volume
|
||||||
# and get the auth_key of the new transfer request
|
# and get the auth_key of the new transfer request
|
||||||
opts = self.get_opts(['auth_key'])
|
cmd_output = json.loads(self.openstack(
|
||||||
auth_key = self.openstack(
|
'volume transfer request create -f json ' +
|
||||||
'volume transfer request create ' +
|
|
||||||
volume_name +
|
volume_name +
|
||||||
' --name ' + name + opts)
|
' --name ' + name))
|
||||||
self.assertNotEqual('', auth_key)
|
auth_key = cmd_output['auth_key']
|
||||||
|
self.assertTrue(auth_key)
|
||||||
|
|
||||||
# accept the volume transfer request
|
# accept the volume transfer request
|
||||||
json_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'volume transfer request accept -f json ' +
|
'volume transfer request accept -f json ' +
|
||||||
name + ' ' +
|
name + ' ' +
|
||||||
'--auth-key ' + auth_key
|
'--auth-key ' + auth_key
|
||||||
))
|
))
|
||||||
self.assertEqual(name, json_output.get('name'))
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
# the volume transfer will be removed by default after accepted
|
# the volume transfer will be removed by default after accepted
|
||||||
# so just need to delete the volume here
|
# so just need to delete the volume here
|
||||||
@ -82,12 +78,11 @@ class TransferRequestTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
|
|
||||||
def test_volume_transfer_request_list(self):
|
def test_volume_transfer_request_list(self):
|
||||||
opts = self.get_opts(self.HEADERS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume transfer request list' + opts)
|
'volume transfer request list -f json'))
|
||||||
self.assertIn(self.NAME, raw_output)
|
self.assertIn(self.NAME, [req['Name'] for req in cmd_output])
|
||||||
|
|
||||||
def test_volume_transfer_request_show(self):
|
def test_volume_transfer_request_show(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume transfer request show -f json ' + self.NAME))
|
||||||
'volume transfer request show ' + self.NAME + opts)
|
self.assertEqual(self.NAME, cmd_output['name'])
|
||||||
self.assertEqual(self.NAME + '\n', raw_output)
|
|
||||||
|
@ -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 time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -20,17 +21,13 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
"""Functional tests for volume type. """
|
"""Functional tests for volume type. """
|
||||||
|
|
||||||
NAME = uuid.uuid4().hex
|
NAME = uuid.uuid4().hex
|
||||||
HEADERS = ['"Name"']
|
|
||||||
FIELDS = ['name']
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(VolumeTypeTests, cls).setUpClass()
|
super(VolumeTypeTests, cls).setUpClass()
|
||||||
opts = cls.get_opts(cls.FIELDS)
|
cmd_output = json.loads(cls.openstack(
|
||||||
raw_output = cls.openstack(
|
'volume type create -f json --private ' + cls.NAME))
|
||||||
'volume type create --private ' + cls.NAME + opts)
|
cls.assertOutput(cls.NAME, cmd_output['name'])
|
||||||
expected = cls.NAME + '\n'
|
|
||||||
cls.assertOutput(expected, raw_output)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@ -38,49 +35,50 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
cls.assertOutput('', raw_output)
|
cls.assertOutput('', raw_output)
|
||||||
|
|
||||||
def test_volume_type_list(self):
|
def test_volume_type_list(self):
|
||||||
opts = self.get_opts(self.HEADERS)
|
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||||
raw_output = self.openstack('volume type list' + opts)
|
self.assertIn(self.NAME, [t['Name'] for t in cmd_output])
|
||||||
self.assertIn(self.NAME, raw_output)
|
|
||||||
|
|
||||||
def test_volume_type_list_default(self):
|
def test_volume_type_list_default(self):
|
||||||
opts = self.get_opts(self.HEADERS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume type list --default' + opts)
|
'volume type list -f json --default'))
|
||||||
self.assertEqual("lvmdriver-1\n", raw_output)
|
self.assertEqual(1, len(cmd_output))
|
||||||
|
self.assertEqual('lvmdriver-1', cmd_output[0]['Name'])
|
||||||
|
|
||||||
def test_volume_type_show(self):
|
def test_volume_type_show(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
'volume type show -f json ' + self.NAME))
|
||||||
self.assertEqual(self.NAME + "\n", raw_output)
|
self.assertEqual(self.NAME, cmd_output['name'])
|
||||||
|
|
||||||
def test_volume_type_set_unset_properties(self):
|
def test_volume_type_set_unset_properties(self):
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d ' + self.NAME)
|
'volume type set --property a=b --property c=d ' + self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
opts = self.get_opts(["properties"])
|
'volume type show -f json ' + self.NAME))
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
# TODO(amotoki): properties output should be machine-readable
|
||||||
self.assertEqual("a='b', c='d'\n", raw_output)
|
self.assertEqual("a='b', c='d'", cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack('volume type unset --property a '
|
raw_output = self.openstack('volume type unset --property a '
|
||||||
+ self.NAME)
|
+ self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
cmd_output = json.loads(self.openstack(
|
||||||
self.assertEqual("c='d'\n", raw_output)
|
'volume type show -f json ' + self.NAME))
|
||||||
|
self.assertEqual("c='d'", cmd_output['properties'])
|
||||||
|
|
||||||
def test_volume_type_set_unset_multiple_properties(self):
|
def test_volume_type_set_unset_multiple_properties(self):
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d ' + self.NAME)
|
'volume type set --property a=b --property c=d ' + self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
opts = self.get_opts(["properties"])
|
'volume type show -f json ' + self.NAME))
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
self.assertEqual("a='b', c='d'", cmd_output['properties'])
|
||||||
self.assertEqual("a='b', c='d'\n", raw_output)
|
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --property a --property c ' + self.NAME)
|
'volume type unset --property a --property c ' + self.NAME)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
raw_output = self.openstack('volume type show ' + self.NAME + opts)
|
cmd_output = json.loads(self.openstack(
|
||||||
self.assertEqual("\n", raw_output)
|
'volume type show -f json ' + self.NAME))
|
||||||
|
self.assertEqual("", cmd_output['properties'])
|
||||||
|
|
||||||
def test_volume_type_set_unset_project(self):
|
def test_volume_type_set_unset_project(self):
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -99,7 +97,6 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.openstack('volume type create ' + vol_type2)
|
self.openstack('volume type create ' + vol_type2)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cmd = 'volume type delete %s %s' % (vol_type1, vol_type2)
|
cmd = 'volume type delete %s %s' % (vol_type1, vol_type2)
|
||||||
time.sleep(5)
|
|
||||||
raw_output = self.openstack(cmd)
|
raw_output = self.openstack(cmd)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
@ -110,40 +107,42 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
def test_encryption_type(self):
|
def test_encryption_type(self):
|
||||||
encryption_type = uuid.uuid4().hex
|
encryption_type = uuid.uuid4().hex
|
||||||
# test create new encryption type
|
# test create new encryption type
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type create -f json '
|
||||||
'volume type create '
|
|
||||||
'--encryption-provider LuksEncryptor '
|
'--encryption-provider LuksEncryptor '
|
||||||
'--encryption-cipher aes-xts-plain64 '
|
'--encryption-cipher aes-xts-plain64 '
|
||||||
'--encryption-key-size 128 '
|
'--encryption-key-size 128 '
|
||||||
'--encryption-control-location front-end ' +
|
'--encryption-control-location front-end ' +
|
||||||
encryption_type + opts)
|
encryption_type))
|
||||||
|
# TODO(amotoki): encryption output should be machine-readable
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test show encryption type
|
# test show encryption type
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + encryption_type))
|
||||||
'volume type show --encryption-type ' + encryption_type + opts)
|
# TODO(amotoki): encryption output should be machine-readable
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test list encryption type
|
# test list encryption type
|
||||||
opts = self.get_opts(['Encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type list -f json --encryption-type'))
|
||||||
'volume type list --encryption-type ' + opts)
|
encryption_output = [t['Encryption'] for t in cmd_output
|
||||||
|
if t['Name'] == encryption_type][0]
|
||||||
|
# TODO(amotoki): encryption output should be machine-readable
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, encryption_output)
|
||||||
# test set existing encryption type
|
# test set existing encryption type
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set '
|
'volume type set '
|
||||||
@ -151,15 +150,14 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
'--encryption-control-location back-end ' +
|
'--encryption-control-location back-end ' +
|
||||||
encryption_type)
|
encryption_type)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + encryption_type))
|
||||||
'volume type show --encryption-type ' + encryption_type + opts)
|
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='256'",
|
"key_size='256'",
|
||||||
"control_location='back-end'"]
|
"control_location='back-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test set new encryption type
|
# test set new encryption type
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set '
|
'volume type set '
|
||||||
@ -169,23 +167,21 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
'--encryption-control-location front-end ' +
|
'--encryption-control-location front-end ' +
|
||||||
self.NAME)
|
self.NAME)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + self.NAME))
|
||||||
'volume type show --encryption-type ' + self.NAME + opts)
|
|
||||||
expected = ["provider='LuksEncryptor'",
|
expected = ["provider='LuksEncryptor'",
|
||||||
"cipher='aes-xts-plain64'",
|
"cipher='aes-xts-plain64'",
|
||||||
"key_size='128'",
|
"key_size='128'",
|
||||||
"control_location='front-end'"]
|
"control_location='front-end'"]
|
||||||
for attr in expected:
|
for attr in expected:
|
||||||
self.assertIn(attr, raw_output)
|
self.assertIn(attr, cmd_output['encryption'])
|
||||||
# test unset encryption type
|
# test unset encryption type
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --encryption-type ' + self.NAME)
|
'volume type unset --encryption-type ' + self.NAME)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
opts = self.get_opts(['encryption'])
|
cmd_output = json.loads(self.openstack(
|
||||||
raw_output = self.openstack(
|
'volume type show -f json --encryption-type ' + self.NAME))
|
||||||
'volume type show --encryption-type ' + self.NAME + opts)
|
self.assertEqual('', cmd_output['encryption'])
|
||||||
self.assertEqual('\n', raw_output)
|
|
||||||
# test delete encryption type
|
# test delete encryption type
|
||||||
raw_output = self.openstack('volume type delete ' + encryption_type)
|
raw_output = self.openstack('volume type delete ' + encryption_type)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user