blob: fa158b9a01566ab7c4981547bbdca4e21037dbaf [file] [log] [blame]
Petr Lomakin47fee0a2017-08-01 10:46:05 -07001package com.mirantis.mcp
2
3/**
4 *
5 * Tests providing functions
6 *
7 */
8
9/**
10 * Configure docker image with tests
11 *
12 * @param dockerImageLink Docker image link with rally and tempest
13 * @param target Host to run tests
14 * @param output_dir Directory for results
15 */
16def runContainerConfiguration(master, dockerImageLink, target, output_dir){
17 def salt = new com.mirantis.mk.Salt()
18 def common = new com.mirantis.mk.Common()
19 def output_file = 'docker.log'
20 def _pillar = salt.getPillar(master, "ctl01*", 'keystone:server')
21 def keystone = _pillar['return'][0].values()[0]
22 salt.cmdRun(master, target, "docker run -tid --net=host --name=qa_tools " +
23 "-e tempest_version=15.0.0 -e OS_USERNAME=${keystone.admin_name} " +
24 "-e OS_PASSWORD=${keystone.admin_password} -e OS_TENANT_NAME=${keystone.admin_tenant} " +
25 "-e OS_AUTH_URL=http://${keystone.bind.private_address}:${keystone.bind.private_port}/v2.0 " +
26 "-e OS_REGION_NAME=${keystone.region} -e OS_ENDPOINT_TYPE=admin ${dockerImageLink} /bin/bash")
27 salt.cmdRun(master, target, "docker exec qa_tools bash -c /opt/devops-qa-tools/deployment/configure.sh > ${output_file}")
28 def file_content = salt.getFileContent(master, target, output_file)
29 writeFile file: "${output_dir}${output_file}", text: file_content
30}
31
32/**
33 * Execute tempest tests
34 *
35 * @param target Host to run tests
36 * @param pattern If not false, will run only tests matched the pattern
37 * @param output_dir Directory for results
38 */
39def runTempestTests(master, target, output_dir, pattern = "false") {
40 def salt = new com.mirantis.mk.Salt()
41 def output_file = 'docker-tempest.log'
42 if (pattern == "false") {
43 salt.cmdRun(master, target, "docker exec qa_tools rally verify start --pattern set=full " +
44 "--detailed > ${output_file}")
45 }
46 else {
47 salt.cmdRun(master, target, "docker exec qa_tools rally verify start --pattern ${pattern} " +
48 "--detailed > ${output_file}")
49 }
50 def file_content = salt.getFileContent(master, target, output_file)
51 writeFile file: "${output_dir}${output_file}", text: file_content
52}
53
54/**
55 * Execute rally tests
56 *
57 * @param target Host to run tests
58 * @param pattern If not false, will run only tests matched the pattern
59 * @param output_dir Directory for results
60 */
61def runRallyTests(master, target, output_dir, pattern = "false") {
62 def salt = new com.mirantis.mk.Salt()
63 def output_file = 'docker-rally.log'
64 salt.cmdRun(master, target, "docker exec qa_tools rally task start combined_scenario.yaml --task-args-file " +
65 "/opt/devops-qa-tools/rally-scenarios/task_arguments.yaml | tee ${output_file}")
66 def file_content = salt.getFileContent(master, target, output_file)
67 writeFile file: "${output_dir}${output_file}", text: file_content
68}
69
70/**
71 * Cleanup
72 *
73 * @param target Host to run commands
74 * @param output_dir Directory for results
75 */
76def runCleanup(master, target, output_dir) {
77 def salt = new com.mirantis.mk.Salt()
78 salt.cmdRun(master, target, "docker rm -f qa_tools")
79 sh "rm -r ${output_dir}"
80}
81
82/** Install docker if needed
83 *
84 * @param target Target node to install docker pkg
85 */
86def installDocker(master, target) {
87 def salt = new com.mirantis.mk.Salt()
88 if ( ! salt.runSaltProcessStep(master, target, 'pkg.version', ["docker-engine"]) ) {
89 salt.runSaltProcessStep(master, target, 'pkg.install', ["docker.io"])
90 }
91}