Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 1 | @Library('tcp-qa')_ |
| 2 | |
| 3 | common = new com.mirantis.mk.Common() |
| 4 | shared = new com.mirantis.system_qa.SharedPipeline() |
| 5 | |
| 6 | |
| 7 | node ("${NODE_NAME}") { |
| 8 | try { |
| 9 | |
| 10 | stage("Clean the environment and clone tcp-qa") { |
| 11 | shared.prepare_working_dir() |
| 12 | } |
| 13 | |
| 14 | stage("Create environment, generate model, bootstrap the salt-cluster") { |
| 15 | shared.swarm_bootstrap_salt_cluster_devops() |
| 16 | } |
| 17 | |
| 18 | stage("Install core infrastructure and deploy CICD nodes") { |
| 19 | shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL) |
| 20 | } |
| 21 | |
| 22 | stage("Install core infrastructure and deploy CICD nodes") { |
| 23 | shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL) |
| 24 | } |
| 25 | |
| 26 | stage("Run tests") { |
| 27 | shared.run_cmd("""\ |
| 28 | export ENV_NAME=${ENV_NAME} |
| 29 | . ./tcp_tests/utils/env_salt |
| 30 | . ./tcp_tests/utils/env_k8s |
| 31 | |
| 32 | # Prepare snapshots that may be used in tests if MANAGER=devops |
| 33 | cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_k8s_deployed.ini |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 34 | cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_stacklight_deployed.ini |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 35 | #dos.py suspend ${ENV_NAME} |
| 36 | #dos.py snapshot ${ENV_NAME} k8s_deployed |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 37 | #dos.py snapshot ${ENV_NAME} stacklight_deployed |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 38 | #dos.py resume ${ENV_NAME} |
| 39 | #dos.py time-sync ${ENV_NAME} |
| 40 | |
| 41 | # Initialize variables used in tcp-qa tests |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 42 | export CURRENT_SNAPSHOT=stacklight_deployed # provide the snapshot name required by the test |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 43 | export TESTS_CONFIGS=\$(pwd)/${ENV_NAME}_salt_deployed.ini # some SSH data may be filled separatelly |
| 44 | |
| 45 | #export MANAGER=empty # skip 'hardware' fixture, disable snapshot/revert features |
| 46 | export MANAGER=devops # use 'hardware' fixture to manage fuel-devops environment |
| 47 | export MAKE_SNAPSHOT_STAGES=false # skip 'hardware' fixture, disable snapshot/revert features |
| 48 | # export SSH='{...}' # non-empty SSH required to skip 'underlay' fixture. It is filled from TESTS_CONFIGS now |
| 49 | export salt_master_host=\$SALT_MASTER_IP # skip salt_deployed fixture |
| 50 | export salt_master_port=6969 |
| 51 | export SALT_USER=\$SALTAPI_USER |
| 52 | export SALT_PASSWORD=\$SALTAPI_PASS |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 53 | export CORE_INSTALLED=true # skip core_deployed fixture |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 54 | export K8S_INSTALLED=true # skip k8s_deployed fixture |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 55 | export sl_installed=true # skip stacklight_deployed fixture |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 56 | |
| 57 | py.test --junit-xml=nosetests.xml ${RUN_TEST_OPTS} |
| 58 | |
| 59 | dos.py suspend ${ENV_NAME} |
| 60 | dos.py snapshot ${ENV_NAME} test_completed |
| 61 | """) |
| 62 | } |
| 63 | |
| 64 | } catch (e) { |
| 65 | common.printMsg("Job failed", "red") |
| 66 | shared.run_cmd("""\ |
| 67 | dos.py suspend ${ENV_NAME} || true |
| 68 | dos.py snapshot ${ENV_NAME} test_failed || true |
| 69 | """) |
| 70 | throw e |
| 71 | } finally { |
| 72 | // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'" |
| 73 | // and report appropriate data to TestRail |
| 74 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") { |
| 75 | shared.run_cmd("""\ |
| 76 | dos.py destroy ${ENV_NAME} || true |
| 77 | """) |
| 78 | } else { |
| 79 | shared.run_cmd("""\ |
| 80 | dos.py resume ${ENV_NAME} || true |
| 81 | dos.py time-sync ${ENV_NAME} || true |
| 82 | """) |
| 83 | } |
| 84 | shared.report_deploy_result("hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL) |
| 85 | shared.report_test_result() |
| 86 | } |
| 87 | } |