From 1339e2bdf756a8d7d56bed4fee06b39a07eabab5 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Wed, 9 Sep 2020 14:12:04 -0400 Subject: [PATCH] combine incluster-integration and separate regular integration scripts (#23) * combine incluster-integration and separate regular integration scripts * Fixup Makefile * make downstream test use venv if docker isn't an option --- .github/workflows/ansible-test.yml | 2 +- Makefile | 20 +++--- ci/downstream.sh | 8 ++- ...n_upstream.sh => incluster_integration.sh} | 0 ci/incluster_integration_downstream.sh | 61 ------------------- 5 files changed, 17 insertions(+), 74 deletions(-) rename ci/{incluster_integration_upstream.sh => incluster_integration.sh} (100%) delete mode 100755 ci/incluster_integration_downstream.sh diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 75426c1..95a053c 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -51,7 +51,7 @@ jobs: # The docker container has all the pinned dependencies that are required. # Explicity specify the version of Python we want to test - name: Run sanity tests - run: make test-sanity TEST_ARGS='--python ${{ matrix.python }}' + run: make upstream-test-sanity TEST_ARGS='--python ${{ matrix.python }}' working-directory: ./ansible_collections/community/okd ### diff --git a/Makefile b/Makefile index a9b22e4..5175ba5 100644 --- a/Makefile +++ b/Makefile @@ -20,19 +20,18 @@ install-kubernetes-src: install: build install-kubernetes-src ansible-galaxy collection install -p ansible_collections community-okd-$(VERSION).tar.gz -test-sanity: install - cd ansible_collections/community/okd && ansible-test sanity --exclude ci/ -v $(SANITY_TEST_ARGS) +test-integration-incluster: + ./ci/incluster_integration.sh -test-integration: install +test-sanity: upstream-test-sanity downstream-test-sanity + +test-integration: upstream-test-integration downstream-test-integration + +upstream-test-integration: install molecule test -test-integration-incluster: test-integration-incluster-upstream test-integration-incluster-downstream - -test-integration-incluster-upstream: - ./ci/incluster_integration_upstream.sh - -test-integration-incluster-downstream: - ./ci/incluster_integration_downstream.sh +upstream-test-sanity: install + cd ansible_collections/community/okd && ansible-test sanity --exclude ci/ -v $(SANITY_TEST_ARGS) downstream-test-sanity: ./ci/downstream.sh -s @@ -42,4 +41,3 @@ downstream-test-integration: downstream-build: ./ci/downstream.sh -b - diff --git a/ci/downstream.sh b/ci/downstream.sh index 322a47e..9d820c2 100755 --- a/ci/downstream.sh +++ b/ci/downstream.sh @@ -170,7 +170,13 @@ f_test_sanity_option() ## Can't do this because the upstream community.kubernetes dependency logic ## is bound as a Makefile dep to the test-sanity target #SANITY_TEST_ARGS="--docker --color --python 3.6" make test-sanity - ansible-test sanity --docker -v --exclude ci/ --color --python 3.6 + # Run tests in docker if available, venv otherwise + if command -v docker &> /dev/null + then + ansible-test sanity --docker -v --exclude ci/ --color --python 3.6 + else + ansible-test sanity --venv -v --exclude ci/ --color --python 3.6 + fi popd || return f_cleanup } diff --git a/ci/incluster_integration_upstream.sh b/ci/incluster_integration.sh similarity index 100% rename from ci/incluster_integration_upstream.sh rename to ci/incluster_integration.sh diff --git a/ci/incluster_integration_downstream.sh b/ci/incluster_integration_downstream.sh deleted file mode 100755 index 920c7ea..0000000 --- a/ci/incluster_integration_downstream.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -set -x - -# IMAGE_FORMAT is in the form $registry/$org/$image:$$component, ie -# quay.io/openshift/release:$component -# To test with your own image, build and push the test image -# (using the Dockerfile in ci/Dockerfile) -# and set the IMAGE_FORMAT environment variable so that it properly -# resolves to your image. For example, quay.io/mynamespace/$component -# would resolve to quay.io/mynamespace/molecule-test-runner -component='molecule-test-runner' -eval IMAGE=$IMAGE_FORMAT - -PULL_POLICY=${PULL_POLICY:-IfNotPresent} - -echo "Deleting test job if it exists" -oc delete job molecule-integration-test --wait --ignore-not-found - -echo "Creating molecule test job" -cat << EOF | oc create -f - ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: molecule-integration-test -spec: - template: - spec: - containers: - - name: test-runner - image: ${IMAGE} - imagePullPolicy: ${PULL_POLICY} - command: - - make - - downstream-test-integration - restartPolicy: Never - backoffLimit: 2 - completions: 1 - parallelism: 1 -EOF - -function wait_for_success { - oc wait --for=condition=complete job/molecule-integration-test --timeout 5m - echo "Molecule integration tests ran successfully" - exit 0 -} - -function wait_for_failure { - oc wait --for=condition=failed job/molecule-integration-test --timeout 5m - oc logs job/molecule-integration-test - echo "Molecule integration tests failed, see logs for more information..." - exit 1 -} - -# Ensure the child processes are killed -trap 'kill -SIGTERM 0' SIGINT EXIT - -echo "Waiting for test job to complete" -wait_for_success & -wait_for_failure