summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/tests/functional')
-rw-r--r--openstackclient/tests/functional/compute/v2/test_aggregate.py147
-rw-r--r--openstackclient/tests/functional/compute/v2/test_server.py78
-rw-r--r--openstackclient/tests/functional/network/v2/test_floating_ip.py2
-rw-r--r--openstackclient/tests/functional/network/v2/test_subnet_pool.py4
4 files changed, 131 insertions, 100 deletions
diff --git a/openstackclient/tests/functional/compute/v2/test_aggregate.py b/openstackclient/tests/functional/compute/v2/test_aggregate.py
index 71026757..c591dd61 100644
--- a/openstackclient/tests/functional/compute/v2/test_aggregate.py
+++ b/openstackclient/tests/functional/compute/v2/test_aggregate.py
@@ -11,7 +11,6 @@
# under the License.
import json
-import time
import uuid
from openstackclient.tests.functional import base
@@ -20,12 +19,13 @@ from openstackclient.tests.functional import base
class AggregateTests(base.TestCase):
"""Functional tests for aggregate"""
- def test_aggregate_create_and_delete(self):
+ def test_aggregate_crud(self):
"""Test create, delete multiple"""
name1 = uuid.uuid4().hex
cmd_output = json.loads(self.openstack(
'aggregate create -f json ' +
'--zone nova ' +
+ '--property a=b ' +
name1
))
self.assertEqual(
@@ -36,11 +36,17 @@ class AggregateTests(base.TestCase):
'nova',
cmd_output['availability_zone']
)
+ # TODO(dtroyer): enable the following once the properties field
+ # is correctly formatted in the create output
+ # self.assertIn(
+ # "a='b'",
+ # cmd_output['properties']
+ # )
name2 = uuid.uuid4().hex
cmd_output = json.loads(self.openstack(
'aggregate create -f json ' +
- '--zone nova ' +
+ '--zone external ' +
name2
))
self.assertEqual(
@@ -48,101 +54,15 @@ class AggregateTests(base.TestCase):
cmd_output['name']
)
self.assertEqual(
- 'nova',
+ 'external',
cmd_output['availability_zone']
)
- # Loop a few times since this is timing-sensitive
- # Just hard-code it for now, since there is no pause and it is
- # racy we shouldn't have to wait too long, a minute seems reasonable
- wait_time = 0
- while wait_time < 60:
- cmd_output = json.loads(self.openstack(
- 'aggregate show -f json ' +
- name2
- ))
- if cmd_output['name'] != name2:
- # Hang out for a bit and try again
- print('retrying aggregate check')
- wait_time += 10
- time.sleep(10)
- else:
- break
-
- del_output = self.openstack(
- 'aggregate delete ' +
- name1 + ' ' +
- name2
- )
- self.assertOutput('', del_output)
-
- def test_aggregate_list(self):
- """Test aggregate list"""
- name1 = uuid.uuid4().hex
- self.openstack(
- 'aggregate create ' +
- '--zone nova ' +
- '--property a=b ' +
- name1
- )
- self.addCleanup(
- self.openstack,
- 'aggregate delete ' + name1,
- fail_ok=True,
- )
-
- name2 = uuid.uuid4().hex
- self.openstack(
- 'aggregate create ' +
- '--zone internal ' +
- '--property c=d ' +
- name2
- )
- self.addCleanup(
- self.openstack,
- 'aggregate delete ' + name2,
- fail_ok=True,
- )
-
- cmd_output = json.loads(self.openstack(
- 'aggregate list -f json'
- ))
- names = [x['Name'] for x in cmd_output]
- self.assertIn(name1, names)
- self.assertIn(name2, names)
- zones = [x['Availability Zone'] for x in cmd_output]
- self.assertIn('nova', zones)
- self.assertIn('internal', zones)
-
- # Test aggregate list --long
- cmd_output = json.loads(self.openstack(
- 'aggregate list --long -f json'
- ))
- names = [x['Name'] for x in cmd_output]
- self.assertIn(name1, names)
- self.assertIn(name2, names)
- zones = [x['Availability Zone'] for x in cmd_output]
- self.assertIn('nova', zones)
- self.assertIn('internal', zones)
- properties = [x['Properties'] for x in cmd_output]
- self.assertIn({'a': 'b'}, properties)
- self.assertIn({'c': 'd'}, properties)
-
- def test_aggregate_set_and_unset(self):
- """Test aggregate set, show and unset"""
- name1 = uuid.uuid4().hex
- name2 = uuid.uuid4().hex
- self.openstack(
- 'aggregate create ' +
- '--zone nova ' +
- '--property a=b ' +
- name1
- )
- self.addCleanup(self.openstack, 'aggregate delete ' + name2)
-
+ # Test aggregate set
+ name3 = uuid.uuid4().hex
raw_output = self.openstack(
'aggregate set ' +
- '--name ' + name2 + ' ' +
+ '--name ' + name3 + ' ' +
'--zone internal ' +
'--no-property ' +
'--property c=d ' +
@@ -152,10 +72,10 @@ class AggregateTests(base.TestCase):
cmd_output = json.loads(self.openstack(
'aggregate show -f json ' +
- name2
+ name3
))
self.assertEqual(
- name2,
+ name3,
cmd_output['name']
)
self.assertEqual(
@@ -171,23 +91,56 @@ class AggregateTests(base.TestCase):
cmd_output['properties']
)
+ # Test aggregate list
+ cmd_output = json.loads(self.openstack(
+ 'aggregate list -f json'
+ ))
+ names = [x['Name'] for x in cmd_output]
+ self.assertIn(name3, names)
+ self.assertIn(name2, names)
+ zones = [x['Availability Zone'] for x in cmd_output]
+ self.assertIn('external', zones)
+ self.assertIn('internal', zones)
+
+ # Test aggregate list --long
+ cmd_output = json.loads(self.openstack(
+ 'aggregate list --long -f json'
+ ))
+ names = [x['Name'] for x in cmd_output]
+ self.assertIn(name3, names)
+ self.assertIn(name2, names)
+ zones = [x['Availability Zone'] for x in cmd_output]
+ self.assertIn('external', zones)
+ self.assertIn('internal', zones)
+ properties = [x['Properties'] for x in cmd_output]
+ self.assertNotIn({'a': 'b'}, properties)
+ self.assertIn({'c': 'd'}, properties)
+
# Test unset
raw_output = self.openstack(
'aggregate unset ' +
'--property c ' +
- name2
+ name3
)
self.assertOutput('', raw_output)
cmd_output = json.loads(self.openstack(
'aggregate show -f json ' +
- name2
+ name3
))
self.assertNotIn(
"c='d'",
cmd_output['properties']
)
+ # test aggregate delete
+ del_output = self.openstack(
+ 'aggregate delete ' +
+ name3 + ' ' +
+ name2
+ )
+ self.assertOutput('', del_output)
+
def test_aggregate_add_and_remove_host(self):
"""Test aggregate add and remove host"""
# Get a host
diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py
index aa7d7cb7..e52a42d3 100644
--- a/openstackclient/tests/functional/compute/v2/test_server.py
+++ b/openstackclient/tests/functional/compute/v2/test_server.py
@@ -63,6 +63,84 @@ class ServerTests(common.ComputeTestCase):
self.assertNotIn(name1, col_name)
self.assertIn(name2, col_name)
+ def test_server_list_with_changes_before(self):
+ """Test server list.
+
+ Getting the servers list with updated_at time equal or
+ before than changes-before.
+ """
+ cmd_output = self.server_create()
+ server_name1 = cmd_output['name']
+
+ cmd_output = self.server_create()
+ server_name2 = cmd_output['name']
+ updated_at2 = cmd_output['updated']
+
+ cmd_output = self.server_create()
+ server_name3 = cmd_output['name']
+
+ cmd_output = json.loads(self.openstack(
+ '--os-compute-api-version 2.66 ' +
+ 'server list -f json '
+ '--changes-before ' + updated_at2
+ ))
+
+ col_updated = [server["Name"] for server in cmd_output]
+ self.assertIn(server_name1, col_updated)
+ self.assertIn(server_name2, col_updated)
+ self.assertNotIn(server_name3, col_updated)
+
+ def test_server_list_with_changes_since(self):
+ """Test server list.
+
+ Getting the servers list with updated_at time equal or
+ later than changes-since.
+ """
+ cmd_output = self.server_create()
+ server_name1 = cmd_output['name']
+ cmd_output = self.server_create()
+ server_name2 = cmd_output['name']
+ updated_at2 = cmd_output['updated']
+ cmd_output = self.server_create()
+ server_name3 = cmd_output['name']
+
+ cmd_output = json.loads(self.openstack(
+ 'server list -f json '
+ '--changes-since ' + updated_at2
+ ))
+
+ col_updated = [server["Name"] for server in cmd_output]
+ self.assertNotIn(server_name1, col_updated)
+ self.assertIn(server_name2, col_updated)
+ self.assertIn(server_name3, col_updated)
+
+ def test_server_list_with_changes_before_and_changes_since(self):
+ """Test server list.
+
+ Getting the servers list with updated_at time equal or before than
+ changes-before and equal or later than changes-since.
+ """
+ cmd_output = self.server_create()
+ server_name1 = cmd_output['name']
+ cmd_output = self.server_create()
+ server_name2 = cmd_output['name']
+ updated_at2 = cmd_output['updated']
+ cmd_output = self.server_create()
+ server_name3 = cmd_output['name']
+ updated_at3 = cmd_output['updated']
+
+ cmd_output = json.loads(self.openstack(
+ '--os-compute-api-version 2.66 ' +
+ 'server list -f json ' +
+ '--changes-since ' + updated_at2 +
+ ' --changes-before ' + updated_at3
+ ))
+
+ col_updated = [server["Name"] for server in cmd_output]
+ self.assertNotIn(server_name1, col_updated)
+ self.assertIn(server_name2, col_updated)
+ self.assertIn(server_name3, col_updated)
+
def test_server_set(self):
"""Test server create, delete, set, show"""
cmd_output = self.server_create()
diff --git a/openstackclient/tests/functional/network/v2/test_floating_ip.py b/openstackclient/tests/functional/network/v2/test_floating_ip.py
index 1d11fc5d..f189c2da 100644
--- a/openstackclient/tests/functional/network/v2/test_floating_ip.py
+++ b/openstackclient/tests/functional/network/v2/test_floating_ip.py
@@ -83,7 +83,7 @@ class FloatingIpTests(common.NetworkTests):
raise
pass
else:
- # break and no longer retry if create sucessfully
+ # break and no longer retry if create successfully
break
@classmethod
diff --git a/openstackclient/tests/functional/network/v2/test_subnet_pool.py b/openstackclient/tests/functional/network/v2/test_subnet_pool.py
index 46aa6f14..6be50529 100644
--- a/openstackclient/tests/functional/network/v2/test_subnet_pool.py
+++ b/openstackclient/tests/functional/network/v2/test_subnet_pool.py
@@ -266,7 +266,7 @@ class SubnetPoolTests(common.NetworkTagTests):
# pool. The error appears to be in a lower layer,
# once that is fixed add a test for subnet pool unset
# --default-quota.
- # The unset command of --pool-prefixes also doesnt work
+ # The unset command of --pool-prefixes also doesn't work
# right now. It would be fixed in a separate patch once
# the lower layer is fixed.
# cmd_output = self.openstack(
@@ -319,7 +319,7 @@ class SubnetPoolTests(common.NetworkTagTests):
raise
pass
else:
- # Break and no longer retry if create is sucessful
+ # Break and no longer retry if create is successful
break
return cmd_output, pool_prefix