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.

203 lines
6.6 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. sudo: required
  2. services:
  3. - docker
  4. git:
  5. depth: 5
  6. env:
  7. global:
  8. GCE_USER=travis
  9. LOG_LEVEL=-v
  10. SSH_USER=$GCE_USER
  11. TEST_ID=$TRAVIS_JOB_NUMBER
  12. CONTAINER_ENGINE=docker
  13. PRIVATE_KEY=$GCE_PRIVATE_KEY
  14. GS_ACCESS_KEY_ID=$GS_KEY
  15. GS_SECRET_ACCESS_KEY=$GS_SECRET
  16. ANSIBLE_KEEP_REMOTE_FILES=1
  17. CLUSTER_MODE=default
  18. BOOTSTRAP_OS=none
  19. matrix:
  20. # Debian Jessie
  21. - >-
  22. KUBE_NETWORK_PLUGIN=flannel
  23. CLOUD_IMAGE=debian-8-kubespray
  24. CLOUD_REGION=europe-west1-b
  25. CLUSTER_MODE=default
  26. - >-
  27. KUBE_NETWORK_PLUGIN=calico
  28. CLOUD_IMAGE=debian-8-kubespray
  29. CLOUD_REGION=us-central1-c
  30. CLUSTER_MODE=default
  31. # Centos 7
  32. - >-
  33. KUBE_NETWORK_PLUGIN=flannel
  34. CLOUD_IMAGE=centos-7-sudo
  35. CLOUD_REGION=asia-east1-c
  36. CLUSTER_MODE=default
  37. - >-
  38. KUBE_NETWORK_PLUGIN=calico
  39. CLOUD_IMAGE=centos-7-sudo
  40. CLOUD_REGION=europe-west1-b
  41. CLUSTER_MODE=default
  42. - >-
  43. KUBE_NETWORK_PLUGIN=weave
  44. CLOUD_IMAGE=centos-7-sudo
  45. CLOUD_REGION=us-central1-c
  46. CLUSTER_MODE=default
  47. # Redhat 7
  48. - >-
  49. KUBE_NETWORK_PLUGIN=calico
  50. CLOUD_IMAGE=rhel-7-sudo
  51. CLOUD_REGION=asia-east1-c
  52. CLUSTER_MODE=default
  53. - >-
  54. KUBE_NETWORK_PLUGIN=weave
  55. CLOUD_IMAGE=rhel-7-sudo
  56. CLOUD_REGION=europe-west1-b
  57. CLUSTER_MODE=default
  58. # Ubuntu 16.04
  59. - >-
  60. KUBE_NETWORK_PLUGIN=canal
  61. CLOUD_IMAGE=ubuntu-1604-xenial
  62. CLOUD_REGION=us-central1-c
  63. CLUSTER_MODE=default
  64. - >-
  65. KUBE_NETWORK_PLUGIN=weave
  66. CLOUD_IMAGE=ubuntu-1604-xenial
  67. CLOUD_REGION=asia-east1-c
  68. CLUSTER_MODE=default
  69. # CoreOS stable
  70. - >-
  71. KUBE_NETWORK_PLUGIN=weave
  72. CLOUD_IMAGE=coreos-stable
  73. CLOUD_REGION=europe-west1-b
  74. CLUSTER_MODE=default
  75. BOOTSTRAP_OS=coreos
  76. - >-
  77. KUBE_NETWORK_PLUGIN=canal
  78. CLOUD_IMAGE=coreos-stable
  79. CLOUD_REGION=us-east1-d
  80. CLUSTER_MODE=default
  81. BOOTSTRAP_OS=coreos
  82. # Extra cases for separated roles
  83. - >-
  84. KUBE_NETWORK_PLUGIN=canal
  85. CLOUD_IMAGE=rhel-7-sudo
  86. CLOUD_REGION=europe-west1-b
  87. CLUSTER_MODE=separate
  88. - >-
  89. KUBE_NETWORK_PLUGIN=calico
  90. CLOUD_IMAGE=ubuntu-1604-xenial
  91. CLOUD_REGION=us-central1-a
  92. CLUSTER_MODE=separate
  93. - >-
  94. KUBE_NETWORK_PLUGIN=weave
  95. CLOUD_IMAGE=debian-8-kubespray
  96. CLOUD_REGION=us-east1-d
  97. CLUSTER_MODE=separate
  98. - >-
  99. KUBE_NETWORK_PLUGIN=calico
  100. CLOUD_IMAGE=coreos-stable
  101. CLOUD_REGION=asia-east1-c
  102. CLUSTER_MODE=separate
  103. BOOTSTRAP_OS=coreos
  104. matrix:
  105. allow_failures:
  106. - env: KUBE_NETWORK_PLUGIN=weave CLOUD_IMAGE=coreos-stable CLOUD_REGION=europe-west1-b CLUSTER_MODE=default BOOTSTRAP_OS=coreos
  107. before_install:
  108. # Install Ansible.
  109. - pip install --user ansible
  110. - pip install --user netaddr
  111. # W/A https://github.com/ansible/ansible-modules-core/issues/5196#issuecomment-253766186
  112. - pip install --user apache-libcloud==0.20.1
  113. - pip install --user boto==2.9.0 -U
  114. # Load cached docker images
  115. - if [ -d /var/tmp/releases ]; then find /var/tmp/releases -type f -name "*.tar" | xargs -I {} sh -c "zcat {} | docker load"; fi
  116. cache:
  117. - directories:
  118. - $HOME/.cache/pip
  119. - $HOME/.local
  120. - /var/tmp/releases
  121. before_script:
  122. - echo "RUN $TRAVIS_JOB_NUMBER $KUBE_NETWORK_PLUGIN $CONTAINER_ENGINE "
  123. - mkdir -p $HOME/.ssh
  124. - echo $PRIVATE_KEY | base64 -d > $HOME/.ssh/id_rsa
  125. - echo $GCE_PEM_FILE | base64 -d > $HOME/.ssh/gce
  126. - chmod 400 $HOME/.ssh/id_rsa
  127. - chmod 755 $HOME/.local/bin/ansible-playbook
  128. - $HOME/.local/bin/ansible-playbook --version
  129. - cp tests/ansible.cfg .
  130. - export PYPATH=$([ $BOOTSTRAP_OS = none ] && echo /usr/bin/python || echo /opt/bin/python)
  131. # - "echo $HOME/.local/bin/ansible-playbook -i inventory.ini -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root -e '{\"cloud_provider\": true}' $LOG_LEVEL -e kube_network_plugin=${KUBE_NETWORK_PLUGIN} setup-kubernetes/cluster.yml"
  132. script:
  133. - >
  134. $HOME/.local/bin/ansible-playbook tests/cloud_playbooks/create-gce.yml -i tests/local_inventory/hosts.cfg -c local $LOG_LEVEL
  135. -e mode=${CLUSTER_MODE}
  136. -e test_id=${TEST_ID}
  137. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  138. -e gce_project_id=${GCE_PROJECT_ID}
  139. -e gce_service_account_email=${GCE_ACCOUNT}
  140. -e gce_pem_file=${HOME}/.ssh/gce
  141. -e cloud_image=${CLOUD_IMAGE}
  142. -e inventory_path=${PWD}/inventory/inventory.ini
  143. -e cloud_region=${CLOUD_REGION}
  144. # Create cluster
  145. - >
  146. $HOME/.local/bin/ansible-playbook -i inventory/inventory.ini -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS
  147. -b --become-user=root -e cloud_provider=gce $LOG_LEVEL -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  148. -e bootstrap_os=${BOOTSTRAP_OS}
  149. -e ansible_python_interpreter=${PYPATH}
  150. -e download_run_once=true
  151. -e download_localhost=true
  152. -e local_release_dir=/var/tmp/releases
  153. cluster.yml
  154. # Tests Cases
  155. ## Test Master API
  156. - $HOME/.local/bin/ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH} tests/testcases/010_check-apiserver.yml $LOG_LEVEL
  157. ## Create a POD
  158. - $HOME/.local/bin/ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root tests/testcases/020_check-create-pod.yml $LOG_LEVEL
  159. ## Ping the between 2 pod
  160. - $HOME/.local/bin/ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root tests/testcases/030_check-network.yml $LOG_LEVEL
  161. after_failure:
  162. - >
  163. $HOME/.local/bin/ansible-playbook -i inventory/inventory.ini -u $SSH_USER
  164. -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root -e dir=$HOME
  165. -e ansible_python_interpreter=${PYPATH}
  166. scripts/collect-info.yaml
  167. - >
  168. $HOME/.local/bin/ansible-playbook tests/cloud_playbooks/upload-logs-gcs.yml -i "localhost," -c local
  169. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  170. -e gce_project_id=${GCE_PROJECT_ID}
  171. -e gs_key=${GS_ACCESS_KEY_ID}
  172. -e gs_skey=${GS_SECRET_ACCESS_KEY}
  173. -e ostype=${CLOUD_IMAGE}
  174. -e commit=${TRAVIS_COMMIT}
  175. -e dir=${HOME}
  176. after_script:
  177. - >
  178. $HOME/.local/bin/ansible-playbook -i inventory/inventory.ini tests/cloud_playbooks/delete-gce.yml -c local $LOG_LEVEL
  179. -e test_id=${TEST_ID}
  180. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  181. -e gce_project_id=${GCE_PROJECT_ID}
  182. -e gce_service_account_email=${GCE_ACCOUNT}
  183. -e gce_pem_file=${HOME}/.ssh/gce
  184. -e cloud_image=${CLOUD_IMAGE}
  185. -e inventory_path=${PWD}/inventory/inventory.ini
  186. -e cloud_region=${CLOUD_REGION}