You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

  1. import os
  2. import pytest
  3. import testinfra.utils.ansible_runner
  4. testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
  5. os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
  6. def test_service(host):
  7. svc = host.service("containerd")
  8. assert svc.is_running
  9. assert svc.is_enabled
  10. def test_version(host):
  11. crictl = "/usr/local/bin/crictl"
  12. path = "unix:///var/run/containerd/containerd.sock"
  13. with host.sudo():
  14. cmd = host.command(crictl + " --runtime-endpoint " + path + " version")
  15. assert cmd.rc == 0
  16. assert "RuntimeName: containerd" in cmd.stdout
  17. @pytest.mark.parametrize('image, dest', [
  18. ('quay.io/kubespray/hello-world:latest', '/tmp/hello-world.tar')
  19. ])
  20. def test_image_pull_save_load(host, image, dest):
  21. nerdctl = "/usr/local/bin/nerdctl"
  22. dest_file = host.file(dest)
  23. with host.sudo():
  24. pull_cmd = host.command(nerdctl + " pull " + image)
  25. assert pull_cmd.rc ==0
  26. with host.sudo():
  27. save_cmd = host.command(nerdctl + " save -o " + dest + " " + image)
  28. assert save_cmd.rc == 0
  29. assert dest_file.exists
  30. with host.sudo():
  31. load_cmd = host.command(nerdctl + " load < " + dest)
  32. assert load_cmd.rc == 0
  33. @pytest.mark.parametrize('image', [
  34. ('quay.io/kubespray/hello-world:latest')
  35. ])
  36. def test_run(host, image):
  37. nerdctl = "/usr/local/bin/nerdctl"
  38. with host.sudo():
  39. cmd = host.command(nerdctl + " -n k8s.io run " + image)
  40. assert cmd.rc == 0
  41. assert "Hello from Docker" in cmd.stdout