Fuel Web UI
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.

run_real_plugin_tests_on_real_nailgun.sh 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # Copyright 2016 Mirantis, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. set -eu
  16. # Variables for remote (master node)
  17. export REMOTE_HOST=${REMOTE_HOST:-'10.109.0.2'}
  18. export REMOTE_USER=${REMOTE_USER:-'root'}
  19. export REMOTE_SSH_PORT=${REMOTE_SSH_PORT:-22}
  20. export REMOTE_PASSWORD=${REMOTE_PASSWORD:-'r00tme'}
  21. export REMOTE_DIR=${REMOTE_DIR:-'/root'}
  22. export REMOTE_EXEC="sshpass -p ${REMOTE_PASSWORD}
  23. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
  24. -p ${REMOTE_SSH_PORT} ${REMOTE_USER}@${REMOTE_HOST}"
  25. # Variables for tests
  26. export TESTS_ROOT="$(pwd)/static/tests/functional/real_plugin"
  27. export SCRIPT_PATH="${TESTS_ROOT}/update_plugin_on_real.sh"
  28. export TEST_PREFIX=${TEST_PREFIX:-'test_*'}
  29. export TESTS_DIR_NAME=${TESTS_DIR_NAME:-'feature_nics'}
  30. export CONF_PATH="${TESTS_ROOT}/${TESTS_DIR_NAME}/plugin_conf"
  31. export ARTIFACTS=${ARTIFACTS:-"$(pwd)/test_run/${TESTS_DIR_NAME}"}
  32. plugins='https://product-ci.infra.mirantis.net/view/All/job/9.0.build-fuel-plugins'
  33. path='lastSuccessfulBuild/artifact/built_plugins/fuel_plugin_example_v5-1.0-1.0.0-1.noarch.rpm'
  34. plugin_url=${PLUGIN_URL:-"${plugins}/${path}"}
  35. plugins='http://plugins.mirantis.com/repository/f/u/fuel-plugin-vmware-dvs'
  36. path='fuel-plugin-vmware-dvs-3.1-3.1.0-1.noarch.rpm'
  37. plugin2_url=${PLUGIN_URL_SECOND:-"${plugins}/${path}"}
  38. export NAILGUN_STATIC=$ARTIFACTS/static
  39. mkdir -p "$ARTIFACTS"
  40. function install_prepare_plugin {
  41. url=$1
  42. file_name=$2
  43. ${REMOTE_EXEC} wget --no-check-certificate -O "${REMOTE_DIR}/${file_name}.rpm" "${url}"
  44. export PLUGIN_PATH=$(
  45. ${REMOTE_EXEC} fuel plugins --install "${REMOTE_DIR}/${file_name}.rpm" | awk '/Installing:/ { getline; print $1 }'
  46. )
  47. export PLUGIN_PATH="/var/www/nailgun/plugins/${PLUGIN_PATH}"
  48. meta="${PLUGIN_PATH}/metadata.yaml"
  49. export plugin_name=$(${REMOTE_EXEC} egrep '^name: ' "${meta}" | cut -d ' ' -f 2)
  50. export plugin_version=$(${REMOTE_EXEC} egrep '^version: ' "${meta}" | cut -d ' ' -f 2)
  51. # Fix package version and release versions
  52. ${REMOTE_EXEC} sed -i -e '$!s/4.0.0/5.0.0/' -e '$!s/9.0/10.0/g' -e '$!s/mitaka/newton/' ${meta}
  53. ${REMOTE_EXEC} fuel plugins --sync
  54. # Fix components settings
  55. ${REMOTE_EXEC} sed -i '/requires/,/+$/s/^/#/' ${PLUGIN_PATH}/components.yaml
  56. ${REMOTE_EXEC} fuel plugins --sync
  57. export INSTALLED_PLUGINS="${INSTALLED_PLUGINS};${plugin_name}==${plugin_version//\'/}"
  58. }
  59. function remove_plugins {
  60. for plug in $(echo ${INSTALLED_PLUGINS} | tr ";" "\n")
  61. do
  62. ${REMOTE_EXEC} fuel plugins --remove "${plug}" 2>/dev/null && \
  63. echo "${plug} was removed" || echo "Can not remove plugin ${plug}"
  64. done
  65. }
  66. function remote_scp {
  67. local_file=$1
  68. sshpass -p ${REMOTE_PASSWORD} \
  69. scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
  70. -P ${REMOTE_SSH_PORT} $local_file ${REMOTE_USER}@${REMOTE_HOST}:/${REMOTE_DIR}/
  71. }
  72. function run_tests {
  73. local GULP='./node_modules/.bin/gulp'
  74. local TESTS_DIR="static/tests/functional/real_plugin/${TESTS_DIR_NAME}"
  75. local TESTS=${TESTS_DIR}/${TEST_PREFIX}.js
  76. local result=0
  77. export INSTALLED_PLUGINS=''
  78. if [ ${TESTS_DIR_NAME} == 'feature_nics' ]; then
  79. install_prepare_plugin ${plugin2_url} "plugin2"
  80. for conf in 'nic' 'node' 'bond'; do
  81. remote_scp ${CONF_PATH}/${conf}_plugin2.yaml
  82. ${REMOTE_EXEC} cp ${REMOTE_DIR}/${conf}_plugin2.yaml ${PLUGIN_PATH}/${conf}_config.yaml
  83. done
  84. local plugin1_path=${PLUGIN_PATH}/environment_config.yaml
  85. fi
  86. install_prepare_plugin ${plugin_url} "plugin"
  87. if [ ${TESTS_DIR_NAME} == 'feature_nics' ]; then
  88. ${REMOTE_EXEC} cp ${PLUGIN_PATH}/environment_config.yaml ${plugin1_path}
  89. ${REMOTE_EXEC} sed -i '$!s/fuel.*/dvs/' ${meta}
  90. ${REMOTE_EXEC} fuel plugins --sync
  91. fi
  92. ${GULP} intern:transpile
  93. for test_case in $TESTS; do
  94. echo "INFO: Running test case ${test_case}"
  95. ARTIFACTS=$ARTIFACTS \
  96. ${GULP} intern:run --suites="${test_case}" || result=1
  97. done
  98. remove_plugins
  99. return $result
  100. }
  101. run_tests