2020-12-01 15:34:49 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2021-11-10 02:01:48 +08:00
|
|
|
def test_run_check(host):
|
|
|
|
kataruntime = "/opt/kata/bin/kata-runtime"
|
2020-12-01 15:34:49 +08:00
|
|
|
with host.sudo():
|
2021-11-10 02:01:48 +08:00
|
|
|
cmd = host.command(kataruntime + " check")
|
2020-12-01 15:34:49 +08:00
|
|
|
assert cmd.rc == 0
|
2021-11-10 02:01:48 +08:00
|
|
|
assert "System is capable of running" in cmd.stdout
|
2020-12-01 15:34:49 +08:00
|
|
|
|
2021-11-10 02:01:48 +08:00
|
|
|
|
|
|
|
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)
|
2020-12-01 15:34:49 +08:00
|
|
|
with host.sudo():
|
|
|
|
cmd = host.command(run_command)
|
|
|
|
assert cmd.rc == 0
|
2021-11-10 02:01:48 +08:00
|
|
|
|
|
|
|
with host.sudo():
|
|
|
|
log_f = host.file("/tmp/kata1.0.log")
|
|
|
|
|
|
|
|
assert log_f.exists
|
|
|
|
assert b"Hello from Docker!" in log_f.content
|