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.

207 lines
6.7 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. ---
  2. stages:
  3. - unit-tests
  4. - moderator
  5. - deploy-part1
  6. - deploy-part2
  7. - deploy-gce
  8. - deploy-special
  9. variables:
  10. FAILFASTCI_NAMESPACE: 'kargo-ci'
  11. GITLAB_REPOSITORY: 'kargo-ci/kubernetes-sigs-kubespray'
  12. # DOCKER_HOST: tcp://localhost:2375
  13. ANSIBLE_FORCE_COLOR: "true"
  14. MAGIC: "ci check this"
  15. TEST_ID: "$CI_PIPELINE_ID-$CI_BUILD_ID"
  16. CI_TEST_VARS: "./tests/files/${CI_JOB_NAME}.yml"
  17. GS_ACCESS_KEY_ID: $GS_KEY
  18. GS_SECRET_ACCESS_KEY: $GS_SECRET
  19. CONTAINER_ENGINE: docker
  20. SSH_USER: root
  21. GCE_PREEMPTIBLE: "false"
  22. ANSIBLE_KEEP_REMOTE_FILES: "1"
  23. ANSIBLE_CONFIG: ./tests/ansible.cfg
  24. ANSIBLE_INVENTORY: ./inventory/sample/${CI_JOB_NAME}-${BUILD_NUMBER}.ini
  25. IDEMPOT_CHECK: "false"
  26. RESET_CHECK: "false"
  27. UPGRADE_TEST: "false"
  28. LOG_LEVEL: "-vv"
  29. before_script:
  30. - /usr/bin/python -m pip install -r tests/requirements.txt
  31. - mkdir -p /.ssh
  32. .job: &job
  33. tags:
  34. - packet
  35. image: quay.io/kubespray/kubespray:v2.9.0
  36. .testcases: &testcases
  37. <<: *job
  38. services:
  39. - docker:dind
  40. before_script:
  41. - /usr/bin/python -m pip install -r tests/requirements.txt
  42. - mkdir -p /.ssh
  43. - mkdir -p $HOME/.ssh
  44. - ansible-playbook --version
  45. - export PYPATH=$([[ ! "$CI_JOB_NAME" =~ "coreos" ]] && echo /usr/bin/python || echo /opt/bin/python)
  46. - echo "CI_JOB_NAME is $CI_JOB_NAME"
  47. - echo "PYPATH is $PYPATH"
  48. script:
  49. - pwd
  50. - ls
  51. - echo ${PWD}
  52. - echo "${STARTUP_SCRIPT}"
  53. # Docker is required on the ansible host for download_run_once and download_localhost
  54. - docker info
  55. - cd tests && make create-${CI_PLATFORM} -s ; cd -
  56. # Check out latest tag if testing upgrade
  57. - test "${UPGRADE_TEST}" != "false" && git fetch --all && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
  58. # Checkout the CI vars file so it is available
  59. - test "${UPGRADE_TEST}" != "false" && git checkout "${CI_BUILD_REF}" tests/files/${CI_JOB_NAME}.yml
  60. # Create cluster
  61. - >
  62. ansible-playbook
  63. -i ${ANSIBLE_INVENTORY}
  64. -b --become-user=root
  65. --private-key=${HOME}/.ssh/id_rsa
  66. -u $SSH_USER
  67. ${SSH_ARGS}
  68. ${LOG_LEVEL}
  69. -e @${CI_TEST_VARS}
  70. -e ansible_ssh_user=${SSH_USER}
  71. -e local_release_dir=${PWD}/downloads
  72. --limit "all:!fake_hosts"
  73. cluster.yml
  74. # Repeat deployment if testing upgrade
  75. - >
  76. if [ "${UPGRADE_TEST}" != "false" ]; then
  77. test "${UPGRADE_TEST}" == "basic" && PLAYBOOK="cluster.yml";
  78. test "${UPGRADE_TEST}" == "graceful" && PLAYBOOK="upgrade-cluster.yml";
  79. git checkout "${CI_BUILD_REF}";
  80. ansible-playbook
  81. -i ${ANSIBLE_INVENTORY}
  82. -b --become-user=root
  83. --private-key=${HOME}/.ssh/id_rsa
  84. -u $SSH_USER
  85. ${SSH_ARGS}
  86. ${LOG_LEVEL}
  87. -e @${CI_TEST_VARS}
  88. -e ansible_ssh_user=${SSH_USER}
  89. -e local_release_dir=${PWD}/downloads
  90. --limit "all:!fake_hosts"
  91. $PLAYBOOK;
  92. fi
  93. # Tests Cases
  94. ## Test Master API
  95. - ansible-playbook -i ${ANSIBLE_INVENTORY} -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root --limit "all:!fake_hosts" tests/testcases/010_check-apiserver.yml $LOG_LEVEL
  96. ## Test that all pods are Running
  97. - ansible-playbook -i ${ANSIBLE_INVENTORY} -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root --limit "all:!fake_hosts" tests/testcases/015_check-pods-running.yml $LOG_LEVEL
  98. ## Ping the between 2 pod
  99. - ansible-playbook -i ${ANSIBLE_INVENTORY} -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root --limit "all:!fake_hosts" tests/testcases/030_check-network.yml $LOG_LEVEL
  100. ## Advanced DNS checks
  101. - ansible-playbook -i ${ANSIBLE_INVENTORY} -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml $LOG_LEVEL
  102. ## Idempotency checks 1/5 (repeat deployment)
  103. - >
  104. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  105. ansible-playbook
  106. -i ${ANSIBLE_INVENTORY}
  107. -b --become-user=root
  108. --private-key=${HOME}/.ssh/id_rsa
  109. -u $SSH_USER
  110. ${SSH_ARGS}
  111. ${LOG_LEVEL}
  112. -e @${CI_TEST_VARS}
  113. -e ansible_python_interpreter=${PYPATH}
  114. -e local_release_dir=${PWD}/downloads
  115. --limit "all:!fake_hosts"
  116. cluster.yml;
  117. fi
  118. ## Idempotency checks 2/5 (Advanced DNS checks)
  119. - >
  120. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  121. ansible-playbook
  122. -i ${ANSIBLE_INVENTORY}
  123. -b --become-user=root
  124. --private-key=${HOME}/.ssh/id_rsa
  125. -u $SSH_USER
  126. ${SSH_ARGS}
  127. ${LOG_LEVEL}
  128. -e @${CI_TEST_VARS}
  129. --limit "all:!fake_hosts"
  130. tests/testcases/040_check-network-adv.yml;
  131. fi
  132. ## Idempotency checks 3/5 (reset deployment)
  133. - >
  134. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  135. ansible-playbook
  136. -i ${ANSIBLE_INVENTORY}
  137. -b --become-user=root
  138. --private-key=${HOME}/.ssh/id_rsa
  139. -u $SSH_USER
  140. ${SSH_ARGS}
  141. ${LOG_LEVEL}
  142. -e @${CI_TEST_VARS}
  143. -e ansible_python_interpreter=${PYPATH}
  144. -e reset_confirmation=yes
  145. --limit "all:!fake_hosts"
  146. reset.yml;
  147. fi
  148. ## Idempotency checks 4/5 (redeploy after reset)
  149. - >
  150. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  151. ansible-playbook
  152. -i ${ANSIBLE_INVENTORY}
  153. -b --become-user=root
  154. --private-key=${HOME}/.ssh/id_rsa
  155. -u $SSH_USER
  156. ${SSH_ARGS}
  157. ${LOG_LEVEL}
  158. -e @${CI_TEST_VARS}
  159. -e ansible_python_interpreter=${PYPATH}
  160. -e local_release_dir=${PWD}/downloads
  161. --limit "all:!fake_hosts"
  162. cluster.yml;
  163. fi
  164. ## Idempotency checks 5/5 (Advanced DNS checks)
  165. - >
  166. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  167. ansible-playbook -i ${ANSIBLE_INVENTORY} -e ansible_python_interpreter=${PYPATH}
  168. -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root
  169. --limit "all:!fake_hosts"
  170. tests/testcases/040_check-network-adv.yml $LOG_LEVEL;
  171. fi
  172. after_script:
  173. - cd tests && make delete-${CI_PLATFORM} -s ; cd -
  174. # For failfast, at least 1 job must be defined in .gitlab-ci.yml
  175. # Premoderated with manual actions
  176. ci-authorized:
  177. extends: .job
  178. stage: moderator
  179. script:
  180. - /bin/sh scripts/premoderator.sh
  181. except: ['triggers', 'master']
  182. include:
  183. - .gitlab-ci/lint.yml
  184. - .gitlab-ci/shellcheck.yml
  185. - .gitlab-ci/gce.yml
  186. - .gitlab-ci/digital-ocean.yml
  187. - .gitlab-ci/terraform.yml
  188. - .gitlab-ci/packet.yml