kitchen-salt 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/kitchen-salt/version.rb +1 -1
- data/lib/kitchen/provisioner/salt_solo.rb +7 -1
- data/lib/kitchen/verifier/nox.rb +137 -50
- data/lib/kitchen/verifier/runtests.rb +5 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e4475c3f3b756deffb4496c2fb8f7de2b883be4782351c6ddf96742aad3d756f
|
4
|
+
data.tar.gz: 277e089f45bb734662498288d6773d2e752e97585aa78dedaefebb6b4c6b1f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9edcc1c724670fe20adb1e4aae236d28ec6e94033e7066b627f0b6492023cd4599ebee67b555936d9060206594421f4dc51d32d8d43128a27274d604022bc453
|
7
|
+
data.tar.gz: b1b2570d0309c96471773183f6be7c5ff296f207f4c61e69c101a947786a2ffe0005b11904a283405d2567f5219bc21c1d1ad361fb0262263a78b78c52ff1277
|
data/lib/kitchen-salt/version.rb
CHANGED
@@ -64,6 +64,7 @@ module Kitchen
|
|
64
64
|
salt_env: 'base',
|
65
65
|
salt_file_root: '/srv/salt',
|
66
66
|
salt_force_color: false,
|
67
|
+
salt_enable_color: true,
|
67
68
|
salt_install: 'bootstrap',
|
68
69
|
salt_minion_config_dropin_files: [],
|
69
70
|
salt_minion_config_template: nil,
|
@@ -106,7 +107,7 @@ module Kitchen
|
|
106
107
|
end
|
107
108
|
|
108
109
|
def install_command
|
109
|
-
unless config[:salt_install] == 'pip' || config[:install_after_init_environment]
|
110
|
+
unless not config[:salt_install] || config[:salt_install] == 'pip' || config[:install_after_init_environment]
|
110
111
|
setup_salt
|
111
112
|
end
|
112
113
|
end
|
@@ -268,11 +269,16 @@ module Kitchen
|
|
268
269
|
cmd << sudo("#{config[:root_path]}/gpgkey.sh;") if config[:gpg_key]
|
269
270
|
salt_config_path = config[:salt_config]
|
270
271
|
end
|
272
|
+
|
273
|
+
if config[:pre_salt_command]
|
274
|
+
cmd << "#{config[:pre_salt_command]} && "
|
275
|
+
end
|
271
276
|
cmd << sudo("#{salt_call} --state-output=changes --config-dir=#{os_join(config[:root_path], salt_config_path)} state.highstate")
|
272
277
|
cmd << " --log-level=#{config[:log_level]}" if config[:log_level]
|
273
278
|
cmd << " --id=#{config[:salt_minion_id]}" if config[:salt_minion_id]
|
274
279
|
cmd << " test=#{config[:dry_run]}" if config[:dry_run]
|
275
280
|
cmd << ' --force-color' if config[:salt_force_color]
|
281
|
+
cmd << ' --no-color' if not config[:salt_enable_color]
|
276
282
|
if "#{salt_version}" > RETCODE_VERSION || salt_version == 'latest'
|
277
283
|
# hope for the best and hope it works eventually
|
278
284
|
cmd << ' --retcode-passthrough'
|
data/lib/kitchen/verifier/nox.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
+
require "date"
|
4
|
+
require "kitchen/errors"
|
3
5
|
require "kitchen/verifier/base"
|
4
6
|
|
5
7
|
module Kitchen
|
@@ -11,14 +13,11 @@ module Kitchen
|
|
11
13
|
|
12
14
|
default_config :testingdir, '/testing'
|
13
15
|
default_config :tests, []
|
14
|
-
default_config :transport, false
|
15
16
|
default_config :save, {}
|
16
|
-
default_config :windows,
|
17
|
+
default_config :windows, nil
|
17
18
|
default_config :verbose, false
|
18
19
|
default_config :run_destructive, false
|
19
|
-
default_config :
|
20
|
-
default_config :proxy_tests, false
|
21
|
-
default_config :pytest, false
|
20
|
+
default_config :runtests, false
|
22
21
|
default_config :coverage, false
|
23
22
|
default_config :junitxml, false
|
24
23
|
default_config :from_filenames, []
|
@@ -26,34 +25,89 @@ module Kitchen
|
|
26
25
|
default_config :passthrough_opts, []
|
27
26
|
default_config :output_columns, 120
|
28
27
|
default_config :sysinfo, true
|
28
|
+
default_config :sys_stats, false
|
29
|
+
default_config :environment_vars, {}
|
29
30
|
|
30
31
|
def call(state)
|
31
|
-
|
32
|
+
if config[:windows].nil?
|
33
|
+
# Since windows is not set, lets try and guess since kitchen actually knows this infomation
|
34
|
+
if instance.platform.os_type == 'windows'
|
35
|
+
config[:windows] = true
|
36
|
+
else
|
37
|
+
config[:windows] = false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
debug("Detected platform for instance #{instance.name}: #{instance.platform.os_type}. Config's windows setting value: #{config[:windows]}")
|
41
|
+
if (ENV['ONLY_DOWNLOAD_ARTEFACTS'] || '') == '1'
|
42
|
+
only_download_artefacts = true
|
43
|
+
else
|
44
|
+
only_download_artefacts = false
|
45
|
+
end
|
46
|
+
if (ENV['DONT_DOWNLOAD_ARTEFACTS'] || '') == '1'
|
47
|
+
dont_download_artefacts = true
|
48
|
+
else
|
49
|
+
dont_download_artefacts = false
|
50
|
+
end
|
51
|
+
if only_download_artefacts and dont_download_artefacts
|
52
|
+
error_msg = "The environment variables 'ONLY_DOWNLOAD_ARTEFACTS' or 'DONT_DOWNLOAD_ARTEFACTS' cannot be both set to '1'"
|
53
|
+
error(error_msg)
|
54
|
+
raise ActionFailed, error_msg
|
55
|
+
end
|
56
|
+
if only_download_artefacts
|
57
|
+
info("[#{name}] Only downloading artefacts from instance #{instance.name} with state=#{state}")
|
58
|
+
else
|
59
|
+
info("[#{name}] Verify on instance #{instance.name} with state=#{state}")
|
60
|
+
end
|
32
61
|
root_path = (config[:windows] ? '%TEMP%\\kitchen' : '/tmp/kitchen')
|
33
62
|
if ENV['KITCHEN_TESTS']
|
34
63
|
ENV['KITCHEN_TESTS'].split(' ').each{|test| config[:tests].push(test)}
|
35
64
|
end
|
36
|
-
|
37
|
-
if
|
38
|
-
|
39
|
-
|
65
|
+
|
66
|
+
if ENV['NOX_ENABLE_FROM_FILENAMES']
|
67
|
+
config[:enable_filenames] = true
|
68
|
+
end
|
69
|
+
|
70
|
+
if ENV['NOX_PASSTHROUGH_OPTS']
|
71
|
+
ENV['NOX_PASSTHROUGH_OPTS'].split(' ').each{|opt| config[:passthrough_opts].push(opt)}
|
72
|
+
end
|
73
|
+
|
74
|
+
if ENV['NOX_ENV_NAME']
|
75
|
+
noxenv = ENV['NOX_ENV_NAME']
|
76
|
+
elsif config[:runtests] == true
|
77
|
+
noxenv = "runtests-zeromq"
|
40
78
|
else
|
41
|
-
|
42
|
-
|
79
|
+
# Default to pytest-zeromq
|
80
|
+
noxenv = "pytest-zeromq"
|
43
81
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
82
|
+
|
83
|
+
# Is the nox env already including the Python version?
|
84
|
+
if not noxenv.match(/^(.*)-([\d]{1})(\.([\d]{1}))?$/)
|
85
|
+
# Nox env's are not py<python-version> named, they just use the <python-version>
|
86
|
+
# Additionally, nox envs are parametrised to enable or disable test coverage
|
87
|
+
# So, the line below becomes something like:
|
88
|
+
# runtests-2(coverage=True)
|
89
|
+
# pytest-3(coverage=False)
|
90
|
+
suite = instance.suite.name.gsub('py', '').gsub('2', '2.7')
|
91
|
+
noxenv = "#{noxenv}-#{suite}"
|
47
92
|
end
|
48
|
-
#
|
49
|
-
# Additionally, nox envs are parametrised to enable or disable test coverage
|
50
|
-
# So, the line below becomes something like:
|
51
|
-
# runtests-2(coverage=True)
|
52
|
-
# pytest-3(coverage=False)
|
53
|
-
suite = instance.suite.name.gsub('py', '').gsub('2', '2.7')
|
54
|
-
noxenv = "#{noxenv}-#{suite}(coverage=#{config[:coverage] ? 'True' : 'False'})"
|
93
|
+
noxenv = "#{noxenv}(coverage=#{config[:coverage] ? 'True' : 'False'})"
|
55
94
|
|
56
|
-
if
|
95
|
+
if noxenv.include? "pytest"
|
96
|
+
tests = config[:tests].join(' ')
|
97
|
+
if config[:sys_stats]
|
98
|
+
sys_stats = '--sys-stats'
|
99
|
+
if not config[:verbose]
|
100
|
+
config[:verbose] = true
|
101
|
+
end
|
102
|
+
else
|
103
|
+
sys_stats = ''
|
104
|
+
end
|
105
|
+
elsif noxenv.include? "runtests"
|
106
|
+
tests = config[:tests].collect{|test| "-n #{test}"}.join(' ')
|
107
|
+
sys_stats = ''
|
108
|
+
end
|
109
|
+
|
110
|
+
if config[:enable_filenames] and ENV['CHANGE_TARGET'] and ENV['BRANCH_NAME'] and ENV['FORCE_FULL'] != 'true'
|
57
111
|
require 'git'
|
58
112
|
repo = Git.open(Dir.pwd)
|
59
113
|
config[:from_filenames] = repo.diff("origin/#{ENV['CHANGE_TARGET']}",
|
@@ -62,17 +116,19 @@ module Kitchen
|
|
62
116
|
|
63
117
|
if config[:junitxml]
|
64
118
|
junitxml = File.join(root_path, config[:testingdir], 'artifacts', 'xml-unittests-output')
|
65
|
-
if
|
66
|
-
junitxml = "--junitxml=#{File.join(junitxml,
|
119
|
+
if noxenv.include? "pytest"
|
120
|
+
junitxml = "--junitxml=#{File.join(junitxml, "test-results-#{DateTime.now.strftime('%Y%m%d%H%M%S.%L')}.xml")}"
|
67
121
|
else
|
68
122
|
junitxml = "--xml=#{junitxml}"
|
69
123
|
end
|
70
124
|
end
|
71
125
|
|
72
126
|
# Be sure to copy the remote artifacts directory to the local machine
|
73
|
-
|
74
|
-
|
75
|
-
|
127
|
+
if config[:windows]
|
128
|
+
save = {'$env:KitchenTestingDir/artifacts/' => "#{Dir.pwd}"}
|
129
|
+
else
|
130
|
+
save = {"#{File.join(root_path, config[:testingdir], 'artifacts')}/" => "#{Dir.pwd}"}
|
131
|
+
end
|
76
132
|
# Hash insert order matters, that's why we define a new one and merge
|
77
133
|
# the one from config
|
78
134
|
save.merge!(config[:save])
|
@@ -83,57 +139,88 @@ module Kitchen
|
|
83
139
|
(config[:windows] ? "-e #{noxenv}" : "-e '#{noxenv}'"),
|
84
140
|
'--',
|
85
141
|
"--output-columns=#{config[:output_columns]}",
|
142
|
+
sys_stats,
|
86
143
|
(config[:sysinfo] ? '--sysinfo' : ''),
|
87
144
|
(config[:junitxml] ? junitxml : ''),
|
88
|
-
(config[:windows] ? "--names-file=#{root_path}\\testing\\tests\\whitelist.txt" : ''),
|
89
145
|
(config[:verbose] ? '-vv' : '-v'),
|
90
|
-
(config[:run_destructive] ?
|
91
|
-
(config[:ssh_tests] ? "--ssh-tests" : ''),
|
92
|
-
(config[:proxy_tests] ? "--proxy-tests" : ''),
|
146
|
+
(config[:run_destructive] ? '--run-destructive' : ''),
|
93
147
|
config[:passthrough_opts].join(' '),
|
94
|
-
(config[:from_filenames].any? ? "--from-filenames=#{config[:from_filenames].join(',')}" : ''),
|
95
|
-
tests,
|
96
148
|
].join(' ')
|
149
|
+
|
150
|
+
if tests.nil? || tests.empty?
|
151
|
+
# If we're not targetting specific tests...
|
152
|
+
extra_command = [
|
153
|
+
(config[:from_filenames].any? ? "--from-filenames=#{config[:from_filenames].join(',')}" : ''),
|
154
|
+
(config[:windows] ? "--names-file=#{root_path}\\testing\\tests\\whitelist.txt" : ''),
|
155
|
+
].join(' ')
|
156
|
+
command = "#{command} #{extra_command}"
|
157
|
+
else
|
158
|
+
command = "#{command} #{tests}"
|
159
|
+
end
|
160
|
+
|
161
|
+
environment_vars = {}
|
162
|
+
if ENV['CI'] || ENV['DRONE'] || ENV['JENKINS_URL']
|
163
|
+
environment_vars['CI'] = 1
|
164
|
+
end
|
165
|
+
# Hash insert order matters, that's why we define a new one and merge
|
166
|
+
# the one from config
|
167
|
+
environment_vars.merge!(config[:environment_vars])
|
168
|
+
|
97
169
|
if config[:windows]
|
98
170
|
command = "cmd.exe /c --% \"#{command}\" 2>&1"
|
99
171
|
end
|
100
|
-
info("Running Command: #{command}")
|
101
172
|
instance.transport.connection(state) do |conn|
|
102
173
|
begin
|
103
174
|
if config[:windows]
|
104
175
|
conn.execute('$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")')
|
105
|
-
conn.execute("$env:PythonPath = [Environment]::ExpandEnvironmentVariables(\"#{root_path}
|
176
|
+
conn.execute("$env:PythonPath = [Environment]::ExpandEnvironmentVariables(\"#{File.join(root_path, config[:testingdir])}\")")
|
177
|
+
conn.execute("[Environment]::SetEnvironmentVariable(\"KitchenTestingDir\", [Environment]::ExpandEnvironmentVariables(\"#{File.join(root_path, config[:testingdir])}\"), \"Machine\")")
|
178
|
+
environment_vars.each do |key, value|
|
179
|
+
conn.execute("[Environment]::SetEnvironmentVariable(\"#{key}\", \"#{value}\", \"Machine\")")
|
180
|
+
end
|
106
181
|
else
|
182
|
+
command_env = []
|
183
|
+
environment_vars.each do |key, value|
|
184
|
+
command_env.push("#{key}=#{value}")
|
185
|
+
end
|
186
|
+
if not command_env.empty?
|
187
|
+
command = "env #{command_env.join(' ')} #{command}"
|
188
|
+
end
|
107
189
|
begin
|
108
190
|
conn.execute(sudo("chown -R $USER #{root_path}"))
|
109
191
|
rescue => e
|
110
192
|
error("Failed to chown #{root_path} :: #{e}")
|
111
193
|
end
|
112
194
|
end
|
113
|
-
|
195
|
+
if not only_download_artefacts
|
196
|
+
info("Running Command: #{command}")
|
114
197
|
conn.execute(sudo(command))
|
115
|
-
rescue => e
|
116
|
-
info("Verify command failed :: #{e}")
|
117
198
|
end
|
118
199
|
ensure
|
119
|
-
|
120
|
-
|
200
|
+
if not dont_download_artefacts
|
201
|
+
save.each do |remote, local|
|
202
|
+
unless config[:windows]
|
203
|
+
begin
|
204
|
+
conn.execute(sudo("chmod -R +r #{remote}"))
|
205
|
+
rescue => e
|
206
|
+
error("Failed to chown #{remote} :: #{e}")
|
207
|
+
end
|
208
|
+
end
|
121
209
|
begin
|
122
|
-
|
210
|
+
info("Copying #{remote} to #{local}")
|
211
|
+
conn.download(remote, local)
|
123
212
|
rescue => e
|
124
|
-
error("Failed to
|
213
|
+
error("Failed to copy #{remote} to #{local} :: #{e}")
|
125
214
|
end
|
126
215
|
end
|
127
|
-
begin
|
128
|
-
info("Copying #{remote} to #{local}")
|
129
|
-
conn.download(remote, local)
|
130
|
-
rescue => e
|
131
|
-
error("Failed to copy #{remote} to #{local} :: #{e}")
|
132
|
-
end
|
133
216
|
end
|
134
217
|
end
|
135
218
|
end
|
136
|
-
|
219
|
+
if only_download_artefacts
|
220
|
+
info("[#{name}] Download artefacts completed.")
|
221
|
+
else
|
222
|
+
debug("[#{name}] Verify completed.")
|
223
|
+
end
|
137
224
|
end
|
138
225
|
end
|
139
226
|
end
|
@@ -22,6 +22,7 @@ module Kitchen
|
|
22
22
|
default_config :windows, false
|
23
23
|
default_config :enable_filenames, false
|
24
24
|
default_config :from_filenames, []
|
25
|
+
default_config :prepend, false
|
25
26
|
|
26
27
|
def call(state)
|
27
28
|
info("[#{name}] Verify on instance #{instance.name} with state=#{state}")
|
@@ -29,12 +30,13 @@ module Kitchen
|
|
29
30
|
if ENV['KITCHEN_TESTS']
|
30
31
|
ENV['KITCHEN_TESTS'].split(' ').each{|test| config[:tests].push(test)}
|
31
32
|
end
|
32
|
-
if config[:enable_filenames] and ENV['CHANGE_TARGET'] and ENV['BRANCH_NAME']
|
33
|
+
if config[:enable_filenames] and ENV['CHANGE_TARGET'] and ENV['BRANCH_NAME'] and ENV['FORCE_FULL'] != 'true'
|
33
34
|
require 'git'
|
34
35
|
repo = Git.open('.')
|
35
|
-
|
36
|
+
config[:from_filenames] = repo.diff("origin/#{ENV['CHANGE_TARGET']}", "origin/#{ENV['BRANCH_NAME']}").name_status.keys.select{|file| file.end_with?('.py')}
|
36
37
|
end
|
37
38
|
command = [
|
39
|
+
(config[:prepend] ? "#{config[:prepend]}" : ''),
|
38
40
|
(config[:windows] ? 'python.exe' : config[:python_bin]),
|
39
41
|
File.join(root_path, config[:testingdir], '/tests/runtests.py'),
|
40
42
|
'--sysinfo',
|
@@ -47,7 +49,7 @@ module Kitchen
|
|
47
49
|
(config[:xml] ? "--xml=#{config[:xml]}" : ''),
|
48
50
|
config[:types].collect{|type| "--#{type}"}.join(' '),
|
49
51
|
config[:tests].collect{|test| "-n #{test}"}.join(' '),
|
50
|
-
|
52
|
+
(config[:from_filenames].any? ? "--from-filenames=#{config[:from_filenames].join(',')}" : ''),
|
51
53
|
'2>&1',
|
52
54
|
].join(' ')
|
53
55
|
if config[:windows]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-salt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaltStack Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -181,8 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.5.2.3
|
184
|
+
rubygems_version: 3.0.3
|
186
185
|
signing_key:
|
187
186
|
specification_version: 4
|
188
187
|
summary: salt provisioner for test-kitchen
|