-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kuttl] Add test for OVN db cluster pod deletions
test steps: 1. stand up a 3 replicas ovn db cluster (both nb & sb). 2. confirm pods are all up. 3. confirm that the pods established the mesh. 4. delete all pods. 5. check that new pods are respawned. 6. check that they re-established the mesh with the correct number of pods. related Jira: OSPRH-6135
- Loading branch information
Showing
13 changed files
with
196 additions
and
0 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,61 @@ | ||
#!/bin/bash | ||
|
||
# Check arguments | ||
if [ $# -lt 2 ]; then | ||
echo "Usage: $0 <db-type> <num-pods>" | ||
exit 1 | ||
fi | ||
|
||
# arguments: db-type: {nb, sb}, num-pods | ||
DB_TYPE="$1" | ||
NUM_PODS="$2" | ||
POD_PREFIX="ovsdbserver-${DB_TYPE}" | ||
CTL_FILE="ovn${DB_TYPE}_db.ctl" | ||
if [ "$DB_TYPE" == "nb" ]; then | ||
DB_NAME="OVN_Northbound" | ||
elif [ "$DB_TYPE" == "sb" ]; then | ||
DB_NAME="OVN_Southbound" | ||
fi | ||
|
||
declare -a pods | ||
for i in $(seq 0 $((NUM_PODS-1))); do | ||
pods+=("${POD_PREFIX}-${i}") | ||
done | ||
|
||
# Check each pod | ||
for i in $(seq 0 $((NUM_PODS-1))); do | ||
pod="${POD_PREFIX}-${i}" | ||
pods+=("$pod") | ||
echo "Checking $pod" | ||
# Execute command and capture output | ||
|
||
output=$(oc exec $pod -n $NAMESPACE -- bash -c "OVS_RUNDIR=/tmp ovs-appctl -t /tmp/$CTL_FILE cluster/status $DB_NAME") | ||
|
||
# Example of part of output string that needs parsing: | ||
# Status: cluster member | ||
# Connections: ->0000 ->5476 <-5476 <-36cf | ||
# Disconnections: 0 | ||
# Servers: | ||
# 36cf (36cf at ssl:ovsdbserver-nb-0.ovsdbserver-nb.openstack.svc.cluster.local:6643) last msg 590 ms ago | ||
# 85de (85de at ssl:ovsdbserver-nb-2.ovsdbserver-nb.openstack.svc.cluster.local:6643) (self) | ||
# 5476 (5476 at ssl:ovsdbserver-nb-1.ovsdbserver-nb.openstack.svc.cluster.local:6643) last msg 12063993 ms ago | ||
|
||
# Check if the pod is a cluster member and all pods are mentioned in the connections | ||
is_cluster_member=$(echo "$output" | grep -q "Status: cluster member"; echo $?) | ||
|
||
all_pods_mentioned=true | ||
|
||
for server in "${pods[@]}"; do | ||
echo "Checking if $server is mentioned in the output" | ||
if ! echo "$output" | grep -q "$server"; then | ||
all_pods_mentioned=false | ||
break | ||
fi | ||
done | ||
done | ||
|
||
if [ $is_cluster_member -ne 0 ] || [ "$all_pods_mentioned" = false ]; then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |
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 @@ | ||
../../common/assert_sample_deployment.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 @@ | ||
../../common/deploy_ovn.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,27 @@ | ||
# | ||
# Check for: | ||
# | ||
# - 1 OVNDBCluster CR | ||
# - 3 Pods for OVNDBCluster nb CR | ||
# | ||
|
||
apiVersion: ovn.openstack.org/v1beta1 | ||
kind: OVNDBCluster | ||
metadata: | ||
finalizers: | ||
- OVNDBCluster | ||
name: ovndbcluster-nb-sample | ||
spec: | ||
replicas: 3 | ||
status: | ||
readyCount: 3 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: ovsdbserver-nb | ||
spec: | ||
replicas: 3 | ||
status: | ||
availableReplicas: 3 | ||
--- |
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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc patch OVNDBCluster -n $NAMESPACE ovndbcluster-nb-sample --type='json' -p='[{"op": "replace", "path": "/spec/replicas", "value":3}]' |
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,27 @@ | ||
# | ||
# Check for: | ||
# | ||
# - 1 OVNDBCluster CR | ||
# - 3 Pods for OVNDBCluster sb CR | ||
# | ||
|
||
apiVersion: ovn.openstack.org/v1beta1 | ||
kind: OVNDBCluster | ||
metadata: | ||
finalizers: | ||
- OVNDBCluster | ||
name: ovndbcluster-sb-sample | ||
spec: | ||
replicas: 3 | ||
status: | ||
readyCount: 3 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: ovsdbserver-sb | ||
spec: | ||
replicas: 3 | ||
status: | ||
availableReplicas: 3 | ||
--- |
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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc patch OVNDBCluster -n $NAMESPACE ovndbcluster-sb-sample --type='json' -p='[{"op": "replace", "path": "/spec/replicas", "value":3}]' |
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: TestAssert | ||
commands: | ||
- script: | | ||
$OVN_KUTTL_DIR/../common/scripts/check_cluster_status.sh | ||
test $? -eq 0 |
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,46 @@ | ||
# | ||
# Check for: | ||
# | ||
# - 1 OVNDBCluster CR | ||
# - 3 Pods for OVNDBCluster CR | ||
# | ||
|
||
apiVersion: ovn.openstack.org/v1beta1 | ||
kind: OVNDBCluster | ||
metadata: | ||
finalizers: | ||
- OVNDBCluster | ||
name: ovndbcluster-nb-sample | ||
spec: | ||
replicas: 3 | ||
status: | ||
readyCount: 3 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: ovsdbserver-nb | ||
spec: | ||
replicas: 3 | ||
status: | ||
availableReplicas: 3 | ||
--- | ||
apiVersion: ovn.openstack.org/v1beta1 | ||
kind: OVNDBCluster | ||
metadata: | ||
finalizers: | ||
- OVNDBCluster | ||
name: ovndbcluster-sb-sample | ||
spec: | ||
replicas: 3 | ||
status: | ||
readyCount: 3 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: ovsdbserver-sb | ||
spec: | ||
replicas: 3 | ||
status: | ||
availableReplicas: 3 |
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: | | ||
oc delete pods -l app=ovsdbserver-nb | ||
oc delete pods -l app=ovsdbserver-sb |
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,9 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- script: | | ||
$OVN_KUTTL_DIR/../common/scripts/check_cluster_status.sh nb 3 | ||
test $? -eq 0 | ||
- script: | | ||
$OVN_KUTTL_DIR/../common/scripts/check_cluster_status.sh sb 3 | ||
test $? -eq 0 |
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 @@ | ||
../../common/cleanup-ovn.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 @@ | ||
../../common/errors_cleanup_ovn.yaml |