diff --git a/roles/container-engine/gvisor/molecule/default/molecule.yml b/roles/container-engine/gvisor/molecule/default/molecule.yml index 543f5441e..212da4a91 100644 --- a/roles/container-engine/gvisor/molecule/default/molecule.yml +++ b/roles/container-engine/gvisor/molecule/default/molecule.yml @@ -25,4 +25,4 @@ provisioner: create: ../../../../../tests/cloud_playbooks/create-kubevirt.yml prepare: ../../../molecule/prepare.yml verifier: - name: testinfra + name: ansible diff --git a/roles/container-engine/gvisor/molecule/default/tests/test_default.py b/roles/container-engine/gvisor/molecule/default/tests/test_default.py deleted file mode 100644 index 1cb7fb0ff..000000000 --- a/roles/container-engine/gvisor/molecule/default/tests/test_default.py +++ /dev/null @@ -1,29 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -def test_run(host): - gvisorruntime = "/usr/local/bin/runsc" - with host.sudo(): - cmd = host.command(gvisorruntime + " --version") - assert cmd.rc == 0 - assert "runsc version" in cmd.stdout - - -def test_run_pod(host): - runtime = "runsc" - - run_command = "/usr/local/bin/crictl run --with-pull --runtime {} /tmp/container.json /tmp/sandbox.json".format(runtime) - with host.sudo(): - cmd = host.command(run_command) - assert cmd.rc == 0 - - with host.sudo(): - log_f = host.file("/tmp/gvisor1.0.log") - - assert log_f.exists - assert b"Hello from Docker" in log_f.content diff --git a/roles/container-engine/gvisor/molecule/default/verify.yml b/roles/container-engine/gvisor/molecule/default/verify.yml new file mode 100644 index 000000000..35e847e53 --- /dev/null +++ b/roles/container-engine/gvisor/molecule/default/verify.yml @@ -0,0 +1,19 @@ +--- +- name: Test gvisor + hosts: all + gather_facts: false + tasks: + - name: Get kubespray defaults + import_role: + name: ../../../../../kubespray_defaults + - name: Test version + command: "{{ bin_dir }}/runsc --version" + register: runsc_version + failed_when: > + runsc_version is failed or + 'runsc version' not in runsc_version.stdout + +- name: Test run container + import_playbook: ../../../molecule/test_runtime.yml + vars: + container_runtime: runsc diff --git a/roles/container-engine/kata-containers/molecule/default/molecule.yml b/roles/container-engine/kata-containers/molecule/default/molecule.yml index c5b312a36..0acb8f3a6 100644 --- a/roles/container-engine/kata-containers/molecule/default/molecule.yml +++ b/roles/container-engine/kata-containers/molecule/default/molecule.yml @@ -25,4 +25,4 @@ provisioner: create: ../../../../../tests/cloud_playbooks/create-kubevirt.yml prepare: ../../../molecule/prepare.yml verifier: - name: testinfra + name: ansible diff --git a/roles/container-engine/kata-containers/molecule/default/tests/test_default.py b/roles/container-engine/kata-containers/molecule/default/tests/test_default.py deleted file mode 100644 index e10fff4b7..000000000 --- a/roles/container-engine/kata-containers/molecule/default/tests/test_default.py +++ /dev/null @@ -1,37 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -def test_run(host): - kataruntime = "/opt/kata/bin/kata-runtime" - with host.sudo(): - cmd = host.command(kataruntime + " version") - assert cmd.rc == 0 - assert "kata-runtime" in cmd.stdout - - -def test_run_check(host): - kataruntime = "/opt/kata/bin/kata-runtime" - with host.sudo(): - cmd = host.command(kataruntime + " check") - assert cmd.rc == 0 - assert "System is capable of running" in cmd.stdout - - -def test_run_pod(host): - runtime = "kata-qemu" - - run_command = "/usr/local/bin/crictl run --with-pull --runtime {} /tmp/container.json /tmp/sandbox.json".format(runtime) - with host.sudo(): - cmd = host.command(run_command) - assert cmd.rc == 0 - - with host.sudo(): - log_f = host.file("/tmp/kata1.0.log") - - assert log_f.exists - assert b"Hello from Docker" in log_f.content diff --git a/roles/container-engine/kata-containers/molecule/default/verify.yml b/roles/container-engine/kata-containers/molecule/default/verify.yml new file mode 100644 index 000000000..1bb02c321 --- /dev/null +++ b/roles/container-engine/kata-containers/molecule/default/verify.yml @@ -0,0 +1,23 @@ +--- +- name: Test kata-containers + hosts: all + gather_facts: false + tasks: + - name: Test version + command: "/opt/kata/bin/kata-runtime version" + register: version + failed_when: > + version is failed or + 'kata-runtime' not in version.stdout + - name: Test version + command: "/opt/kata/bin/kata-runtime check" + register: check + failed_when: > + check is failed or + 'System is capable of running' not in check.stdout + +- name: Test run container + import_playbook: ../../../molecule/test_runtime.yml + vars: + container_runtime: kata-qemu + container_manager: containerd diff --git a/roles/container-engine/youki/molecule/default/molecule.yml b/roles/container-engine/youki/molecule/default/molecule.yml index 543f5441e..212da4a91 100644 --- a/roles/container-engine/youki/molecule/default/molecule.yml +++ b/roles/container-engine/youki/molecule/default/molecule.yml @@ -25,4 +25,4 @@ provisioner: create: ../../../../../tests/cloud_playbooks/create-kubevirt.yml prepare: ../../../molecule/prepare.yml verifier: - name: testinfra + name: ansible diff --git a/roles/container-engine/youki/molecule/default/tests/test_default.py b/roles/container-engine/youki/molecule/default/tests/test_default.py deleted file mode 100644 index 54ed5c54c..000000000 --- a/roles/container-engine/youki/molecule/default/tests/test_default.py +++ /dev/null @@ -1,29 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -def test_run(host): - youkiruntime = "/usr/local/bin/youki" - with host.sudo(): - cmd = host.command(youkiruntime + " --version") - assert cmd.rc == 0 - assert "youki" in cmd.stdout - - -def test_run_pod(host): - runtime = "youki" - - run_command = "/usr/local/bin/crictl run --with-pull --runtime {} /tmp/container.json /tmp/sandbox.json".format(runtime) - with host.sudo(): - cmd = host.command(run_command) - assert cmd.rc == 0 - - with host.sudo(): - log_f = host.file("/tmp/youki1.0.log") - - assert log_f.exists - assert b"Hello from Docker" in log_f.content diff --git a/roles/container-engine/youki/molecule/default/verify.yml b/roles/container-engine/youki/molecule/default/verify.yml new file mode 100644 index 000000000..75adeb559 --- /dev/null +++ b/roles/container-engine/youki/molecule/default/verify.yml @@ -0,0 +1,19 @@ +--- +- name: Test youki + hosts: all + gather_facts: false + tasks: + - name: Get kubespray defaults + import_role: + name: ../../../../../kubespray_defaults + - name: Test version + command: "{{ bin_dir }}/youki --version" + register: youki_version + failed_when: > + youki_version is failed or + 'youki' not in youki_version.stdout + +- name: Test run container + import_playbook: ../../../molecule/test_runtime.yml + vars: + container_runtime: youki