Skip to content

Commit

Permalink
Add ingress-internal and ingress-external tests.
Browse files Browse the repository at this point in the history
* Add test scripts for ingress-internal and ingress-external.
  • Loading branch information
sawsa307 committed Oct 26, 2023
1 parent 07a2345 commit a618aa1
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 3 deletions.
20 changes: 19 additions & 1 deletion ingress/single-cluster/ingress-external-basic/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
13 changes: 12 additions & 1 deletion ingress/single-cluster/ingress-external-basic/run-test.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 11 additions & 1 deletion ingress/single-cluster/ingress-external-basic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
40 changes: 40 additions & 0 deletions ingress/single-cluster/ingress-internal-basic/cleanup.sh
Original file line number Diff line number Diff line change
@@ -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}"
33 changes: 33 additions & 0 deletions ingress/single-cluster/ingress-internal-basic/run-test.sh
Original file line number Diff line number Diff line change
@@ -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}"
33 changes: 33 additions & 0 deletions ingress/single-cluster/ingress-internal-basic/setup.sh
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit a618aa1

Please sign in to comment.