summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/tests/functional')
-rw-r--r--openstackclient/tests/functional/common/test_help.py2
-rw-r--r--openstackclient/tests/functional/compute/v2/test_agent.py4
-rw-r--r--openstackclient/tests/functional/compute/v2/test_keypair.py4
-rw-r--r--openstackclient/tests/functional/compute/v2/test_server.py10
-rw-r--r--openstackclient/tests/functional/object/v1/test_object.py2
-rw-r--r--openstackclient/tests/functional/volume/v2/test_backup.py58
6 files changed, 70 insertions, 10 deletions
diff --git a/openstackclient/tests/functional/common/test_help.py b/openstackclient/tests/functional/common/test_help.py
index 7f274099..88f7ddbd 100644
--- a/openstackclient/tests/functional/common/test_help.py
+++ b/openstackclient/tests/functional/common/test_help.py
@@ -80,7 +80,7 @@ class HelpTests(base.TestCase):
"""Check help commands without auth info."""
# Pop all auth info. os.environ will be changed in loop, so do not
# replace os.environ.keys() to os.environ
- for key in os.environ.keys():
+ for key in list(os.environ):
if key.startswith('OS_'):
self.useFixture(fixtures.EnvironmentVariable(key, None))
diff --git a/openstackclient/tests/functional/compute/v2/test_agent.py b/openstackclient/tests/functional/compute/v2/test_agent.py
index 1a112e82..25d8c868 100644
--- a/openstackclient/tests/functional/compute/v2/test_agent.py
+++ b/openstackclient/tests/functional/compute/v2/test_agent.py
@@ -21,10 +21,10 @@ class ComputeAgentTests(base.TestCase):
# Generate two different md5hash
MD5HASH1 = hashlib.md5()
- MD5HASH1.update('agent_1')
+ MD5HASH1.update('agent_1'.encode('utf-8'))
MD5HASH1 = MD5HASH1.hexdigest()
MD5HASH2 = hashlib.md5()
- MD5HASH2.update('agent_2')
+ MD5HASH2.update('agent_2'.encode('utf-8'))
MD5HASH2 = MD5HASH2.hexdigest()
def test_compute_agent_delete(self):
diff --git a/openstackclient/tests/functional/compute/v2/test_keypair.py b/openstackclient/tests/functional/compute/v2/test_keypair.py
index 9a88e66f..42f334a4 100644
--- a/openstackclient/tests/functional/compute/v2/test_keypair.py
+++ b/openstackclient/tests/functional/compute/v2/test_keypair.py
@@ -88,7 +88,7 @@ class KeypairTests(KeypairBase):
1) Create keypair with given public key
2) Delete keypair
"""
- with tempfile.NamedTemporaryFile() as f:
+ with tempfile.NamedTemporaryFile(mode='w+') as f:
f.write(self.PUBLIC_KEY)
f.flush()
@@ -108,7 +108,7 @@ class KeypairTests(KeypairBase):
1) Create keypair with private key file
2) Delete keypair
"""
- with tempfile.NamedTemporaryFile() as f:
+ with tempfile.NamedTemporaryFile(mode='w+') as f:
cmd_output = json.loads(self.openstack(
'keypair create -f json --private-key %s tmpkey' % f.name,
))
diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py
index 0b29fe5f..13fdfa06 100644
--- a/openstackclient/tests/functional/compute/v2/test_server.py
+++ b/openstackclient/tests/functional/compute/v2/test_server.py
@@ -586,7 +586,9 @@ class ServerTests(common.ComputeTestCase):
server_name
)
except exceptions.CommandFailed as e:
- self.assertIn('nics are required after microversion 2.36',
- e.stderr)
- else:
- self.fail('CommandFailed should be raised.')
+ # If we got here, it shouldn't be because a nics value wasn't
+ # provided to the server; it is likely due to something else in
+ # the functional tests like there being multiple available
+ # networks and the test didn't specify a specific network.
+ self.assertNotIn('nics are required after microversion 2.36',
+ e.stderr)
diff --git a/openstackclient/tests/functional/object/v1/test_object.py b/openstackclient/tests/functional/object/v1/test_object.py
index 226ef8ad..b3f23e52 100644
--- a/openstackclient/tests/functional/object/v1/test_object.py
+++ b/openstackclient/tests/functional/object/v1/test_object.py
@@ -33,7 +33,7 @@ class ObjectTests(common.ObjectStoreTests):
self.skipTest("No object-store service present")
def test_object(self):
- with tempfile.NamedTemporaryFile() as f:
+ with tempfile.NamedTemporaryFile(mode='w+') as f:
f.write('test content')
f.flush()
self._test_object(f.name)
diff --git a/openstackclient/tests/functional/volume/v2/test_backup.py b/openstackclient/tests/functional/volume/v2/test_backup.py
new file mode 100644
index 00000000..e4890b00
--- /dev/null
+++ b/openstackclient/tests/functional/volume/v2/test_backup.py
@@ -0,0 +1,58 @@
+# 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
+import uuid
+
+from openstackclient.tests.functional.volume.v2 import common
+
+
+class VolumeBackupTests(common.BaseVolumeTests):
+ """Functional tests for volume backups. """
+
+ def setUp(self):
+ super(VolumeBackupTests, self).setUp()
+ self.backup_enabled = False
+ serv_list = json.loads(self.openstack('volume service list -f json'))
+ for service in serv_list:
+ if service['Binary'] == 'cinder-backup':
+ if service['Status'] == 'enabled':
+ self.backup_enabled = True
+
+ def test_volume_backup_restore(self):
+ """Test restore backup"""
+ if not self.backup_enabled:
+ self.skipTest('Backup service is not enabled')
+ vol_id = uuid.uuid4().hex
+ # create a volume
+ json.loads(self.openstack(
+ 'volume create -f json ' +
+ '--size 1 ' +
+ vol_id
+ ))
+ # create a backup
+ backup = json.loads(self.openstack(
+ 'volume backup create -f json ' +
+ vol_id
+ ))
+
+ self.wait_for_status("volume", vol_id, "available")
+ self.wait_for_status("backup", backup['id'], "available")
+ # restore the backup
+ backup_restored = json.loads(self.openstack(
+ 'volume backup restore -f json %s %s'
+ % (backup['id'], vol_id)))
+ self.assertEqual(backup_restored['backup_id'], backup['id'])
+ self.wait_for_status("backup", backup['id'], "available")
+ self.wait_for_status("volume", backup_restored['volume_id'],
+ "available")
+ self.addCleanup(self.openstack, 'volume delete %s' % vol_id)