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.

68 lines
3.1 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. cd tests && make create-${CI_PLATFORM} -s ; cd -
  10. export ANSIBLE_REMOTE_USER=$SSH_USER
  11. export ANSIBLE_BECOME=true
  12. export ANSIBLE_BECOME_USER=root
  13. # Check out latest tag if testing upgrade
  14. test "${UPGRADE_TEST}" != "false" && git fetch --all && git checkout "$KUBESPRAY_VERSION"
  15. # Checkout the CI vars file so it is available
  16. test "${UPGRADE_TEST}" != "false" && git checkout "${CI_BUILD_REF}" tests/files/${CI_JOB_NAME}.yml
  17. # Create cluster
  18. ansible-playbook ${LOG_LEVEL} -e @${CI_TEST_VARS} -e ansible_ssh_user=${SSH_USER} -e local_release_dir=${PWD}/downloads --limit "all:!fake_hosts" cluster.yml
  19. # Repeat deployment if testing upgrade
  20. if [ "${UPGRADE_TEST}" != "false" ]; then
  21. test "${UPGRADE_TEST}" == "basic" && PLAYBOOK="cluster.yml"
  22. test "${UPGRADE_TEST}" == "graceful" && PLAYBOOK="upgrade-cluster.yml"
  23. git checkout "${CI_BUILD_REF}"
  24. ansible-playbook ${LOG_LEVEL} -e @${CI_TEST_VARS} -e ansible_ssh_user=${SSH_USER} -e local_release_dir=${PWD}/downloads --limit "all:!fake_hosts" $PLAYBOOK
  25. fi
  26. # Tests Cases
  27. ## Test Master API
  28. ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/010_check-apiserver.yml $LOG_LEVEL
  29. ## Test that all pods are Running
  30. ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/015_check-pods-running.yml $LOG_LEVEL
  31. ## Test pod creation and ping between them
  32. ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/030_check-network.yml $LOG_LEVEL
  33. ## Advanced DNS checks
  34. ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml $LOG_LEVEL
  35. ## Idempotency checks 1/5 (repeat deployment)
  36. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  37. 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
  38. fi
  39. ## Idempotency checks 2/5 (Advanced DNS checks)
  40. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  41. ansible-playbook ${LOG_LEVEL} -e @${CI_TEST_VARS} --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml
  42. fi
  43. ## Idempotency checks 3/5 (reset deployment)
  44. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  45. ansible-playbook ${LOG_LEVEL} -e @${CI_TEST_VARS} -e ansible_python_interpreter=${PYPATH} -e reset_confirmation=yes --limit "all:!fake_hosts" reset.yml
  46. fi
  47. ## Idempotency checks 4/5 (redeploy after reset)
  48. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  49. 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
  50. fi
  51. ## Idempotency checks 5/5 (Advanced DNS checks)
  52. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  53. ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml $LOG_LEVEL
  54. fi