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.

176 lines
5.7 KiB

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