Browse Source
Convert CRI-O molecule to ansible verifier
pull/12302/head
Max Gautier
3 months ago
Failed to extract signature
7 changed files with
57 additions and
39 deletions
-
roles/container-engine/cri-o/molecule/default/molecule.yml
-
roles/container-engine/cri-o/molecule/default/tests/test_default.py
-
roles/container-engine/cri-o/molecule/default/verify.yml
-
roles/container-engine/molecule/files/10-mynet.conf
-
roles/container-engine/molecule/templates/container.json.j2
-
roles/container-engine/molecule/templates/sandbox.json.j2
-
roles/container-engine/molecule/test_runtime.yml
|
|
@ -45,4 +45,4 @@ provisioner: |
|
|
|
create: ../../../../../tests/cloud_playbooks/create-kubevirt.yml |
|
|
|
prepare: ../../../molecule/prepare.yml |
|
|
|
verifier: |
|
|
|
name: testinfra |
|
|
|
name: ansible |
|
|
@ -1,35 +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_service(host): |
|
|
|
svc = host.service("crio") |
|
|
|
assert svc.is_running |
|
|
|
assert svc.is_enabled |
|
|
|
|
|
|
|
|
|
|
|
def test_run(host): |
|
|
|
crictl = "/usr/local/bin/crictl" |
|
|
|
path = "unix:///var/run/crio/crio.sock" |
|
|
|
with host.sudo(): |
|
|
|
cmd = host.command(crictl + " --runtime-endpoint " + path + " version") |
|
|
|
assert cmd.rc == 0 |
|
|
|
assert "RuntimeName: cri-o" in cmd.stdout |
|
|
|
|
|
|
|
def test_run_pod(host): |
|
|
|
runtime = "crun" |
|
|
|
|
|
|
|
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/runc1.0.log") |
|
|
|
|
|
|
|
assert log_f.exists |
|
|
|
assert b"Hello from Docker" in log_f.content |
|
|
@ -0,0 +1,11 @@ |
|
|
|
--- |
|
|
|
- name: Test CRI-O cri |
|
|
|
import_playbook: ../../../molecule/test_cri.yml |
|
|
|
vars: |
|
|
|
container_manager: crio |
|
|
|
cri_socket: unix:///var/run/crio/crio.sock |
|
|
|
cri_name: cri-o |
|
|
|
- name: Test running a container with crun |
|
|
|
import_playbook: ../../../molecule/test_runtime.yml |
|
|
|
vars: |
|
|
|
container_runtime: crun |
|
|
@ -1,10 +1,10 @@ |
|
|
|
{ |
|
|
|
"metadata": { |
|
|
|
"name": "runc1" |
|
|
|
"name": "{{ container_runtime }}1" |
|
|
|
}, |
|
|
|
"image": { |
|
|
|
"image": "quay.io/kubespray/hello-world:latest" |
|
|
|
}, |
|
|
|
"log_path": "runc1.0.log", |
|
|
|
"log_path": "{{ container_runtime }}1.0.log", |
|
|
|
"linux": {} |
|
|
|
} |
|
|
@ -1,6 +1,6 @@ |
|
|
|
{ |
|
|
|
"metadata": { |
|
|
|
"name": "runc1", |
|
|
|
"name": "{{ container_runtime }}1", |
|
|
|
"namespace": "default", |
|
|
|
"attempt": 1, |
|
|
|
"uid": "hdishd83djaidwnduwk28bcsb" |
|
|
@ -0,0 +1,42 @@ |
|
|
|
--- |
|
|
|
- name: Test container runtime |
|
|
|
hosts: all |
|
|
|
gather_facts: false |
|
|
|
become: true |
|
|
|
roles: |
|
|
|
- role: ../../kubespray_defaults |
|
|
|
tasks: |
|
|
|
- name: Copy test container files |
|
|
|
template: |
|
|
|
src: "{{ item }}.j2" |
|
|
|
dest: "/tmp/{{ item }}" |
|
|
|
owner: root |
|
|
|
mode: "0644" |
|
|
|
loop: |
|
|
|
- container.json |
|
|
|
- sandbox.json |
|
|
|
- name: Check running a container with runtime {{ container_runtime }} |
|
|
|
block: |
|
|
|
- name: Run container |
|
|
|
command: |
|
|
|
argv: |
|
|
|
- "{{ bin_dir }}/crictl" |
|
|
|
- run |
|
|
|
- --with-pull |
|
|
|
- --runtime |
|
|
|
- "{{ container_runtime }}" |
|
|
|
- /tmp/container.json |
|
|
|
- /tmp/sandbox.json |
|
|
|
- name: Check log file |
|
|
|
slurp: |
|
|
|
src: "/tmp/{{ container_runtime }}1.0.log" |
|
|
|
register: log_file |
|
|
|
failed_when: > |
|
|
|
log_file is failed or |
|
|
|
'Hello from Docker' not in (log_file.content | b64decode) |
|
|
|
rescue: |
|
|
|
- name: Display container manager config on error |
|
|
|
command: "{{ bin_dir }}/crictl info" |
|
|
|
- name: Check container manager logs |
|
|
|
command: journalctl -u {{ container_manager }} |
|
|
|
failed_when: true |