Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. source_dir=$(pwd)
  2. results_file=$(echo $source_dir | sed 's:.*/::')
  3. test_start=$(date +%Y-%m-%d-%T)
  4.  
  5. mkdir $test_start
  6.  
  7. echo "\n \n \n $(date +%Y-%m-%d-%T) - Installing CockroachDB via Helm"
  8. helm install --name cockroachdb stable/cockroachdb
  9.  
  10. echo "$(date +%Y-%m-%d-%T) - Started log capture for initialization"
  11. while [ $(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l) != 3 ]; do \
  12. kubectl get po -o wide --no-headers | while \
  13. IFS= read -r line; do echo "$(date) $line"; done \
  14. >> "./$test_start/startup-$results_file"; done
  15. echo "$(date +%Y-%m-%d-%T) - All CockroachDB pods are ready"
  16.  
  17. echo "$(date +%Y-%m-%d-%T) - Deleting node $delete_node to induce failover test."
  18. delete_node=$(kubectl get no -o jsonpath="{.items[*].metadata.name}" | awk '{print $NF}')
  19. group=$(az vm list | grep $delete_node | awk '{print $(NF-1)}')
  20. az vm delete -n $delete_node -g $group -y
  21.  
  22. echo "$(date +%Y-%m-%d-%T) - Watching for one of the pods status to go notready"
  23. while [ $(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l) -gt 2 ]; do sleep 5; done
  24.  
  25. echo "$(date +%Y-%m-%d-%T) - Pod is now failing over and second log to test recovery time has started."
  26. while [ $(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l) != 3 ]; do \
  27. kubectl get po -o wide --no-headers | while \
  28. IFS= read -r line; do echo "$(date) $line"; done \
  29. >> "./$test_start/failover-$results_file"; done
  30.  
  31. echo "$(date +%Y-%m-%d-%T) - Test complete and now we will reset the cluster scale."
  32. kubectl get po -o wide
  33. aks_name=$(kubectl config view -o template --template='{{ index . "current-context" }}')
  34. aks_group=$(az aks list | grep $aks_name | awk '{print $(NF-3)}')
  35.  
  36. echo "$(date +%Y-%m-%d-%T) Deleting CockroachDb and all associated Kubernetes objects."
  37. helm delete cockroachdb --purge
  38. kubectl delete pvc --all
  39. kubectl delete pv --all
  40.  
  41. echo "$(date +%Y-%m-%d-%T) - Scaling cluster down to two."
  42. az aks scale -n $aks_name -g $aks_group -c 2
  43. echo "$(date +%Y-%m-%d-%T) - Scaling cluster back to three."
  44. az aks scale -n $aks_name -g $aks_group -c 3
  45. echo "$(date +%Y-%m-%d-%T) - All done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement