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.

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