-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch enhances Kuttl coverage by adding the following tests: * Scale up all Designate services * Scale down all Designate services * Scale up again all Designate services * Scale down to 0 all Designate services The tests will assert the Bind9 & Mdns predictable IPs and generated pools.yaml file were changed accordingly (except for the scale down to 0)
- Loading branch information
1 parent
b8784e9
commit 4d52b98
Showing
17 changed files
with
537 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
# | ||
# This is a base script which will verify the pools.yaml generated file. | ||
# | ||
# Get the ConfigMap content | ||
NUM_OF_SERVICES=$1 | ||
EXPECTED_IPS_NUM=$((NUM_OF_SERVICES * 2)) | ||
config_content=$(oc get -n $NAMESPACE configmap designate-pools-yaml-config-map -o jsonpath='{.data.pools-yaml-content}') | ||
|
||
# Validate pools.yaml config map YAML structure | ||
if ! yq eval '.' <<< "$config_content" &> /dev/null; then | ||
echo "Invalid YAML structure" | ||
exit 1 | ||
fi | ||
|
||
# Assert pool's name | ||
if [ "$(echo "$config_content" | yq eval '.[0].name' -)" != "default" ]; then | ||
echo "Pool name is not 'default'" | ||
exit 1 | ||
fi | ||
|
||
# Assert pool's NS records | ||
if [ "$(echo "$config_content" | yq eval '.[0].ns_records[0].hostname' -)" != "ns1.example.com." ]; then | ||
echo "First NS record hostname is incorrect" | ||
exit 1 | ||
fi | ||
if [ "$(echo "$config_content" | yq eval '.[0].ns_records[1].hostname' -)" != "ns2.example.com." ]; then | ||
echo "Second NS record hostname is incorrect" | ||
exit 1 | ||
fi | ||
|
||
# Check nameserver IPs | ||
nameserver_ips=$(echo "$config_content" | yq eval '.[0].nameservers[].host' -) | ||
for ip in $nameserver_ips; do | ||
if [[ ! $ip =~ ^172\.28\.0\.[0-9]+$ ]]; then | ||
echo "Invalid nameserver IP format: $ip" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check master IPs | ||
master_ips=$(echo "$config_content" | yq eval '.[0].targets[].masters[].host' -) | ||
for ip in $master_ips; do | ||
if [[ ! $ip =~ ^172\.28\.0\.[0-9]+$ ]]; then | ||
echo "Invalid master IP format: $ip" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check target.option IPs | ||
target_ips=$(echo "$config_content" | yq eval '.[0].targets[].options.host' -) | ||
rndc_ips=$(echo "$config_content" | yq eval '.[0].targets[].options.rndc_host' -) | ||
for ip in $target_ips $rndc_ips; do | ||
if [[ ! $ip =~ ^172\.28\.0\.[0-9]+$ ]]; then | ||
echo "Invalid target/rndc IP format: $ip" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Count total unique IPs | ||
all_ips=$(echo "$config_content" | yq eval ' | ||
.[0].nameservers[].host, | ||
.[0].targets[].masters[].host, | ||
.[0].targets[].options.host, | ||
.[0].targets[].options.rndc_host' - | sort -u) | ||
unique_ip_count=$(echo "$all_ips" | wc -l) | ||
if [ "$unique_ip_count" -ne $EXPECTED_IPS_NUM ]; then | ||
echo "Expected $EXPECTED_IPS_NUM unique IPs, found $unique_ip_count" | ||
exit 1 | ||
fi | ||
|
||
# Verify port numbers | ||
nameserver_ports=$(echo "$config_content" | yq eval '.[0].nameservers[].port' -) | ||
for port in $nameserver_ports; do | ||
if [ "$port" -ne 53 ]; then | ||
echo "Invalid nameserver port: $port" | ||
exit 1 | ||
fi | ||
done | ||
master_ports=$(echo "$config_content" | yq eval '.[0].targets[].masters[].port' -) | ||
for port in $master_ports; do | ||
if [ "$port" -ne 5354 ]; then | ||
echo "Invalid master port: $port" | ||
exit 1 | ||
fi | ||
done | ||
rndc_ports=$(echo "$config_content" | yq eval '.[0].targets[].options.rndc_port' -) | ||
for port in $rndc_ports; do | ||
if [ "$port" -ne 953 ]; then | ||
echo "Invalid rndc port: $port" | ||
exit 1 | ||
fi | ||
done | ||
echo "pools.yaml generated file was verified successfully" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
# | ||
# This is a base script which will verify Bind9 & Mdns predictable IPs. | ||
# | ||
# Check Bind9 predictable IPs configmap | ||
NUM_OF_SERVICES=$1 | ||
bind_ips=$(oc get -n $NAMESPACE configmap designate-bind-ip-map -o json | jq -r '.data | values[]') | ||
if [ $(echo "$bind_ips" | wc -l) -ne ${NUM_OF_SERVICES} ]; then | ||
echo "Expected ${NUM_OF_SERVICES} bind addresses, found $(echo "$bind_ips" | wc -l)" | ||
exit 1 | ||
fi | ||
for ip in $bind_ips; do | ||
if [[ ! $ip =~ ^172\.28\.0\.[0-9]+$ ]]; then | ||
echo "Invalid bind IP format: $ip" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check Mdns predictable IPs configmap | ||
mdns_ips=$(oc get -n $NAMESPACE configmap designate-mdns-ip-map -o json | jq -r '.data | values[]') | ||
if [ $(echo "$mdns_ips" | wc -l) -ne ${NUM_OF_SERVICES} ]; then | ||
echo "Expected ${NUM_OF_SERVICES} mdns addresses, found $(echo "$mdns_ips" | wc -l)" | ||
exit 1 | ||
fi | ||
for ip in $mdns_ips; do | ||
if [[ ! $ip =~ ^172\.28\.0\.[0-9]+$ ]]; then | ||
echo "Invalid mdns IP format: $ip" | ||
exit 1 | ||
fi | ||
done | ||
echo "Bind9 & Mdns predictable IPs were verified successfully" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
SVC_REPLICA_COUNT=3 | ||
for svc in API Backendbind9 Central Mdns Producer Unbound Worker; do oc patch designate -n $NAMESPACE designate --type='json' -p='[{"op": "replace", "path": "/spec/designate'"${svc}"'/replicas", "value":'"${SVC_REPLICA_COUNT}"'}]'; done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/kuttl/tests/designate_scale/03-scale-down-designate.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
SVC_REPLICA_COUNT=1 | ||
for svc in API Backendbind9 Central Mdns Producer Unbound Worker; do oc patch designate -n $NAMESPACE designate --type='json' -p='[{"op": "replace", "path": "/spec/designate'"${svc}"'/replicas", "value":'"${SVC_REPLICA_COUNT}"'}]'; done |
5 changes: 0 additions & 5 deletions
5
tests/kuttl/tests/designate_scale/03-scale-down-designateapi.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.