From 990c09293c2ea45fce697feccc4342212b6a2693 Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Mon, 2 Dec 2019 16:36:07 +0000 Subject: [PATCH 1/2] fix scripts to run in ios --- doc/dev/testing/travis-build.md | 10 ---------- hack/generate/gen-test-framework.sh | 2 +- hack/tests/e2e-ansible-molecule.sh | 12 ++---------- hack/tests/e2e-ansible.sh | 11 ++++++++--- hack/tests/e2e-helm.sh | 6 +++--- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/doc/dev/testing/travis-build.md b/doc/dev/testing/travis-build.md index adf4ed265b7..1923c7b3b6c 100644 --- a/doc/dev/testing/travis-build.md +++ b/doc/dev/testing/travis-build.md @@ -83,16 +83,6 @@ The Go, Ansible, and Helm tests then differ in what tests they run. **NOTE**: All created resources, including the namespace, are deleted using a bash trap when the test finishes -**NOTE** If you are using a MacOSX SO then will be required replace the sed command in the `hack/tests/e2e-ansible-molecule.sh` as the following example. - -```sh -# Use the following sed command to check it on macOsX. -# More info: https://www.mkyong.com/mac/sed-command-hits-undefined-label-error-on-mac-os-x/ -sed -i "" 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile -# The following code is the default used (Not valid for MacOSX) -# sed -i 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile -``` - ### Helm Tests 1. Run [helm e2e tests][helm-e2e]. diff --git a/hack/generate/gen-test-framework.sh b/hack/generate/gen-test-framework.sh index cfa43c0be97..37ffc1090b5 100755 --- a/hack/generate/gen-test-framework.sh +++ b/hack/generate/gen-test-framework.sh @@ -13,7 +13,7 @@ cd test/test-framework # Ensure test-framework is up-to-date with current Go project dependencies. echo "$(../../build/operator-sdk print-deps)" > go.mod -sed -i 's|github.com/operator-framework/operator-sdk\s\+master||g' go.mod +sed -i".bak" -E -e "s|github.com/operator-framework/operator-sdk[[:blank:]]+master||g" go.mod; rm -f go.mod.bak echo -e "\nreplace github.com/operator-framework/operator-sdk => ../../" >> go.mod go mod edit -require "github.com/operator-framework/operator-sdk@v0.0.0" go build ./... diff --git a/hack/tests/e2e-ansible-molecule.sh b/hack/tests/e2e-ansible-molecule.sh index a8451f69dde..8a6aceaec7a 100755 --- a/hack/tests/e2e-ansible-molecule.sh +++ b/hack/tests/e2e-ansible-molecule.sh @@ -46,11 +46,7 @@ cat "$ROOTDIR/test/ansible-memcached/watches-v1-kind.yaml" >> memcached-operator # Test local pushd memcached-operator -# Use the following sed command to check it on macOsX. -# More info: https://www.mkyong.com/mac/sed-command-hits-undefined-label-error-on-mac-os-x/ -# sed -i "" 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile -# The following code is the default used (Not valid for MacOSX) -sed -i 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile +sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/ansible-operator)(:.*)?/\1:dev/g' build/Dockerfile; rm -f build/Dockerfile.bak OPERATORDIR="$(pwd)" TEST_CLUSTER_PORT=24443 operator-sdk test local --namespace default @@ -60,11 +56,7 @@ popd popd pushd "${ROOTDIR}/test/ansible-inventory" -# Use the following sed command to check it on macOsX. -# More info: https://www.mkyong.com/mac/sed-command-hits-undefined-label-error-on-mac-os-x/ -# sed -i "" 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile -# The following code is the default used (Not valid for MacOSX) -sed -i 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile +sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/ansible-operator)(:.*)?/\1:dev/g' build/Dockerfile; rm -f build/Dockerfile.bak TEST_CLUSTER_PORT=24443 operator-sdk test local --namespace default popd diff --git a/hack/tests/e2e-ansible.sh b/hack/tests/e2e-ansible.sh index 71737e639e1..1aaeaf0f99f 100755 --- a/hack/tests/e2e-ansible.sh +++ b/hack/tests/e2e-ansible.sh @@ -145,12 +145,17 @@ cat "$ROOTDIR/test/ansible-memcached/watches-foo-kind.yaml" >> memcached-operato pushd memcached-operator # Add a second Kind to test watching multiple GVKs operator-sdk add crd --kind=Foo --api-version=ansible.example.com/v1alpha1 -sed -i 's|\(FROM quay.io/operator-framework/ansible-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile +sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/ansible-operator)(:.*)?/\1:dev/g' build/Dockerfile; rm -f build/Dockerfile.bak operator-sdk build "$DEST_IMAGE" # If using a kind cluster, load the image into all nodes. load_image_if_kind "$DEST_IMAGE" -sed -i "s|{{ REPLACE_IMAGE }}|$DEST_IMAGE|g" deploy/operator.yaml -sed -i 's|{{ pull_policy.default..Always.. }}|Never|g' deploy/operator.yaml +if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i " " "s|{{ REPLACE_IMAGE }}|$DEST_IMAGE|g" deploy/operator.yaml +else + sed -i "s|{{ REPLACE_IMAGE }}|$DEST_IMAGE|g" deploy/operator.yaml +fi +sed -i".bak" -e 's/{{ pull_policy.default..Always.. }}/Never/g' deploy/operator.yaml; rm -f deploy/operator.yaml.bak + # kind has an issue with certain image registries (ex. redhat's), so use a # different test pod image. METRICS_TEST_IMAGE="fedora:latest" diff --git a/hack/tests/e2e-helm.sh b/hack/tests/e2e-helm.sh index 5fbb1e04ec1..1cf9c555863 100755 --- a/hack/tests/e2e-helm.sh +++ b/hack/tests/e2e-helm.sh @@ -125,12 +125,12 @@ if echo $log | grep -q "failed to generate RBAC rules"; then fi pushd nginx-operator -sed -i 's|\(FROM quay.io/operator-framework/helm-operator\)\(:.*\)\?|\1:dev|g' build/Dockerfile +sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/helm-operator)(:.*)?/\1:dev/g' build/Dockerfile; rm -f build/Dockerfile.bak operator-sdk build "$DEST_IMAGE" # If using a kind cluster, load the image into all nodes. load_image_if_kind "$DEST_IMAGE" -sed -i "s|REPLACE_IMAGE|$DEST_IMAGE|g" deploy/operator.yaml -sed -i 's|Always|Never|g' deploy/operator.yaml +sed -i".bak" -E -e "s|REPLACE_IMAGE|$DEST_IMAGE|g" deploy/operator.yaml; rm -f deploy/operator.yaml.bak +sed -i".bak" -E -e 's|Always|Never|g' deploy/operator.yaml; rm -f deploy/operator.yaml.bak # kind has an issue with certain image registries (ex. redhat's), so use a # different test pod image. METRICS_TEST_IMAGE="fedora:latest" From fa0c9ee694d9090cb5cc048db37a77dc03329b68 Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Mon, 2 Dec 2019 16:37:54 +0000 Subject: [PATCH 2/2] add suggestion on review --- hack/tests/e2e-ansible.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hack/tests/e2e-ansible.sh b/hack/tests/e2e-ansible.sh index 1aaeaf0f99f..068e6f9ffa3 100755 --- a/hack/tests/e2e-ansible.sh +++ b/hack/tests/e2e-ansible.sh @@ -149,13 +149,8 @@ sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/ansible-operator)(:.*)? operator-sdk build "$DEST_IMAGE" # If using a kind cluster, load the image into all nodes. load_image_if_kind "$DEST_IMAGE" -if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i " " "s|{{ REPLACE_IMAGE }}|$DEST_IMAGE|g" deploy/operator.yaml -else - sed -i "s|{{ REPLACE_IMAGE }}|$DEST_IMAGE|g" deploy/operator.yaml -fi -sed -i".bak" -e 's/{{ pull_policy.default..Always.. }}/Never/g' deploy/operator.yaml; rm -f deploy/operator.yaml.bak - +sed -i".bak" -E -e "s|\{\{ REPLACE_IMAGE \}\}|$DEST_IMAGE|g" deploy/operator.yaml; rm -f deploy/operator.yaml.bak +sed -i".bak" -E -e 's|\{\{ pull_policy.default..Always.. \}\}|Never|g' deploy/operator.yaml; rm -f deploy/operator.yaml.bak # kind has an issue with certain image registries (ex. redhat's), so use a # different test pod image. METRICS_TEST_IMAGE="fedora:latest"