diff --git a/Makefile b/Makefile index 080194e..7373a34 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION = 0.1.0 # To run sanity tests in a venv, set SANITY_TEST_ARGS to '--venv' -SANITY_TEST_ARGS ?= '--docker --color' +SANITY_TEST_ARGS ?= --docker --color clean: rm -f community-okd-$(VERSION).tar.gz @@ -19,3 +19,6 @@ test-sanity: install test-integration: install molecule test + +test-integration-incluster: install + ANSIBLE_COLLECTIONS_PATHS=$(shell pwd) ansible-playbook ci/incluster_integration.yml diff --git a/ci/incluster_integration.yml b/ci/incluster_integration.yml new file mode 100644 index 0000000..49ac231 --- /dev/null +++ b/ci/incluster_integration.yml @@ -0,0 +1,66 @@ +--- +- hosts: localhost + connection: local + gather_facts: no + + vars: + namespace: default + component: molecule-test-runner + pull_policy: IfNotPresent + # This will be in the form $registry/$org/$image:$$component, ie + # quay.io/openshift/release:$component + image_format: '{{ lookup("env", "IMAGE_FORMAT") }}' + image: '{{ image_format | replace("$component", component) }}' + + tasks: + - name: Ensure clean environment + community.okd.k8s: + api_version: v1 + kind: Pod + name: molecule-integration-test + namespace: '{{ namespace }}' + state: absent + wait: yes + + - name: Create molecule test pod + community.okd.k8s: + definition: + apiVersion: v1 + kind: Pod + metadata: + name: molecule-integration-test + namespace: '{{ namespace }}' + spec: + containers: + - name: test-runner + image: '{{ image }}' + imagePullPolicy: '{{ pull_policy }}' + command: + - make + - test-integration + restartPolicy: Never + + - name: Wait for Pod to finish + community.kubernetes.k8s_info: + api_version: v1 + kind: Pod + name: molecule-integration-test + namespace: '{{ namespace }}' + register: test_pod + until: test_pod.resources.0.status.phase in ['Succeeded', 'Failed'] + delay: 6 + retries: 10 + + - name: Gather Pod Logs + community.kubernetes.k8s_log: + name: molecule-integration-test + namespace: '{{ namespace }}' + register: pod_log + + - name: Exit with error on Pod failure + fail: + msg: | + Molecule interation tests failed, see logs for more info + + {{ pod_log.log }} + when: test_pod.resources.0.status.phase == 'Failed'