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 | # TODO: . ./tcp_tests/utils/env_keystonercv3 |
| 31 | |
| 32 | # Prepare snapshots that may be used in tests if MANAGER=devops |
| 33 | cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_openstack_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 | cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_sl_os_deployed.ini |
| 36 | #dos.py suspend ${ENV_NAME} |
| 37 | #dos.py snapshot ${ENV_NAME} openstack_deployed |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 38 | #dos.py snapshot ${ENV_NAME} stacklight_deployed |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 39 | #dos.py snapshot ${ENV_NAME} sl_os_deployed |
| 40 | #dos.py resume ${ENV_NAME} |
| 41 | #dos.py time-sync ${ENV_NAME} |
| 42 | |
| 43 | # Initialize variables used in tcp-qa tests |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 44 | 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] | 45 | export TESTS_CONFIGS=\$(pwd)/${ENV_NAME}_salt_deployed.ini # some SSH data may be filled separatelly |
| 46 | |
| 47 | #export MANAGER=empty # skip 'hardware' fixture, disable snapshot/revert features |
| 48 | export MANAGER=devops # use 'hardware' fixture to manage fuel-devops environment |
| 49 | export MAKE_SNAPSHOT_STAGES=false # skip 'hardware' fixture, disable snapshot/revert features |
| 50 | # export SSH='{...}' # non-empty SSH required to skip 'underlay' fixture. It is filled from TESTS_CONFIGS now |
| 51 | export salt_master_host=\$SALT_MASTER_IP # skip salt_deployed fixture |
| 52 | export salt_master_port=6969 |
| 53 | export SALT_USER=\$SALTAPI_USER |
| 54 | export SALT_PASSWORD=\$SALTAPI_PASS |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 55 | export CORE_INSTALLED=true # skip core_deployed fixture |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 56 | export OPENSTACK_INSTALLED=true # skip k8s_deployed fixture |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 57 | export sl_installed=true # skip stacklight_deployed fixture |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 58 | |
| 59 | py.test --junit-xml=nosetests.xml ${RUN_TEST_OPTS} |
| 60 | |
| 61 | dos.py suspend ${ENV_NAME} |
| 62 | dos.py snapshot ${ENV_NAME} test_completed |
| 63 | """) |
| 64 | } |
| 65 | |
| 66 | } catch (e) { |
| 67 | common.printMsg("Job failed", "red") |
| 68 | shared.run_cmd("""\ |
| 69 | dos.py suspend ${ENV_NAME} || true |
| 70 | dos.py snapshot ${ENV_NAME} test_failed || true |
| 71 | """) |
| 72 | throw e |
| 73 | } finally { |
| 74 | // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'" |
| 75 | // and report appropriate data to TestRail |
| 76 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") { |
| 77 | shared.run_cmd("""\ |
| 78 | dos.py destroy ${ENV_NAME} || true |
| 79 | """) |
| 80 | } else { |
| 81 | shared.run_cmd("""\ |
| 82 | dos.py resume ${ENV_NAME} || true |
| 83 | dos.py time-sync ${ENV_NAME} || true |
| 84 | """) |
| 85 | } |
| 86 | shared.report_deploy_result("hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL) |
| 87 | shared.report_test_result() |
| 88 | } |
| 89 | } |