CI for the TripleO project
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.

toci_quickstart.sh 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #!/usr/bin/env bash
  2. set -eux
  3. set -o pipefail
  4. export ANSIBLE_NOCOLOR=1
  5. [[ -n ${STATS_TESTENV:-''} ]] && export STATS_TESTENV=$(( $(date +%s) - STATS_TESTENV ))
  6. export STATS_OOOQ=$(date +%s)
  7. LOCAL_WORKING_DIR="$WORKSPACE/.quickstart"
  8. WORKING_DIR="$HOME"
  9. LOGS_DIR=$WORKSPACE/logs
  10. source $TRIPLEO_ROOT/tripleo-ci/scripts/oooq_common_functions.sh
  11. ## Signal to toci_gate_test.sh we've started by
  12. touch /tmp/toci.started
  13. export DEFAULT_ARGS="--extra-vars local_working_dir=$LOCAL_WORKING_DIR \
  14. --extra-vars virthost=$UNDERCLOUD \
  15. --inventory $LOCAL_WORKING_DIR/hosts \
  16. --extra-vars tripleo_root=$TRIPLEO_ROOT \
  17. --extra-vars working_dir=$WORKING_DIR \
  18. --skip-tags "tripleo-validations,teardown-all" \
  19. "
  20. # --install-deps arguments installs deps and then quits, no other arguments are
  21. # processed.
  22. QUICKSTART_PREPARE_CMD="
  23. ./quickstart.sh
  24. --install-deps
  25. "
  26. QUICKSTART_VENV_CMD="
  27. ./quickstart.sh
  28. --bootstrap
  29. --no-clone
  30. --working-dir $LOCAL_WORKING_DIR
  31. --playbook noop.yml
  32. --retain-inventory
  33. $UNDERCLOUD
  34. "
  35. QUICKSTART_INSTALL_CMD="
  36. $LOCAL_WORKING_DIR/bin/ansible-playbook
  37. --tags $TAGS
  38. "
  39. export QUICKSTART_DEFAULT_RELEASE_ARG="--extra-vars @$LOCAL_WORKING_DIR/config/release/tripleo-ci/${DISTRIBUTION:-CentOS}-${DISTRIBUTION_MAJOR_VERSION:-7}/$QUICKSTART_RELEASE.yml"
  40. QUICKSTART_COLLECTLOGS_CMD="$LOCAL_WORKING_DIR/bin/ansible-playbook \
  41. $LOCAL_WORKING_DIR/playbooks/collect-logs.yml \
  42. -vv \
  43. $QUICKSTART_DEFAULT_RELEASE_ARG \
  44. $FEATURESET_CONF \
  45. $ENV_VARS \
  46. $EXTRA_VARS \
  47. $DEFAULT_ARGS \
  48. --extra-vars @$COLLECT_CONF \
  49. --extra-vars artcl_collect_dir=$LOGS_DIR \
  50. --tags all \
  51. "
  52. declare -A RELEASE_ARGS=()
  53. if [[ -f "$RELEASES_FILE_OUTPUT" ]]; then
  54. source $RELEASES_FILE_OUTPUT
  55. declare -A RELEASE_ARGS=(
  56. ["multinode-undercloud.yml"]=$(get_extra_vars_from_release \
  57. $UNDERCLOUD_INSTALL_RELEASE $UNDERCLOUD_INSTALL_HASH)
  58. ["multinode-undercloud-upgrade.yml"]=$(get_extra_vars_from_release \
  59. $UNDERCLOUD_TARGET_RELEASE $UNDERCLOUD_TARGET_HASH)
  60. ["multinode-overcloud-prep.yml"]=$(get_extra_vars_from_release \
  61. $OVERCLOUD_DEPLOY_RELEASE $OVERCLOUD_DEPLOY_HASH)
  62. ["multinode-overcloud.yml"]=$(get_extra_vars_from_release \
  63. $OVERCLOUD_DEPLOY_RELEASE $OVERCLOUD_DEPLOY_HASH)
  64. ["multinode-overcloud-update.yml"]=$(get_extra_vars_from_release \
  65. $OVERCLOUD_DEPLOY_RELEASE $OVERCLOUD_DEPLOY_HASH)
  66. ["multinode-overcloud-upgrade.yml"]=$(get_extra_vars_from_release \
  67. $OVERCLOUD_TARGET_RELEASE $OVERCLOUD_TARGET_HASH)
  68. ["multinode-validate.yml"]=$(get_extra_vars_from_release \
  69. $OVERCLOUD_TARGET_RELEASE $OVERCLOUD_TARGET_HASH)
  70. )
  71. fi
  72. declare -A PLAYBOOKS_ARGS=(
  73. ["baremetal-full-overcloud.yml"]=" --extra-vars validation_args='--validation-errors-nonfatal' "
  74. ["multinode-overcloud.yml"]=" --extra-vars validation_args='--validation-errors-nonfatal' "
  75. ["multinode.yml"]=" --extra-vars validation_args='--validation-errors-nonfatal' "
  76. )
  77. mkdir -p $LOCAL_WORKING_DIR
  78. # TODO(gcerami) parametrize hosts
  79. cp $TRIPLEO_ROOT/tripleo-ci/toci-quickstart/config/testenv/${ENVIRONMENT}_hosts $LOCAL_WORKING_DIR/hosts
  80. pushd $TRIPLEO_ROOT/tripleo-quickstart/
  81. $QUICKSTART_PREPARE_CMD
  82. $QUICKSTART_VENV_CMD
  83. # Only ansible-playbook command will be used from this point forward, so we
  84. # need some variables from quickstart.sh
  85. OOOQ_DIR=$TRIPLEO_ROOT/tripleo-quickstart/
  86. export OPT_WORKDIR=$LOCAL_WORKING_DIR
  87. export ANSIBLE_CONFIG=$OOOQ_DIR/ansible.cfg
  88. export ARA_DATABASE="sqlite:///${LOCAL_WORKING_DIR}/ara.sqlite"
  89. export VIRTUAL_ENV_DISABLE_PROMPT=1
  90. # Workaround for virtualenv issue https://github.com/pypa/virtualenv/issues/1029
  91. set +u
  92. source $LOCAL_WORKING_DIR/bin/activate
  93. set -u
  94. source $OOOQ_DIR/ansible_ssh_env.sh
  95. [[ -n ${STATS_OOOQ:-''} ]] && export STATS_OOOQ=$(( $(date +%s) - STATS_OOOQ ))
  96. # Debug step capture env variables
  97. if [[ "$PLAYBOOK_DRY_RUN" == "1" ]]; then
  98. echo "-- Capture Environment Variables Used ---------"
  99. echo "$(env)" | tee -a $LOGS_DIR/toci_env_args_output.log
  100. declare -p | tee -a $LOGS_DIR/toci_env_args_output.log
  101. fi
  102. echo "-- Playbooks Output --------------------------"
  103. for playbook in $PLAYBOOKS; do
  104. echo "$QUICKSTART_INSTALL_CMD \
  105. ${RELEASE_ARGS[$playbook]:=$QUICKSTART_DEFAULT_RELEASE_ARG} \
  106. $NODES_ARGS \
  107. $FEATURESET_CONF \
  108. $ENV_VARS \
  109. $EXTRA_VARS \
  110. $VXLAN_VARS \
  111. $DEFAULT_ARGS \
  112. $LOCAL_WORKING_DIR/playbooks/$playbook ${PLAYBOOKS_ARGS[$playbook]:-}" \
  113. | sed 's/--/\n--/g' \
  114. | tee -a $LOGS_DIR/playbook_executions.log
  115. echo "# --------------------------------------- " \
  116. | tee -a $LOGS_DIR/playbook_executions.log
  117. done
  118. if [[ "$PLAYBOOK_DRY_RUN" == "1" ]]; then
  119. exit_value=0
  120. else
  121. ## LOGS COLLECTION PREPARE
  122. create_collect_logs_script
  123. for playbook in $PLAYBOOKS; do
  124. echo "${RELEASE_ARGS[$playbook]:=$QUICKSTART_DEFAULT_RELEASE_ARG}"
  125. run_with_timeout $START_JOB_TIME $QUICKSTART_INSTALL_CMD \
  126. "${RELEASE_ARGS[$playbook]:=$QUICKSTART_DEFAULT_RELEASE_ARG}" \
  127. $NODES_ARGS \
  128. $FEATURESET_CONF \
  129. $ENV_VARS \
  130. $EXTRA_VARS \
  131. $VXLAN_VARS \
  132. $DEFAULT_ARGS \
  133. --extra-vars ci_job_end_time=$(( START_JOB_TIME + REMAINING_TIME*60 )) \
  134. $LOCAL_WORKING_DIR/playbooks/$playbook "${PLAYBOOKS_ARGS[$playbook]:-}" \
  135. 2>&1 | tee -a $LOGS_DIR/quickstart_install.log && exit_value=0 || exit_value=$?
  136. # Print status of playbook run
  137. [[ "$exit_value" == 0 ]] && echo "Playbook run of $playbook passed successfully"
  138. [[ "$exit_value" != 0 ]] && echo "Playbook run of $playbook failed" && break
  139. done
  140. [[ "$exit_value" == 0 ]] && echo "Playbook run passed successfully" || echo "Playbook run failed"
  141. ## LOGS COLLECTION RUN (if applicable)
  142. if [[ "${NODEPOOL_PROVIDER:-''}" == "rdo-cloud-tripleo" ]] || \
  143. [[ "${NODEPOOL_PROVIDER:-''}" == "vexxhost-rdo-ca-ymq-1" ]] ; then
  144. if [[ "$TOCI_JOBTYPE" =~ "ovb" ]]; then
  145. bash $LOGS_DIR/collect_logs.sh
  146. # rename script to not to run it in multinode jobs
  147. mv $LOGS_DIR/collect_logs.sh $LOGS_DIR/ovb_collect_logs.sh
  148. fi
  149. fi
  150. fi
  151. popd
  152. sudo unbound-control dump_cache > /tmp/dns_cache.txt
  153. sudo chown ${USER}: /tmp/dns_cache.txt
  154. cat /tmp/dns_cache.txt | gzip - > $LOGS_DIR/dns_cache.txt.gz
  155. if [[ "$PERIODIC" == 1 && -e $WORKSPACE/hash_info.sh ]] ; then
  156. echo export JOB_EXIT_VALUE=$exit_value >> $WORKSPACE/hash_info.sh
  157. fi
  158. mkdir -p $LOGS_DIR/quickstart_files
  159. find $LOCAL_WORKING_DIR -maxdepth 1 -type f -not -name "*sqlite" | while read i; do gzip -cf $i > $LOGS_DIR/quickstart_files/$(basename $i).txt.gz; done
  160. echo 'Quickstart completed.'
  161. exit $exit_value