Skip to content

Commit

Permalink
Support customization in test-e2e-ansible-molecule
Browse files Browse the repository at this point in the history
Signed-off-by: arkadeepsen <[email protected]>
  • Loading branch information
arkadeepsen committed Sep 23, 2024
1 parent d32e1b1 commit f59aaf6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,14 @@ test-e2e-ansible:: image/ansible-operator test-e2e-ansible-run ## Run Ansible e2
test-e2e-ansible-run:
go test ./test/e2e/ansible -v -ginkgo.v

test-e2e-ansible-molecule:: install dev-install image/ansible-operator ## Run molecule-based Ansible e2e tests
test-e2e-ansible-molecule:: install dev-install image/ansible-operator test-e2e-ansible-molecule-generate test-e2e-ansible-molecule-run ## Run molecule-based Ansible e2e tests

.PHONY: test-e2e-ansible-molecule-generate
test-e2e-ansible-molecule-generate:
go run ./hack/generate/samples/molecule/generate.go

.PHONY: test-e2e-ansible-molecule-run
test-e2e-ansible-molecule-run:
./hack/tests/e2e-ansible-molecule.sh

## Location to install dependencies to
Expand Down
42 changes: 28 additions & 14 deletions hack/tests/e2e-ansible-molecule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,27 @@ ROOTDIR="$(pwd)"
cp -r $ROOTDIR/testdata/ansible/memcached-molecule-operator/ $TMPDIR/memcached-molecule-operator
cp -r $ROOTDIR/testdata/ansible/advanced-molecule-operator/ $TMPDIR/advanced-molecule-operator

pushd $TMPDIR/memcached-molecule-operator
# Skip Kind test with memcached-molecule-operator if ADVANCED_MOLECULE_OPERATOR_IMAGE has a value.
if [ -z "${ADVANCED_MOLECULE_OPERATOR_IMAGE-}" ] ; then
pushd $TMPDIR/memcached-molecule-operator

header_text "Running Kind test with memcached-molecule-operator"
make kustomize
if [ -f ./bin/kustomize ] ; then
KUSTOMIZE="$(realpath ./bin/kustomize)"
else
KUSTOMIZE="$(which kustomize)"
header_text "Running Kind test with memcached-molecule-operator"
make kustomize
if [ -f ./bin/kustomize ] ; then
KUSTOMIZE="$(realpath ./bin/kustomize)"
else
KUSTOMIZE="$(which kustomize)"
fi
KUSTOMIZE_PATH=${KUSTOMIZE} TEST_OPERATOR_NAMESPACE=default molecule test -s kind
popd
fi
KUSTOMIZE_PATH=${KUSTOMIZE} TEST_OPERATOR_NAMESPACE=default molecule test -s kind
popd

header_text "Running Default test with advanced-molecule-operator"

make test-e2e-setup
# Skip creation of Kind cluster if ADVANCED_MOLECULE_OPERATOR_IMAGE has a value.
if [ -z "${ADVANCED_MOLECULE_OPERATOR_IMAGE-}" ] ; then
make test-e2e-setup
fi
pushd $TMPDIR/advanced-molecule-operator

make kustomize
Expand All @@ -64,8 +70,16 @@ else
KUSTOMIZE="$(which kustomize)"
fi

DEST_IMAGE="quay.io/example/advanced-molecule-operator:v0.0.1"
docker build -t "$DEST_IMAGE" --no-cache .
load_image_if_kind "$DEST_IMAGE"
KUSTOMIZE_PATH=$KUSTOMIZE OPERATOR_PULL_POLICY=Never OPERATOR_IMAGE=${DEST_IMAGE} TEST_OPERATOR_NAMESPACE=osdk-test molecule test
# Check if ADVANCED_MOLECULE_OPERATOR_IMAGE has value or not. If it doesn't have a value then proceed with the test
# using a Kind cluster, otherwise proceed with the test without the Kind cluster.
if [ -z "${ADVANCED_MOLECULE_OPERATOR_IMAGE-}" ] ; then
DEST_IMAGE="quay.io/example/advanced-molecule-operator:v0.0.1"
docker build -t "$DEST_IMAGE" --no-cache .
load_image_if_kind "$DEST_IMAGE"
IMAGE_PULL_POLICY="Never"
else
DEST_IMAGE=${ADVANCED_MOLECULE_OPERATOR_IMAGE}
IMAGE_PULL_POLICY="IfNotPresent"
fi
KUSTOMIZE_PATH=$KUSTOMIZE OPERATOR_PULL_POLICY=${IMAGE_PULL_POLICY} OPERATOR_IMAGE=${DEST_IMAGE} TEST_OPERATOR_NAMESPACE=osdk-test molecule test
popd

0 comments on commit f59aaf6

Please sign in to comment.