Browse Source

Add molecule for Kata Containers with Containerd (#6905)

pull/6903/head
Pasquale Toscano 4 years ago
committed by GitHub
parent
commit
f1231bb97d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 0 deletions
  1. 10
      roles/container-engine/kata-containers/molecule/default/converge.yml
  2. 44
      roles/container-engine/kata-containers/molecule/default/molecule.yml
  3. 6
      roles/container-engine/kata-containers/molecule/default/prepare.yml
  4. 30
      roles/container-engine/kata-containers/molecule/default/tests/test_default.py

10
roles/container-engine/kata-containers/molecule/default/converge.yml

@ -0,0 +1,10 @@
---
- name: Converge
hosts: all
become: true
vars:
kata_containers_enabled: true
roles:
- role: kubespray-defaults
- role: containerd
- role: kata-containers

44
roles/container-engine/kata-containers/molecule/default/molecule.yml

@ -0,0 +1,44 @@
---
driver:
name: vagrant
provider:
name: libvirt
options:
driver: kvm
lint: |
set -e
yamllint -c ../../../.yamllint .
platforms:
- name: ubuntu18
box: generic/ubuntu1804
cpus: 1
memory: 1024
nested: true
groups:
- kube-master
- name: ubuntu20
box: generic/ubuntu2004
cpus: 1
memory: 1024
nested: true
groups:
- kube-master
provisioner:
name: ansible
env:
ANSIBLE_ROLES_PATH: ../../../../
config_options:
defaults:
callback_whitelist: profile_tasks
lint:
name: ansible-lint
options:
c: ../../../.ansible-lint
inventory:
group_vars:
all:
become: true
verifier:
name: testinfra
lint:
name: flake8

6
roles/container-engine/kata-containers/molecule/default/prepare.yml

@ -0,0 +1,6 @@
---
- name: Prepare
hosts: all
gather_facts: False
roles:
- role: bootstrap-os

30
roles/container-engine/kata-containers/molecule/default/tests/test_default.py

@ -0,0 +1,30 @@
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_pod(host):
image = "docker.io/library/hello-world:latest"
runtime = "io.containerd.kata-qemu.v2"
pull_command = "ctr image pull {}".format(image)
with host.sudo():
cmd = host.command(pull_command)
assert cmd.rc == 0
run_command = "ctr run --runtime {} {} kata1".format(runtime, image)
with host.sudo():
cmd = host.command(run_command)
assert cmd.rc == 0
assert "Hello from Docker!" in cmd.stdout
Loading…
Cancel
Save