summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-05-25 19:53:51 +0000
committerGerrit Code Review <review@openstack.org>2017-05-25 19:53:51 +0000
commitb78153aec4f050e64ee8ec9c930ae673bb3ecd47 (patch)
tree3c9070f187c8fe68482b1e70e1d06a4306b4ed4e
parent5f41f651e588c9b9d6091aaa79f6ebf4134e607d (diff)
parent9f297853ce768c243d9c411b42786954e991cd91 (diff)
downloadpython-openstackclient-b78153aec4f050e64ee8ec9c930ae673bb3ecd47.tar.gz
Merge "Add functional test for volume service"
-rw-r--r--openstackclient/tests/functional/volume/v1/test_service.py93
-rw-r--r--openstackclient/tests/functional/volume/v2/test_service.py93
2 files changed, 186 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/volume/v1/test_service.py b/openstackclient/tests/functional/volume/v1/test_service.py
new file mode 100644
index 00000000..c921c46a
--- /dev/null
+++ b/openstackclient/tests/functional/volume/v1/test_service.py
@@ -0,0 +1,93 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from openstackclient.tests.functional.volume.v1 import common
+
+
+class VolumeServiceTests(common.BaseVolumeTests):
+ """Functional tests for volume service."""
+
+ def test_volume_service_list(self):
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json'))
+
+ # Get the nonredundant services and hosts
+ services = list(set([x['Binary'] for x in cmd_output]))
+
+ # Test volume service list --service
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json ' +
+ '--service ' +
+ services[0]
+ ))
+ for x in cmd_output:
+ self.assertEqual(
+ services[0],
+ x['Binary']
+ )
+
+ # TODO(zhiyong.dai): test volume service list --host after solving
+ # https://bugs.launchpad.net/python-openstackclient/+bug/1664451
+
+ def test_volume_service_set(self):
+
+ # Get a service and host
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json'
+ ))
+ service_1 = cmd_output[0]['Binary']
+ host_1 = cmd_output[0]['Host']
+
+ # Test volume service set --enable
+ raw_output = self.openstack(
+ 'volume service set --enable ' +
+ host_1 + ' ' +
+ service_1
+ )
+ self.assertOutput('', raw_output)
+
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json --long'
+ ))
+ self.assertEqual(
+ 'enabled',
+ cmd_output[0]['Status']
+ )
+ self.assertEqual(
+ None,
+ cmd_output[0]['Disabled Reason']
+ )
+
+ # Test volume service set --disable and --disable-reason
+ disable_reason = 'disable_reason'
+ raw_output = self.openstack(
+ 'volume service set --disable ' +
+ '--disable-reason ' +
+ disable_reason + ' ' +
+ host_1 + ' ' +
+ service_1
+ )
+ self.assertOutput('', raw_output)
+
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json --long'
+ ))
+ self.assertEqual(
+ 'disabled',
+ cmd_output[0]['Status']
+ )
+ self.assertEqual(
+ disable_reason,
+ cmd_output[0]['Disabled Reason']
+ )
diff --git a/openstackclient/tests/functional/volume/v2/test_service.py b/openstackclient/tests/functional/volume/v2/test_service.py
new file mode 100644
index 00000000..8d1944e4
--- /dev/null
+++ b/openstackclient/tests/functional/volume/v2/test_service.py
@@ -0,0 +1,93 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from openstackclient.tests.functional.volume.v2 import common
+
+
+class VolumeServiceTests(common.BaseVolumeTests):
+ """Functional tests for volume service."""
+
+ def test_volume_service_list(self):
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json'))
+
+ # Get the nonredundant services and hosts
+ services = list(set([x['Binary'] for x in cmd_output]))
+
+ # Test volume service list --service
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json ' +
+ '--service ' +
+ services[0]
+ ))
+ for x in cmd_output:
+ self.assertEqual(
+ services[0],
+ x['Binary']
+ )
+
+ # TODO(zhiyong.dai): test volume service list --host after solving
+ # https://bugs.launchpad.net/python-openstackclient/+bug/1664451
+
+ def test_volume_service_set(self):
+
+ # Get a service and host
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json'
+ ))
+ service_1 = cmd_output[0]['Binary']
+ host_1 = cmd_output[0]['Host']
+
+ # Test volume service set --enable
+ raw_output = self.openstack(
+ 'volume service set --enable ' +
+ host_1 + ' ' +
+ service_1
+ )
+ self.assertOutput('', raw_output)
+
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json --long'
+ ))
+ self.assertEqual(
+ 'enabled',
+ cmd_output[0]['Status']
+ )
+ self.assertEqual(
+ None,
+ cmd_output[0]['Disabled Reason']
+ )
+
+ # Test volume service set --disable and --disable-reason
+ disable_reason = 'disable_reason'
+ raw_output = self.openstack(
+ 'volume service set --disable ' +
+ '--disable-reason ' +
+ disable_reason + ' ' +
+ host_1 + ' ' +
+ service_1
+ )
+ self.assertOutput('', raw_output)
+
+ cmd_output = json.loads(self.openstack(
+ 'volume service list -f json --long'
+ ))
+ self.assertEqual(
+ 'disabled',
+ cmd_output[0]['Status']
+ )
+ self.assertEqual(
+ disable_reason,
+ cmd_output[0]['Disabled Reason']
+ )