Skip to content

Commit 79a0460

Browse files
guessimselim00
authored andcommitted
fix(bootstrap): more test cases for validation
1 parent 6e67c1c commit 79a0460

9 files changed

Lines changed: 88 additions & 5 deletions

templates/test/cases/ipv4-cluster-dns-ip.sh renamed to templates/test/cases/ipv4-cluster-with-cluster-dns-ip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
echo "--> Should return IPv4 DNS Cluster IP when given dns-cluster-ip"
4+
echo "--> Should return IPv4 DNS Cluster IP when --dns-cluster-ip set"
55
exit_code=0
66
expected_cluster_dns="192.168.0.1"
77
/etc/eks/bootstrap.sh \
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "--> Should return default IPv4 DNS Cluster IP if no --dns-cluster-ip set"
5+
exit_code=0
6+
expected_cluster_dns="10.100.0.10"
7+
/etc/eks/bootstrap.sh \
8+
--b64-cluster-ca dGVzdA== \
9+
--apiserver-endpoint http://my-api-endpoint \
10+
--ip-family ipv4 \
11+
ipv4-cluster || exit_code=$?
12+
13+
if [[ ${exit_code} -ne 0 ]]; then
14+
echo "❌ Test Failed: expected a non-zero exit code but got '${exit_code}'"
15+
exit 1
16+
fi
17+
18+
actual_cluster_dns=$(jq -r '.clusterDNS[0]' < /etc/kubernetes/kubelet/kubelet-config.json)
19+
if [[ ${actual_cluster_dns} != "${expected_cluster_dns}" ]]; then
20+
echo "❌ Test Failed: expected clusterDNS IP '${expected_cluster_dns}' but got '${actual_cluster_dns}'"
21+
exit 1
22+
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "--> Should return default IPv4 DNS Cluster IP when --service-ipv4-cidr not set"
5+
exit_code=0
6+
expected_cluster_dns="10.100.0.10"
7+
/etc/eks/bootstrap.sh \
8+
--b64-cluster-ca dGVzdA== \
9+
--apiserver-endpoint http://my-api-endpoint \
10+
--ip-family ipv4 \
11+
ipv4-cluster || exit_code=$?
12+
13+
if [[ ${exit_code} -ne 0 ]]; then
14+
echo "❌ Test Failed: expected a non-zero exit code but got '${exit_code}'"
15+
exit 1
16+
fi
17+
18+
actual_cluster_dns=$(jq -r '.clusterDNS[0]' < /etc/kubernetes/kubelet/kubelet-config.json)
19+
if [[ ${actual_cluster_dns} != "${expected_cluster_dns}" ]]; then
20+
echo "❌ Test Failed: expected clusterDNS IP '${expected_cluster_dns}' but got '${actual_cluster_dns}'"
21+
exit 1
22+
fi
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "--> Should return IPv4 DNS Cluster IP when --service-ipv4-cidr set"
5+
exit_code=0
6+
expected_cluster_dns="192.168.0.10"
7+
/etc/eks/bootstrap.sh \
8+
--b64-cluster-ca dGVzdA== \
9+
--apiserver-endpoint http://my-api-endpoint \
10+
--ip-family ipv4 \
11+
--service-ipv4-cidr 192.168.0.0/16 \
12+
ipv4-cluster || exit_code=$?
13+
14+
if [[ ${exit_code} -ne 0 ]]; then
15+
echo "❌ Test Failed: expected a non-zero exit code but got '${exit_code}'"
16+
exit 1
17+
fi
18+
19+
actual_cluster_dns=$(jq -r '.clusterDNS[0]' < /etc/kubernetes/kubelet/kubelet-config.json)
20+
if [[ ${actual_cluster_dns} != "${expected_cluster_dns}" ]]; then
21+
echo "❌ Test Failed: expected clusterDNS IP '${expected_cluster_dns}' but got '${actual_cluster_dns}'"
22+
exit 1
23+
fi

templates/test/cases/ip-family-service-ipv6-cidr-mismatch.sh renamed to templates/test/cases/ipv4-cluster-with-service-ipv6-cidr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
echo "-> Should fail validation - ip-family mismatch"
4+
echo "-> Should fail validation - IPv4 cluster with mismatch --service-ipv6-cidr set"
55
exit_code=0
66
/etc/eks/bootstrap.sh \
77
--b64-cluster-ca dGVzdA== \

templates/test/cases/ipv6-cluster-dns-ip.sh renamed to templates/test/cases/ipv6-cluster-with-cluster-dns-ip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
echo "-> Should return ipv6 DNS Cluster IP when given dns-cluster-ip"
4+
echo "-> Should return IPv6 DNS Cluster IP when --dns-cluster-ip set"
55
exit_code=0
66
expected_cluster_dns="fe80::2a"
77
/etc/eks/bootstrap.sh \

templates/test/cases/ipv6-ip-family-and-service-ipv6-cidr.sh renamed to templates/test/cases/ipv6-cluster-with-no-service-ipv6-cidr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
echo "-> Should fail w/ \"service-ipv6-cidr must be provided when ip-family is specified as ipv6\""
4+
echo "-> Should fail validation - IPv6 cluster with no --service-ipv6-cidr set"
55
exit_code=0
66
/etc/eks/bootstrap.sh \
77
--b64-cluster-ca dGVzdA== \
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "-> Should fail validation - IPv6 cluster with mismatch --service-ipv4-cidr set"
5+
exit_code=0
6+
/etc/eks/bootstrap.sh \
7+
--b64-cluster-ca dGVzdA== \
8+
--apiserver-endpoint http://my-api-endpoint \
9+
--ip-family ipv6 \
10+
--service-ipv4-cidr 192.168.0.0/24 \
11+
ipv4-cluster || exit_code=$?
12+
13+
if [[ ${exit_code} -eq 0 ]]; then
14+
echo "❌ Test Failed: expected a non-zero exit code but got '${exit_code}'"
15+
exit 1
16+
fi

templates/test/cases/ipv6-dns-cluster-ip-given-service-ipv6-cidr.sh renamed to templates/test/cases/ipv6-cluster-with-service-ipv6-cidr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
echo "-> Should return IPv6 DNS cluster IP when given service-ipv6-cidr"
4+
echo "-> Should return IPv6 DNS cluster IP when --service-ipv6-cidr set"
55
exit_code=0
66
TEMP_DIR=$(mktemp -d)
77
/etc/eks/bootstrap.sh \

0 commit comments

Comments
 (0)