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.

98 lines
4.7 KiB

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