diff --git a/zun_tempest_plugin/tests/tempest/api/common/datagen.py b/zun_tempest_plugin/tests/tempest/api/common/datagen.py index 9fa616e..4224965 100644 --- a/zun_tempest_plugin/tests/tempest/api/common/datagen.py +++ b/zun_tempest_plugin/tests/tempest/api/common/datagen.py @@ -116,9 +116,9 @@ def container_remove_sg_data(**kwargs): return model -def capsule_data(default_data=None, **kwargs): - if default_data is None: - default_data = { +def capsule_data(data=None, **kwargs): + if data is None: + data = { 'template': { 'kind': 'capsule', 'capsuleVersion': 'beta', @@ -130,6 +130,6 @@ def capsule_data(default_data=None, **kwargs): } } } - default_data.update(kwargs) - model = capsule_model.CapsuleEntity.from_dict(default_data) + data.update(kwargs) + model = capsule_model.CapsuleEntity.from_dict(data) return model diff --git a/zun_tempest_plugin/tests/tempest/api/test_capsules.py b/zun_tempest_plugin/tests/tempest/api/test_capsules.py index 1dd44da..b707da5 100644 --- a/zun_tempest_plugin/tests/tempest/api/test_capsules.py +++ b/zun_tempest_plugin/tests/tempest/api/test_capsules.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +from tempest.lib.common.utils import data_utils from tempest.lib import decorators from zun_tempest_plugin.tests.tempest.api import clients @@ -99,3 +100,52 @@ class TestCapsule(base.BaseZunTest): self.assertEqual('Running', model.status) # TODO(hongbin): verify all containers are running return resp, model + + @decorators.idempotent_id('b7e79a0b-c09e-4539-886f-a9f33ae15620') + def test_create_capsule_full(self): + capsule_data = { + "template": { + "capsuleVersion": "beta", + "kind": "capsule", + "metadata": { + "labels": { + "app": "web", + "app1": "web1" + }, + "name": data_utils.rand_name('capsule') + }, + "spec": { + "restartPolicy": "Always", + "containers": [ + { + "command": [ + "/bin/bash" + ], + "env": { + "ENV1": "/usr/local/bin", + "ENV2": "/usr/bin" + }, + "image": "ubuntu", + "imagePullPolicy": "ifnotpresent", + "ports": [ + { + "containerPort": 80, + "hostPort": 80, + "name": "nginx-port", + "protocol": "TCP" + } + ], + "resources": { + "requests": { + "cpu": 1, + "memory": 256 + } + }, + "workDir": "/root" + } + ] + } + } + } + + self._create_capsule(data=capsule_data)