blob: 95a432e452329199e3be9c0d4334ddf1d7b2bd6e [file] [log] [blame]
Jakub Josef79ecec32017-02-17 14:36:28 +01001package com.mirantis.mk
2
3/**
4 *
5 * Tests providing functions
6 *
7 */
8
9/**
10 * Run e2e conformance tests
11 *
12 * @param k8s_api Kubernetes api address
13 * @param image Docker image with tests
14 */
15def runConformanceTests(master, k8s_api, image) {
16 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrála7318f52017-04-21 16:15:29 +020017 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
18 salt.runSaltProcessStep(master, 'ctl01*', 'cmd.run', ["docker run --rm --net=host -e API_SERVER=${k8s_api} ${image} > ${outfile}"])
Tomáš Kukrál798b3f52017-04-28 13:19:32 +020019 print("Conformance test output saved in " + outfile)
Tatyana Leontovichc73d63c2017-02-28 14:41:38 +020020}
21
22/**
23 * Copy test output to cfg node
24 *
25 * @param image Docker image with tests
26 */
27def copyTestsOutput(master, image) {
28 def salt = new com.mirantis.mk.Salt()
29 salt.runSaltProcessStep(master, 'cfg01*', 'cmd.run', ["scp ctl01:/root/${image}.output /home/ubuntu/"])
30}
31
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040032/**
33 * Execute tempest tests
34 *
Tatyana Leontovich060e1152017-07-10 17:25:37 +030035 * @param dockerImageLink Docker image link with rally and tempest
36 * @param target Host to run tests
37 * @param pattern If not false, will run only tests matched the pattern
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040038 */
Tatyana Leontovich060e1152017-07-10 17:25:37 +030039def runTempestTests(master, dockerImageLink, target, pattern = "false") {
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040040 def salt = new com.mirantis.mk.Salt()
Tatyana Leontovich060e1152017-07-10 17:25:37 +030041 if (pattern == "false") {
42 salt.runSaltProcessStep(master, "${target}", 'cmd.run', ["docker run --rm --net=host " +
43 "-e TEMPEST_CONF=mcp.conf " +
44 "-e SKIP_LIST=mcp_skip.list " +
45 "-e SOURCE_FILE=keystonercv3 " +
46 "-v /root/:/home/rally ${dockerImageLink} >> docker-tempest.log"])
47 }
48 else {
49 salt.runSaltProcessStep(master, "${target}", 'cmd.run', ["docker run --rm --net=host " +
50 "-e TEMPEST_CONF=mcp.conf " +
51 "-e SKIP_LIST=mcp_skip.list " +
52 "-e SOURCE_FILE=keystonercv3 " +
53 "-e CUSTOM='--pattern ${pattern}' " +
54 "-v /root/:/home/rally ${dockerImageLink} >> docker-tempest.log"])
55 }
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040056}
57
58/**
59 * Upload results to worker
60 *
61 */
Tatyana Leontovich060e1152017-07-10 17:25:37 +030062def copyTempestResults(master, target) {
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040063 def salt = new com.mirantis.mk.Salt()
Tatyana Leontovich060e1152017-07-10 17:25:37 +030064 salt.runSaltProcessStep(master, "${target}", 'cmd.run', ["scp /root/docker-tempest.log cfg01:/home/ubuntu/ && " +
65 "find /root -name result.xml -exec scp {} cfg01:/home/ubuntu \\;"])
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040066}
67
68
Tatyana Leontovich01704b32017-03-06 12:26:33 +020069/** Store tests results on host
Victor Ryzhenkinc5b30292017-02-21 19:26:24 +040070 *
Tatyana Leontovich01704b32017-03-06 12:26:33 +020071 * @param image Docker image name
72 */
73def catTestsOutput(master, image) {
74 def salt = new com.mirantis.mk.Salt()
75 salt.runSaltProcessStep(master, 'cfg01*', 'cmd.run', ["cat /home/ubuntu/${image}.output"])
76}
Tatyana Leontovich060e1152017-07-10 17:25:37 +030077
78
79/** Install docker if needed
80 *
81 * @param target Target node to install docker pkg
82 */
83def install_docker(master, target) {
84 def salt = new com.mirantis.mk.Salt()
85 salt.runSaltProcessStep(master, "${target}", 'pkg.install', ["docker.io"])
86}