Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 1 | package 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 | */ |
| 15 | def runConformanceTests(master, k8s_api, image) { |
| 16 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | a7318f5 | 2017-04-21 16:15:29 +0200 | [diff] [blame] | 17 | 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ál | 798b3f5 | 2017-04-28 13:19:32 +0200 | [diff] [blame] | 19 | print("Conformance test output saved in " + outfile) |
Tatyana Leontovich | c73d63c | 2017-02-28 14:41:38 +0200 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Copy test output to cfg node |
| 24 | * |
| 25 | * @param image Docker image with tests |
| 26 | */ |
| 27 | def 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 Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 32 | /** |
| 33 | * Execute tempest tests |
| 34 | * |
Tatyana Leontovich | 060e115 | 2017-07-10 17:25:37 +0300 | [diff] [blame^] | 35 | * @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 Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 38 | */ |
Tatyana Leontovich | 060e115 | 2017-07-10 17:25:37 +0300 | [diff] [blame^] | 39 | def runTempestTests(master, dockerImageLink, target, pattern = "false") { |
Victor Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 40 | def salt = new com.mirantis.mk.Salt() |
Tatyana Leontovich | 060e115 | 2017-07-10 17:25:37 +0300 | [diff] [blame^] | 41 | 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 Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Upload results to worker |
| 60 | * |
| 61 | */ |
Tatyana Leontovich | 060e115 | 2017-07-10 17:25:37 +0300 | [diff] [blame^] | 62 | def copyTempestResults(master, target) { |
Victor Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 63 | def salt = new com.mirantis.mk.Salt() |
Tatyana Leontovich | 060e115 | 2017-07-10 17:25:37 +0300 | [diff] [blame^] | 64 | 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 Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | |
Tatyana Leontovich | 01704b3 | 2017-03-06 12:26:33 +0200 | [diff] [blame] | 69 | /** Store tests results on host |
Victor Ryzhenkin | c5b3029 | 2017-02-21 19:26:24 +0400 | [diff] [blame] | 70 | * |
Tatyana Leontovich | 01704b3 | 2017-03-06 12:26:33 +0200 | [diff] [blame] | 71 | * @param image Docker image name |
| 72 | */ |
| 73 | def 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 Leontovich | 060e115 | 2017-07-10 17:25:37 +0300 | [diff] [blame^] | 77 | |
| 78 | |
| 79 | /** Install docker if needed |
| 80 | * |
| 81 | * @param target Target node to install docker pkg |
| 82 | */ |
| 83 | def install_docker(master, target) { |
| 84 | def salt = new com.mirantis.mk.Salt() |
| 85 | salt.runSaltProcessStep(master, "${target}", 'pkg.install', ["docker.io"]) |
| 86 | } |