Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- source_dir=$(pwd)
- results_file=$(echo $source_dir | sed 's:.*/::')
- test_start=$(date +%Y-%m-%d-%T)
- mkdir $test_start
- echo "\n \n \n $(date +%Y-%m-%d-%T) - Installing CockroachDB via Helm"
- helm install --name cockroachdb stable/cockroachdb
- echo "$(date +%Y-%m-%d-%T) - Started log capture for initialization"
- while [ $(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l) != 3 ]; do \
- kubectl get po -o wide --no-headers | while \
- IFS= read -r line; do echo "$(date) $line"; done \
- >> "./$test_start/startup-$results_file"; done
- echo "$(date +%Y-%m-%d-%T) - All CockroachDB pods are ready"
- echo "$(date +%Y-%m-%d-%T) - Deleting node $delete_node to induce failover test."
- delete_node=$(kubectl get no -o jsonpath="{.items[*].metadata.name}" | awk '{print $NF}')
- group=$(az vm list | grep $delete_node | awk '{print $(NF-1)}')
- az vm delete -n $delete_node -g $group -y
- echo "$(date +%Y-%m-%d-%T) - Watching for one of the pods status to go notready"
- while [ $(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l) -gt 2 ]; do sleep 5; done
- echo "$(date +%Y-%m-%d-%T) - Pod is now failing over and second log to test recovery time has started."
- while [ $(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l) != 3 ]; do \
- kubectl get po -o wide --no-headers | while \
- IFS= read -r line; do echo "$(date) $line"; done \
- >> "./$test_start/failover-$results_file"; done
- echo "$(date +%Y-%m-%d-%T) - Test complete and now we will reset the cluster scale."
- kubectl get po -o wide
- aks_name=$(kubectl config view -o template --template='{{ index . "current-context" }}')
- aks_group=$(az aks list | grep $aks_name | awk '{print $(NF-3)}')
- echo "$(date +%Y-%m-%d-%T) Deleting CockroachDb and all associated Kubernetes objects."
- helm delete cockroachdb --purge
- kubectl delete pvc --all
- kubectl delete pv --all
- echo "$(date +%Y-%m-%d-%T) - Scaling cluster down to two."
- az aks scale -n $aks_name -g $aks_group -c 2
- echo "$(date +%Y-%m-%d-%T) - Scaling cluster back to three."
- az aks scale -n $aks_name -g $aks_group -c 3
- echo "$(date +%Y-%m-%d-%T) - All done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement