You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.8 KiB

  1. #!/bin/bash
  2. set -euxo pipefail
  3. echo "CI_JOB_NAME is $CI_JOB_NAME"
  4. if [[ "$CI_JOB_NAME" =~ "upgrade" ]]; then
  5. if [ "${UPGRADE_TEST}" == "false" ]; then
  6. echo "Job name contains 'upgrade', but UPGRADE_TEST='false'"
  7. exit 1
  8. fi
  9. else
  10. if [ "${UPGRADE_TEST}" != "false" ]; then
  11. echo "UPGRADE_TEST!='false', but job names does not contain 'upgrade'"
  12. exit 1
  13. fi
  14. fi
  15. export ANSIBLE_REMOTE_USER=$SSH_USER
  16. export ANSIBLE_BECOME=true
  17. export ANSIBLE_BECOME_USER=root
  18. cd tests && make create-${CI_PLATFORM} -s ; cd -
  19. ansible-playbook tests/cloud_playbooks/wait-for-ssh.yml
  20. # CoreOS needs auto update disabled
  21. if [[ "$CI_JOB_NAME" =~ "coreos" ]]; then
  22. ansible all -m raw -a 'systemctl disable locksmithd'
  23. ansible all -m raw -a 'systemctl stop locksmithd'
  24. mkdir -p /opt/bin && ln -s /usr/bin/python /opt/bin/python
  25. fi
  26. if [[ "$CI_JOB_NAME" =~ "opensuse" ]]; then
  27. # OpenSUSE needs netconfig update to get correct resolv.conf
  28. # See https://goinggnu.wordpress.com/2013/10/14/how-to-fix-the-dns-in-opensuse-13-1/
  29. ansible all -m raw -a 'netconfig update -f'
  30. # Auto import repo keys
  31. ansible all -m raw -a 'zypper --gpg-auto-import-keys refresh'
  32. fi
  33. # Check out latest tag if testing upgrade
  34. test "${UPGRADE_TEST}" != "false" && git fetch --all && git checkout "$KUBESPRAY_VERSION"
  35. # Checkout the CI vars file so it is available
  36. test "${UPGRADE_TEST}" != "false" && git checkout "${CI_BUILD_REF}" tests/files/${CI_JOB_NAME}.yml tests/testcases/*.yml
  37. # Install mitogen ansible plugin
  38. if [ "${MITOGEN_ENABLE}" = "true" ]; then
  39. ansible-playbook ${ANSIBLE_LOG_LEVEL} mitogen.yml
  40. export ANSIBLE_STRATEGY=mitogen_linear
  41. export ANSIBLE_STRATEGY_PLUGINS=plugins/mitogen/ansible_mitogen/plugins/strategy
  42. fi
  43. # Create cluster
  44. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads --limit "all:!fake_hosts" cluster.yml
  45. # Repeat deployment if testing upgrade
  46. if [ "${UPGRADE_TEST}" != "false" ]; then
  47. test "${UPGRADE_TEST}" == "basic" && PLAYBOOK="cluster.yml"
  48. test "${UPGRADE_TEST}" == "graceful" && PLAYBOOK="upgrade-cluster.yml"
  49. git checkout "${CI_BUILD_REF}"
  50. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads --limit "all:!fake_hosts" $PLAYBOOK
  51. fi
  52. # Test control plane recovery
  53. if [ "${RECOVER_CONTROL_PLANE_TEST}" != "false" ]; then
  54. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads --limit "${RECOVER_CONTROL_PLANE_TEST_GROUPS}:!fake_hosts" -e reset_confirmation=yes reset.yml
  55. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads -e etcd_retries=10 --limit etcd,kube-master:!fake_hosts recover-control-plane.yml
  56. fi
  57. # Tests Cases
  58. ## Test Master API
  59. ansible-playbook --limit "all:!fake_hosts" -e @${CI_TEST_VARS} tests/testcases/010_check-apiserver.yml $ANSIBLE_LOG_LEVEL
  60. ## Test that all pods are Running
  61. ansible-playbook --limit "all:!fake_hosts" -e @${CI_TEST_VARS} tests/testcases/015_check-pods-running.yml $ANSIBLE_LOG_LEVEL
  62. ## Test that all nodes are Ready
  63. ansible-playbook --limit "all:!fake_hosts" -e @${CI_TEST_VARS} tests/testcases/020_check-nodes-ready.yml $ANSIBLE_LOG_LEVEL
  64. ## Test pod creation and ping between them
  65. ansible-playbook --limit "all:!fake_hosts" -e @${CI_TEST_VARS} tests/testcases/030_check-network.yml $ANSIBLE_LOG_LEVEL
  66. ## Advanced DNS checks
  67. ansible-playbook --limit "all:!fake_hosts" -e @${CI_TEST_VARS} tests/testcases/040_check-network-adv.yml $ANSIBLE_LOG_LEVEL
  68. ## Kubernetes conformance tests
  69. ansible-playbook -i ${ANSIBLE_INVENTORY} -e @${CI_TEST_VARS} --limit "all:!fake_hosts" tests/testcases/100_check-k8s-conformance.yml $ANSIBLE_LOG_LEVEL
  70. ## Idempotency checks 1/5 (repeat deployment)
  71. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  72. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads --limit "all:!fake_hosts" cluster.yml
  73. fi
  74. ## Idempotency checks 2/5 (Advanced DNS checks)
  75. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  76. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml
  77. fi
  78. ## Idempotency checks 3/5 (reset deployment)
  79. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  80. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e reset_confirmation=yes --limit "all:!fake_hosts" reset.yml
  81. fi
  82. ## Idempotency checks 4/5 (redeploy after reset)
  83. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  84. ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads --limit "all:!fake_hosts" cluster.yml
  85. fi
  86. ## Idempotency checks 5/5 (Advanced DNS checks)
  87. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  88. ansible-playbook --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml $ANSIBLE_LOG_LEVEL
  89. fi