Add molecule tests to containerd role (#6037)

pull/6048/head
Maxime Guyot 2020-04-29 18:08:25 +02:00 committed by GitHub
parent db5f83f8c9
commit e4c820c35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 3 deletions

View File

@ -0,0 +1,31 @@
---
driver:
name: vagrant
provider:
name: libvirt
lint:
name: yamllint
options:
config-file: ../../../.yamllint
platforms:
- name: ubuntu18
box: generic/ubuntu1804
cpus: 2
memory: 1024
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
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
become: true
roles:
- role: kubespray-defaults
- role: containerd

View File

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

View File

@ -0,0 +1,21 @@
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("containerd")
assert svc.is_running
assert svc.is_enabled
def test_run(host):
crictl = "/usr/local/bin/crictl"
path = "unix:///var/run/containerd/containerd.sock"
with host.sudo():
cmd = host.command(crictl + " --runtime-endpoint " + path + " version")
assert cmd.rc == 0
assert "RuntimeName: containerd" in cmd.stdout

View File

@ -21,7 +21,13 @@
group: no
delegate_to: "{{ inventory_hostname }}"
- name: Get crictl completion
shell: "{{ bin_dir }}/crictl completion"
changed_when: False
register: cri_completion
- name: Install crictl completion
shell: "{{ bin_dir }}/crictl completion >/etc/bash_completion.d/crictl"
ignore_errors: True
when: ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"]
copy:
dest: /etc/bash_completion.d/crictl
content: "{{ cri_completion.stdout }}"
become: True