Test full capsule template

Change-Id: Ia52750f804ce363e1082c4d67747c04ac8204ad5
This commit is contained in:
Hongbin Lu 2018-07-06 02:16:58 +00:00
parent b1deaa19a9
commit 46f8378395
2 changed files with 55 additions and 5 deletions

View File

@ -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

View File

@ -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)