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
This commit is contained in:
Fabian von Feilitzsch
2020-09-09 14:12:04 -04:00
committed by GitHub
parent 80ae2e6b1e
commit 1339e2bdf7
5 changed files with 17 additions and 74 deletions

View File

@@ -51,7 +51,7 @@ jobs:
# The docker container has all the pinned dependencies that are required. # The docker container has all the pinned dependencies that are required.
# Explicity specify the version of Python we want to test # Explicity specify the version of Python we want to test
- name: Run sanity tests - 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 working-directory: ./ansible_collections/community/okd
### ###

View File

@@ -20,19 +20,18 @@ install-kubernetes-src:
install: build install-kubernetes-src install: build install-kubernetes-src
ansible-galaxy collection install -p ansible_collections community-okd-$(VERSION).tar.gz ansible-galaxy collection install -p ansible_collections community-okd-$(VERSION).tar.gz
test-sanity: install test-integration-incluster:
cd ansible_collections/community/okd && ansible-test sanity --exclude ci/ -v $(SANITY_TEST_ARGS) ./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 molecule test
test-integration-incluster: test-integration-incluster-upstream test-integration-incluster-downstream upstream-test-sanity: install
cd ansible_collections/community/okd && ansible-test sanity --exclude ci/ -v $(SANITY_TEST_ARGS)
test-integration-incluster-upstream:
./ci/incluster_integration_upstream.sh
test-integration-incluster-downstream:
./ci/incluster_integration_downstream.sh
downstream-test-sanity: downstream-test-sanity:
./ci/downstream.sh -s ./ci/downstream.sh -s
@@ -42,4 +41,3 @@ downstream-test-integration:
downstream-build: downstream-build:
./ci/downstream.sh -b ./ci/downstream.sh -b

View File

@@ -170,7 +170,13 @@ f_test_sanity_option()
## Can't do this because the upstream community.kubernetes dependency logic ## Can't do this because the upstream community.kubernetes dependency logic
## is bound as a Makefile dep to the test-sanity target ## is bound as a Makefile dep to the test-sanity target
#SANITY_TEST_ARGS="--docker --color --python 3.6" make test-sanity #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 popd || return
f_cleanup f_cleanup
} }

View File

@@ -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