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.

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