From a618aa1ff1dd7be596b27711772c8f1bfec0de3b Mon Sep 17 00:00:00 2001 From: David Cheung Date: Wed, 18 Oct 2023 19:58:50 +0000 Subject: [PATCH] Add ingress-internal and ingress-external tests. * Add test scripts for ingress-internal and ingress-external. --- .../ingress-external-basic/cleanup.sh | 20 +++++++++- .../ingress-external-basic/run-test.sh | 13 +++++- .../ingress-external-basic/setup.sh | 12 +++++- .../ingress-internal-basic/cleanup.sh | 40 +++++++++++++++++++ .../ingress-internal-basic/run-test.sh | 33 +++++++++++++++ .../ingress-internal-basic/setup.sh | 33 +++++++++++++++ 6 files changed, 148 insertions(+), 3 deletions(-) mode change 100644 => 100755 ingress/single-cluster/ingress-external-basic/run-test.sh create mode 100755 ingress/single-cluster/ingress-internal-basic/cleanup.sh create mode 100755 ingress/single-cluster/ingress-internal-basic/run-test.sh create mode 100755 ingress/single-cluster/ingress-internal-basic/setup.sh diff --git a/ingress/single-cluster/ingress-external-basic/cleanup.sh b/ingress/single-cluster/ingress-external-basic/cleanup.sh index 18732a86..4393d43a 100755 --- a/ingress/single-cluster/ingress-external-basic/cleanup.sh +++ b/ingress/single-cluster/ingress-external-basic/cleanup.sh @@ -19,4 +19,22 @@ set -o nounset; set -o pipefail; set -o xtrace; -echo "Running external basic cleanup." +source ./test/helper.sh +test_name="ingress-external-basic" +context=$(get_context "${test_name}") + +if [[ ! -z "${context}" ]]; then + ingress_name="foo-external" + fr=$(get_forwarding_rule "${ingress_name}" "${test_name}" "${context}") + thp=$(get_target_http_proxy "${ingress_name}" "${test_name}" "${context}") + thsp=$(get_target_https_proxy "${ingress_name}" "${test_name}" "${context}") + um=$(get_url_map "${ingress_name}" "${test_name}" "${context}") + backends=$(get_backends "${ingress_name}" "${test_name}" "${context}") + negs=$(get_negs "${context}") + + kubectl --context "${context}" delete -f ingress/single-cluster/ingress-external-basic/external-ingress-basic.yaml -n "${test_name}" || true + wait_for_glbc_deletion "${fr}" "${thp}" "${thsp}" "${um}" "${backends}" "${negs}" + kubectl --context "${context}" delete namespace "${test_name}" || true +fi + +cleanup_gke_basic "${test_name}" "${ZONE}" "${REGION}" diff --git a/ingress/single-cluster/ingress-external-basic/run-test.sh b/ingress/single-cluster/ingress-external-basic/run-test.sh old mode 100644 new mode 100755 index e472aaf4..41c418c3 --- a/ingress/single-cluster/ingress-external-basic/run-test.sh +++ b/ingress/single-cluster/ingress-external-basic/run-test.sh @@ -19,4 +19,15 @@ set -o nounset; set -o pipefail; set -o xtrace; -echo "Running external basic test." +source ./test/helper.sh +test_name="ingress-external-basic" +context=$(get_context "${test_name}") + +if [[ -z "${context}" ]]; then + exit 1 +fi + +vip=$(wait_for_ingress_ip "foo-external" "${test_name}" "${context}") + +check_http_status "${vip}" 200 "host: foo.example.com" +check_http_status "${vip}" 404 "host: bar.example.com" diff --git a/ingress/single-cluster/ingress-external-basic/setup.sh b/ingress/single-cluster/ingress-external-basic/setup.sh index 7d37fdfc..251f54a0 100755 --- a/ingress/single-cluster/ingress-external-basic/setup.sh +++ b/ingress/single-cluster/ingress-external-basic/setup.sh @@ -19,4 +19,14 @@ set -o nounset; set -o pipefail; set -o xtrace; -echo "Running external basic setup." +source ./test/helper.sh +test_name="ingress-external-basic" +setup_gke_basic "${test_name}" "${ZONE}" "${REGION}" +context=$(get_context "${test_name}") + +if [[ -z "${context}" ]]; then + exit 1 +fi + +kubectl --context "${context}" create namespace "${test_name}" +kubectl --context "${context}" apply -f ingress/single-cluster/ingress-external-basic/external-ingress-basic.yaml -n "${test_name}" diff --git a/ingress/single-cluster/ingress-internal-basic/cleanup.sh b/ingress/single-cluster/ingress-internal-basic/cleanup.sh new file mode 100755 index 00000000..9f5ee5b4 --- /dev/null +++ b/ingress/single-cluster/ingress-internal-basic/cleanup.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit; +set -o nounset; +set -o pipefail; +set -o xtrace; + +source ./test/helper.sh +test_name="ingress-internal-basic" +context=$(get_context "${test_name}") + +if [[ ! -z "${context}" ]]; then + ingress_name="foo-internal" + fr=$(get_forwarding_rule "${ingress_name}" "${test_name}" "${context}") + thp=$(get_target_http_proxy "${ingress_name}" "${test_name}" "${context}") + thsp=$(get_target_https_proxy "${ingress_name}" "${test_name}" "${context}") + um=$(get_url_map "${ingress_name}" "${test_name}" "${context}") + backends=$(get_backends "${ingress_name}" "${test_name}" "${context}") + negs=$(get_negs "${context}") + + kubectl --context "${context}" delete -f ingress/single-cluster/ingress-internal-basic/internal-ingress-basic.yaml -n "${test_name}" || true + wait_for_glbc_deletion "${fr}" "${thp}" "${thsp}" "${um}" "${backends}" "${negs}" + kubectl --context "${context}" delete namespace "${test_name}" || true +fi + +cleanup_gke_basic "${test_name}" "${ZONE}" "${REGION}" diff --git a/ingress/single-cluster/ingress-internal-basic/run-test.sh b/ingress/single-cluster/ingress-internal-basic/run-test.sh new file mode 100755 index 00000000..56bb4c4b --- /dev/null +++ b/ingress/single-cluster/ingress-internal-basic/run-test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit; +set -o nounset; +set -o pipefail; +set -o xtrace; + +source ./test/helper.sh +test_name="ingress-internal-basic" +context=$(get_context "${test_name}") + +if [[ -z "${context}" ]]; then + exit 1 +fi + +vip=$(wait_for_ingress_ip "foo-internal" "${test_name}" "${context}") + +check_http_status "${vip}" 200 "host: foo.example.com" "${test_name}" "${ZONE}" +check_http_status "${vip}" 404 "host: bar.example.com" "${test_name}" "${ZONE}" diff --git a/ingress/single-cluster/ingress-internal-basic/setup.sh b/ingress/single-cluster/ingress-internal-basic/setup.sh new file mode 100755 index 00000000..2309695d --- /dev/null +++ b/ingress/single-cluster/ingress-internal-basic/setup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit; +set -o nounset; +set -o pipefail; +set -o xtrace; + +source ./test/helper.sh +test_name="ingress-internal-basic" +setup_gke_basic "${test_name}" "${ZONE}" "${REGION}" +setup_ilb "${test_name}" "${REGION}" +context=$(get_context "${test_name}") + +if [[ -z "${context}" ]]; then + exit 1 +fi + +kubectl --context "${context}" create namespace "${test_name}" +kubectl --context "${context}" apply -f ingress/single-cluster/ingress-internal-basic/internal-ingress-basic.yaml -n "${test_name}"