Skip to content

Commit

Permalink
fix(ci): add openebs namespace in ci
Browse files Browse the repository at this point in the history
Signed-off-by: sinhaashish <[email protected]>
  • Loading branch information
sinhaashish committed Aug 29, 2024
1 parent 6c89f42 commit ea8736e
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions ci/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@ set -e

SNAP_CLASS=deploy/sample/zfssnapclass.yaml
TEST_DIR="tests"
OPENEBS_NAMESPACE="openebs"

# Prepare env for running BDD tests
# Minikube is already running
helm install zfs-localpv ./deploy/helm/charts -n "$OPENEBS_NAMESPACE" --create-namespace --set zfsPlugin.pullPolicy=Never --set analytics.enabled=false
helm install zfs-localpv ./deploy/helm/charts -n "openebs" --create-namespace --set zfsPlugin.pullPolicy=Never --set analytics.enabled=false
kubectl apply -f "$SNAP_CLASS"

dumpAgentLogs() {
NR=$1
AgentPOD=$(kubectl get pods -l app=openebs-zfs-node -o jsonpath='{.items[0].metadata.name}' -n openebs)
kubectl describe po "$AgentPOD" -n openebs
AgentPOD=$(kubectl get pods -l app=openebs-zfs-node -o jsonpath='{.items[0].metadata.name}' -n "openebs")
kubectl describe po "$AgentPOD" -n "openebs"
printf "\n\n"
kubectl logs --tail="${NR}" "$AgentPOD" -n openebs -c openebs-zfs-plugin
kubectl logs --tail="${NR}" "$AgentPOD" -n "openebs" -c openebs-zfs-plugin
printf "\n\n"
}

dumpControllerLogs() {
NR=$1
ControllerPOD=$(kubectl get pods -l app=openebs-zfs-controller -o jsonpath='{.items[0].metadata.name}' -n openebs)
kubectl describe po "$ControllerPOD" -n openebs
ControllerPOD=$(kubectl get pods -l app=openebs-zfs-controller -o jsonpath='{.items[0].metadata.name}' -n "openebs")
kubectl describe po "$ControllerPOD" -n "openebs"
printf "\n\n"
kubectl logs --tail="${NR}" "$ControllerPOD" -n openebs -c openebs-zfs-plugin
kubectl logs --tail="${NR}" "$ControllerPOD" -n "openebs" -c openebs-zfs-plugin
printf "\n\n"
}


isPodReady(){
echo $1
[ "$(kubectl get po "$1" -o 'jsonpath={.status.conditions[?(@.type=="Ready")].status}' -n openebs)" = 'True' ]
}

Expand All @@ -44,10 +46,13 @@ isDriverReady(){
waitForZFSDriver() {
period=120
interval=1

echo "Ashish"
echo openebs
echo "Fetching pods with label 'role=openebs-zfs' in namespace 'openebs'"
i=0
while [ "$i" -le "$period" ]; do
zfsDriver="$(kubectl get pods -l role=openebs-zfs -o 'jsonpath={.items[*].metadata.name}' -n openebs)"
echo "$zfsDriver"
if isDriverReady "$zfsDriver"; then
return 0
fi
Expand All @@ -70,7 +75,7 @@ runTestSuite() {

cd $TEST_DIR

kubectl get po -n openebs
kubectl get po -n "openebs"

set +e

Expand Down Expand Up @@ -103,10 +108,10 @@ runTestSuite() {
kubectl get sc --all-namespaces -oyaml

echo "get zfs volume details"
kubectl get zfsvolumes.zfs.openebs.io -n openebs -oyaml
kubectl get zfsvolumes.zfs.openebs.io -n "openebs" -oyaml

echo "get zfs snapshot details"
kubectl get zfssnapshots.zfs.openebs.io -n openebs -oyaml
kubectl get zfssnapshots.zfs.openebs.io -n "openebs" -oyaml

exit 1
fi
Expand All @@ -115,17 +120,17 @@ runTestSuite() {
runTestSuite bdd_coverage.txt "!custom-node-id"

prepareCustomNodeIdEnv() {
for node in $(kubectl get nodes -n openebs -o jsonpath='{.items[*].metadata.name}'); do
local zfsNode=$(kubectl get zfsnode -n openebs -o jsonpath="{.items[?(@.metadata.ownerReferences[0].name=='${node}')].metadata.name}")
for node in $(kubectl get nodes -n "openebs" -o jsonpath='{.items[*].metadata.name}'); do
local zfsNode=$(kubectl get zfsnode -n "openebs" -o jsonpath="{.items[?(@.metadata.ownerReferences[0].name=='${node}')].metadata.name}")
echo "Relabeling node ${node} with ${node}-custom-id"
kubectl label node "${node}" openebs.io/nodeid="${node}-custom-id" --overwrite

local nodeDriver=$(kubectl get pods -l name=openebs-zfs-node -o jsonpath="{.items[?(@.spec.nodeName=='${node}')].metadata.name}" -n openebs)
local nodeDriver=$(kubectl get pods -l name=openebs-zfs-node -o jsonpath="{.items[?(@.spec.nodeName=='${node}')].metadata.name}" -n "openebs")
echo "Restarting ${nodeDriver} on ${node} to pick up the new node id"
kubectl delete pod "${nodeDriver}" -n openebs
kubectl delete pod "${nodeDriver}" -n "openebs"

echo "Deleting old zfsnode ${zfsNode}"
kubectl delete zfsnode "${zfsNode}" -n openebs
kubectl delete zfsnode "${zfsNode}" -n "openebs"
done
}

Expand Down

0 comments on commit ea8736e

Please sign in to comment.