kitchen-salt 0.6.0 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/kitchen/provisioner/formula-fetch.sh +3 -3
- data/lib/kitchen/provisioner/install.erb +6 -1
- data/lib/kitchen/provisioner/install_win.erb +2 -1
- data/lib/kitchen/provisioner/minion.erb +1 -1
- data/lib/kitchen/provisioner/salt_solo.rb +42 -12
- data/lib/kitchen/verifier/nox.rb +189 -54
- data/lib/kitchen/verifier/runtests.rb +5 -3
- data/lib/kitchen-salt/states.rb +7 -1
- data/lib/kitchen-salt/util.rb +0 -1
- data/lib/kitchen-salt/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f264baa2768e6d4a343d428d316da1fa467f365e012804d0184927bdf441efc3
|
|
4
|
+
data.tar.gz: 8a9608d00cdd30471567e3de85073515d8aab496610f6b7867bcb520f888bb85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ca9f7b27528e62f990a791083606c657a070a856063eef2cc632dfc82ce0c00d0a2a87fd3d46b36b687b165b39f28daafe023e521c5920b4afa79972cac8448
|
|
7
|
+
data.tar.gz: 3c9ea1fbd395c1ee5dc4df1f6899ff980e29477e2ffab63f8395745350834eed1db09d83f566356f5e071df097f1e102884634c3b7df2619cd5ef547e210d136
|
|
@@ -42,15 +42,15 @@ function fetchGitFormula() {
|
|
|
42
42
|
if ! [[ "${FETCHED[*]}" =~ $name ]]; then # dependency not yet fetched
|
|
43
43
|
echo "Fetching: $name"
|
|
44
44
|
if test -e "$GIT_FORMULAS_PATH/$name"; then
|
|
45
|
-
pushd "$GIT_FORMULAS_PATH/$name" &>/dev/null
|
|
45
|
+
pushd "$GIT_FORMULAS_PATH/$name" &>/dev/null || exit
|
|
46
46
|
test ! -e .git || git pull -r
|
|
47
|
-
popd &>/dev/null
|
|
47
|
+
popd &>/dev/null || exit
|
|
48
48
|
else
|
|
49
49
|
echo "git clone $source $GIT_FORMULAS_PATH/$name -b $branch"
|
|
50
50
|
git clone "$source" "$GIT_FORMULAS_PATH/$name" -b "$branch"
|
|
51
51
|
fi
|
|
52
52
|
# install dependencies
|
|
53
|
-
FETCHED+=($name)
|
|
53
|
+
FETCHED+=("$name")
|
|
54
54
|
if [ -e "$GIT_FORMULAS_PATH/$name/metadata.yml" ]; then
|
|
55
55
|
fetchDependencies "$GIT_FORMULAS_PATH/$name/metadata.yml"
|
|
56
56
|
fi
|
|
@@ -40,7 +40,12 @@ then
|
|
|
40
40
|
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "pip" ]
|
|
41
41
|
then
|
|
42
42
|
echo "Make sure setuptools and pip are new enough"
|
|
43
|
-
|
|
43
|
+
export REQUIREMENTS_FILE=$(mktemp)
|
|
44
|
+
echo "setuptools >=30,<54.* ; python_version < '3.6'" > $REQUIREMENTS_FILE
|
|
45
|
+
echo "setuptools >=30,!=50.*,!=51.*,!=52.*; python_version >= '3.6'" > $REQUIREMENTS_FILE
|
|
46
|
+
echo "pip >=9,<21.0.0 ; python_version < '3.6'" >> $REQUIREMENTS_FILE
|
|
47
|
+
echo "pip >=9 ; python_version >= '3.6'" >> $REQUIREMENTS_FILE
|
|
48
|
+
#{sudo(salt_pip_bin)} install -r $REQUIREMENTS_FILE
|
|
44
49
|
echo #{sudo(salt_pip_bin)} #{salt_pip_install_command} #{salt_pip_pkg}
|
|
45
50
|
#{sudo(salt_pip_bin)} #{salt_pip_install_command} #{salt_pip_pkg}
|
|
46
51
|
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "apt" ]
|
|
@@ -5,7 +5,7 @@ salt_version = config[:salt_version]
|
|
|
5
5
|
bootstrap_options = config[:salt_bootstrap_options] % [salt_version]
|
|
6
6
|
|
|
7
7
|
<<-POWERSHELL
|
|
8
|
-
if (
|
|
8
|
+
if (Get-Command #{salt_call}) {
|
|
9
9
|
$installed_version = $(#{salt_call} --version).split(' ')[1]
|
|
10
10
|
}
|
|
11
11
|
if (-Not $(Test-Path c:\\temp)) {
|
|
@@ -15,6 +15,7 @@ if (-Not $installed_version -And "#{salt_install}" -eq "bootstrap") {
|
|
|
15
15
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
16
16
|
(New-Object net.webclient).DownloadFile("#{salt_url}", "c:\\temp\\salt_bootstrap.ps1")
|
|
17
17
|
#{sudo('powershell')} c:\\temp\\salt_bootstrap.ps1 #{bootstrap_options}
|
|
18
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
|
|
18
19
|
}
|
|
19
20
|
$FULL_SALT_VERSION = $(#{salt_call} --version).split(' ')[1]
|
|
20
21
|
if ($FULL_SALT_VERSION) {
|
|
@@ -9,7 +9,7 @@ file_roots:
|
|
|
9
9
|
- <%= os_join(config[:root_path], config[:salt_spm_root], 'salt') %>
|
|
10
10
|
|
|
11
11
|
pillar_roots:
|
|
12
|
-
<%= config[:salt_env] %>:
|
|
12
|
+
<%= config[:pillar_env] || config[:salt_env] %>:
|
|
13
13
|
- <%= os_join(config[:root_path], config[:salt_pillar_root]) %>
|
|
14
14
|
- <%= os_join(config[:root_path], config[:salt_spm_root], 'pillar') %>
|
|
15
15
|
|
|
@@ -47,23 +47,25 @@ module Kitchen
|
|
|
47
47
|
is_file_root: false,
|
|
48
48
|
local_salt_root: nil,
|
|
49
49
|
omnibus_cachier: false,
|
|
50
|
+
pillar_env: nil,
|
|
50
51
|
pillars_from_directories: [],
|
|
51
52
|
pip_bin: 'pip',
|
|
52
53
|
pip_editable: false,
|
|
53
54
|
pip_extra_index_url: [],
|
|
54
|
-
pip_index_url: 'https://pypi.
|
|
55
|
+
pip_index_url: 'https://pypi.org/simple/',
|
|
55
56
|
pip_pkg: 'salt==%s',
|
|
56
57
|
remote_states: nil,
|
|
57
58
|
require_chef: true,
|
|
58
|
-
salt_apt_repo_key: 'https://repo.
|
|
59
|
-
salt_apt_repo: 'https://repo.
|
|
59
|
+
salt_apt_repo_key: 'https://repo.saltproject.io/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub',
|
|
60
|
+
salt_apt_repo: 'https://repo.saltproject.io/apt/ubuntu/16.04/amd64',
|
|
60
61
|
salt_bootstrap_options: '',
|
|
61
|
-
salt_bootstrap_url: 'https://bootstrap.
|
|
62
|
+
salt_bootstrap_url: 'https://bootstrap.saltproject.io',
|
|
62
63
|
salt_config: '/etc/salt',
|
|
63
64
|
salt_copy_filter: [],
|
|
64
65
|
salt_env: 'base',
|
|
65
66
|
salt_file_root: '/srv/salt',
|
|
66
67
|
salt_force_color: false,
|
|
68
|
+
salt_enable_color: true,
|
|
67
69
|
salt_install: 'bootstrap',
|
|
68
70
|
salt_minion_config_dropin_files: [],
|
|
69
71
|
salt_minion_config_template: nil,
|
|
@@ -75,10 +77,10 @@ module Kitchen
|
|
|
75
77
|
salt_spm_root: '/srv/spm',
|
|
76
78
|
salt_state_top: '/srv/salt/top.sls',
|
|
77
79
|
salt_version: 'latest',
|
|
78
|
-
salt_yum_repo_key: 'https://repo.
|
|
79
|
-
salt_yum_repo_latest: 'https://repo.
|
|
80
|
-
salt_yum_repo: 'https://repo.
|
|
81
|
-
salt_yum_rpm_key: 'https://repo.
|
|
80
|
+
salt_yum_repo_key: 'https://repo.saltproject.io/yum/redhat/$releasever/$basearch/archive/%s/SALTSTACK-GPG-KEY.pub',
|
|
81
|
+
salt_yum_repo_latest: 'https://repo.saltproject.io/yum/redhat/salt-repo-latest-2.el7.noarch.rpm',
|
|
82
|
+
salt_yum_repo: 'https://repo.saltproject.io/yum/redhat/$releasever/$basearch/archive/%s',
|
|
83
|
+
salt_yum_rpm_key: 'https://repo.saltproject.io/yum/redhat/7/x86_64/archive/%s/SALTSTACK-GPG-KEY.pub',
|
|
82
84
|
state_collection: false,
|
|
83
85
|
state_top_from_file: false,
|
|
84
86
|
state_top: {},
|
|
@@ -89,7 +91,7 @@ module Kitchen
|
|
|
89
91
|
|
|
90
92
|
WIN_DEFAULT_CONFIG = {
|
|
91
93
|
chef_bootstrap_url: 'https://omnitruck.chef.io/install.ps1',
|
|
92
|
-
salt_bootstrap_url: 'https://
|
|
94
|
+
salt_bootstrap_url: 'https://winbootstrap.saltproject.io/develop'
|
|
93
95
|
}.freeze
|
|
94
96
|
|
|
95
97
|
# salt-call version that supports the undocumented --retcode-passthrough command
|
|
@@ -106,6 +108,7 @@ module Kitchen
|
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
def install_command
|
|
111
|
+
return unless config[:salt_install]
|
|
109
112
|
unless config[:salt_install] == 'pip' || config[:install_after_init_environment]
|
|
110
113
|
setup_salt
|
|
111
114
|
end
|
|
@@ -123,6 +126,7 @@ module Kitchen
|
|
|
123
126
|
#{config[:prepare_salt_environment]}
|
|
124
127
|
PREPARE
|
|
125
128
|
end
|
|
129
|
+
return cmd unless config[:salt_install]
|
|
126
130
|
if config[:salt_install] == 'pip' || config[:install_after_init_environment]
|
|
127
131
|
cmd << setup_salt
|
|
128
132
|
end
|
|
@@ -136,8 +140,13 @@ module Kitchen
|
|
|
136
140
|
# if salt_verison is set, bootstrap is being used & bootstrap_options is empty,
|
|
137
141
|
# set the bootstrap_options string to git install the requested version
|
|
138
142
|
if (salt_version != 'latest') && (config[:salt_install] == 'bootstrap') && config[:salt_bootstrap_options].empty?
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
if windows_os?
|
|
144
|
+
debug("Using bootstrap to install #{salt_version}")
|
|
145
|
+
config[:salt_bootstrap_options] = "-version #{salt_version}"
|
|
146
|
+
else
|
|
147
|
+
debug("Using bootstrap git to install #{salt_version}")
|
|
148
|
+
config[:salt_bootstrap_options] = "-P git v#{salt_version}"
|
|
149
|
+
end
|
|
141
150
|
end
|
|
142
151
|
|
|
143
152
|
install_template = if windows_os?
|
|
@@ -208,6 +217,7 @@ module Kitchen
|
|
|
208
217
|
end
|
|
209
218
|
|
|
210
219
|
def prepare_install
|
|
220
|
+
return unless config[:salt_install]
|
|
211
221
|
salt_version = config[:salt_version]
|
|
212
222
|
if config[:salt_install] == 'pip'
|
|
213
223
|
debug('Using pip to install')
|
|
@@ -268,11 +278,24 @@ module Kitchen
|
|
|
268
278
|
cmd << sudo("#{config[:root_path]}/gpgkey.sh;") if config[:gpg_key]
|
|
269
279
|
salt_config_path = config[:salt_config]
|
|
270
280
|
end
|
|
271
|
-
|
|
281
|
+
|
|
282
|
+
if config[:pre_salt_command]
|
|
283
|
+
cmd << "#{config[:pre_salt_command]} && "
|
|
284
|
+
end
|
|
285
|
+
cmd << sudo("#{salt_call}")
|
|
286
|
+
state_output = config[:salt_minion_extra_config][:state_output]
|
|
287
|
+
if state_output
|
|
288
|
+
cmd << " --state-output=#{state_output}"
|
|
289
|
+
else
|
|
290
|
+
cmd << " --state-output=changes"
|
|
291
|
+
end
|
|
292
|
+
cmd << " --config-dir=#{os_join(config[:root_path], salt_config_path)}"
|
|
293
|
+
cmd << " state.highstate"
|
|
272
294
|
cmd << " --log-level=#{config[:log_level]}" if config[:log_level]
|
|
273
295
|
cmd << " --id=#{config[:salt_minion_id]}" if config[:salt_minion_id]
|
|
274
296
|
cmd << " test=#{config[:dry_run]}" if config[:dry_run]
|
|
275
297
|
cmd << ' --force-color' if config[:salt_force_color]
|
|
298
|
+
cmd << ' --no-color' if not config[:salt_enable_color]
|
|
276
299
|
if "#{salt_version}" > RETCODE_VERSION || salt_version == 'latest'
|
|
277
300
|
# hope for the best and hope it works eventually
|
|
278
301
|
cmd << ' --retcode-passthrough'
|
|
@@ -404,6 +427,13 @@ module Kitchen
|
|
|
404
427
|
end
|
|
405
428
|
|
|
406
429
|
def prepare_dependencies
|
|
430
|
+
# Dependency scripts are bash scripts only
|
|
431
|
+
# Copying them clobbers the kitchen temp directory
|
|
432
|
+
# with a file named `kitchen`. If adding Windows
|
|
433
|
+
# support for dependencies, relocate into a
|
|
434
|
+
# sub-directory
|
|
435
|
+
return if windows_os?
|
|
436
|
+
|
|
407
437
|
# upload scripts
|
|
408
438
|
sandbox_scripts_path = File.join(sandbox_path, config[:salt_config], 'scripts')
|
|
409
439
|
info("Preparing scripts into #{config[:salt_config]}/scripts")
|
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,68 +13,130 @@ 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
|
|
18
|
+
default_config :windows do |verifier|
|
|
19
|
+
verifier.windows_os? ? true : false
|
|
20
|
+
end
|
|
17
21
|
default_config :verbose, false
|
|
18
22
|
default_config :run_destructive, false
|
|
19
|
-
default_config :
|
|
20
|
-
default_config :proxy_tests, false
|
|
21
|
-
default_config :pytest, false
|
|
23
|
+
default_config :runtests, false
|
|
22
24
|
default_config :coverage, false
|
|
23
25
|
default_config :junitxml, false
|
|
24
26
|
default_config :from_filenames, []
|
|
27
|
+
default_config :from_filenames_basename, "changed-files-list.txt"
|
|
28
|
+
default_config :from_filenames_path, false
|
|
25
29
|
default_config :enable_filenames, false
|
|
26
30
|
default_config :passthrough_opts, []
|
|
27
31
|
default_config :output_columns, 120
|
|
28
32
|
default_config :sysinfo, true
|
|
33
|
+
default_config :sys_stats, false
|
|
34
|
+
default_config :environment_vars, {}
|
|
35
|
+
default_config :zip_windows_artifacts, false
|
|
29
36
|
|
|
30
37
|
def call(state)
|
|
31
|
-
|
|
38
|
+
create_sandbox
|
|
39
|
+
debug("Detected platform for instance #{instance.name}: #{instance.platform.os_type}. Config's windows setting value: #{config[:windows]}")
|
|
40
|
+
if (ENV['ONLY_DOWNLOAD_ARTEFACTS'] || '') == '1'
|
|
41
|
+
only_download_artefacts = true
|
|
42
|
+
else
|
|
43
|
+
only_download_artefacts = false
|
|
44
|
+
end
|
|
45
|
+
if (ENV['DONT_DOWNLOAD_ARTEFACTS'] || '') == '1'
|
|
46
|
+
dont_download_artefacts = true
|
|
47
|
+
else
|
|
48
|
+
dont_download_artefacts = false
|
|
49
|
+
end
|
|
50
|
+
if only_download_artefacts and dont_download_artefacts
|
|
51
|
+
error_msg = "The environment variables 'ONLY_DOWNLOAD_ARTEFACTS' or 'DONT_DOWNLOAD_ARTEFACTS' cannot be both set to '1'"
|
|
52
|
+
error(error_msg)
|
|
53
|
+
raise ActionFailed, error_msg
|
|
54
|
+
end
|
|
55
|
+
if only_download_artefacts
|
|
56
|
+
info("[#{name}] Only downloading artefacts from instance #{instance.name} with state=#{state}")
|
|
57
|
+
else
|
|
58
|
+
info("[#{name}] Verify on instance #{instance.name} with state=#{state}")
|
|
59
|
+
if ENV['NOX_ENABLE_FROM_FILENAMES']
|
|
60
|
+
config[:enable_filenames] = true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if config[:enable_filenames] and ENV['CHANGE_TARGET'] and ENV['BRANCH_NAME'] and ENV['FORCE_FULL'] != 'true'
|
|
64
|
+
require 'git'
|
|
65
|
+
repo = Git.open(Dir.pwd)
|
|
66
|
+
config[:from_filenames] = repo.diff("origin/#{ENV['CHANGE_TARGET']}",
|
|
67
|
+
"origin/#{ENV['BRANCH_NAME']}").name_status.keys.select{|file| file.end_with?('.py')}
|
|
68
|
+
debug("Populating `from_filenames` with: #{config[:from_filenames]}")
|
|
69
|
+
if config[:windows] && config[:from_filenames].any?
|
|
70
|
+
# On windows, if the changed files list is too big, it will error.
|
|
71
|
+
# Let's then pass an absolute path to a text file which contains the list of changed
|
|
72
|
+
# files, one per line.
|
|
73
|
+
config[:from_filenames_path] = File.join(sandbox_path, config[:from_filenames_basename])
|
|
74
|
+
from_filenames_contents = "#{config[:from_filenames].join('\n')}"
|
|
75
|
+
File.open(config[:from_filenames_path], "w") { |f| f.write from_filenames_contents }
|
|
76
|
+
info("Created #{config[:from_filenames_path]} with contents:\n#{from_filenames_contents}")
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
32
80
|
root_path = (config[:windows] ? '%TEMP%\\kitchen' : '/tmp/kitchen')
|
|
33
81
|
if ENV['KITCHEN_TESTS']
|
|
34
82
|
ENV['KITCHEN_TESTS'].split(' ').each{|test| config[:tests].push(test)}
|
|
35
83
|
end
|
|
36
|
-
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
|
|
84
|
+
|
|
85
|
+
if ENV['NOX_PASSTHROUGH_OPTS']
|
|
86
|
+
ENV['NOX_PASSTHROUGH_OPTS'].split(' ').each{|opt| config[:passthrough_opts].push(opt)}
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
if ENV['NOX_ENV_NAME']
|
|
90
|
+
noxenv = ENV['NOX_ENV_NAME']
|
|
91
|
+
elsif config[:runtests] == true
|
|
92
|
+
noxenv = "runtests-zeromq"
|
|
40
93
|
else
|
|
41
|
-
|
|
42
|
-
|
|
94
|
+
# Default to pytest-zeromq
|
|
95
|
+
noxenv = "pytest-zeromq"
|
|
43
96
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
97
|
+
|
|
98
|
+
# Is the nox env already including the Python version?
|
|
99
|
+
if not noxenv.match(/^(.*)-([\d]{1})(\.([\d]{1}))?$/)
|
|
100
|
+
# Nox env's are not py<python-version> named, they just use the <python-version>
|
|
101
|
+
# Additionally, nox envs are parametrised to enable or disable test coverage
|
|
102
|
+
# So, the line below becomes something like:
|
|
103
|
+
# runtests-2(coverage=True)
|
|
104
|
+
# pytest-3(coverage=False)
|
|
105
|
+
suite = instance.suite.name.gsub('py', '').gsub('2', '2.7')
|
|
106
|
+
noxenv = "#{noxenv}-#{suite}"
|
|
47
107
|
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'})"
|
|
108
|
+
noxenv = "#{noxenv}(coverage=#{config[:coverage] ? 'True' : 'False'})"
|
|
55
109
|
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
110
|
+
if noxenv.include? "pytest"
|
|
111
|
+
tests = config[:tests].join(' ')
|
|
112
|
+
if config[:sys_stats]
|
|
113
|
+
sys_stats = '--sys-stats'
|
|
114
|
+
if not config[:verbose]
|
|
115
|
+
config[:verbose] = true
|
|
116
|
+
end
|
|
117
|
+
else
|
|
118
|
+
sys_stats = ''
|
|
119
|
+
end
|
|
120
|
+
elsif noxenv.include? "runtests"
|
|
121
|
+
tests = config[:tests].collect{|test| "-n #{test}"}.join(' ')
|
|
122
|
+
sys_stats = ''
|
|
61
123
|
end
|
|
62
124
|
|
|
63
125
|
if config[:junitxml]
|
|
64
126
|
junitxml = File.join(root_path, config[:testingdir], 'artifacts', 'xml-unittests-output')
|
|
65
|
-
if
|
|
66
|
-
junitxml = "--junitxml=#{File.join(junitxml,
|
|
127
|
+
if noxenv.include? "pytest"
|
|
128
|
+
junitxml = "--junitxml=#{File.join(junitxml, "test-results-#{DateTime.now.strftime('%Y%m%d%H%M%S.%L')}.xml")}"
|
|
67
129
|
else
|
|
68
130
|
junitxml = "--xml=#{junitxml}"
|
|
69
131
|
end
|
|
70
132
|
end
|
|
71
133
|
|
|
72
134
|
# Be sure to copy the remote artifacts directory to the local machine
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
135
|
+
if config[:windows]
|
|
136
|
+
save = {'$env:KitchenTestingDir/artifacts/' => "#{Dir.pwd}"}
|
|
137
|
+
else
|
|
138
|
+
save = {"#{File.join(root_path, config[:testingdir], 'artifacts')}/" => "#{Dir.pwd}"}
|
|
139
|
+
end
|
|
76
140
|
# Hash insert order matters, that's why we define a new one and merge
|
|
77
141
|
# the one from config
|
|
78
142
|
save.merge!(config[:save])
|
|
@@ -80,60 +144,131 @@ module Kitchen
|
|
|
80
144
|
command = [
|
|
81
145
|
'nox',
|
|
82
146
|
"-f #{File.join(root_path, config[:testingdir], 'noxfile.py')}",
|
|
147
|
+
(config[:windows] ? "--envdir=C:\\Windows\\Temp\\nox" : ""),
|
|
83
148
|
(config[:windows] ? "-e #{noxenv}" : "-e '#{noxenv}'"),
|
|
84
149
|
'--',
|
|
85
150
|
"--output-columns=#{config[:output_columns]}",
|
|
151
|
+
sys_stats,
|
|
86
152
|
(config[:sysinfo] ? '--sysinfo' : ''),
|
|
87
153
|
(config[:junitxml] ? junitxml : ''),
|
|
88
|
-
(config[:windows] ? "--names-file=#{root_path}\\testing\\tests\\whitelist.txt" : ''),
|
|
89
154
|
(config[:verbose] ? '-vv' : '-v'),
|
|
90
|
-
(config[:run_destructive] ?
|
|
91
|
-
(config[:ssh_tests] ? "--ssh-tests" : ''),
|
|
92
|
-
(config[:proxy_tests] ? "--proxy-tests" : ''),
|
|
155
|
+
(config[:run_destructive] ? '--run-destructive' : ''),
|
|
93
156
|
config[:passthrough_opts].join(' '),
|
|
94
|
-
(config[:from_filenames].any? ? "--from-filenames=#{config[:from_filenames].join(',')}" : ''),
|
|
95
|
-
tests,
|
|
96
157
|
].join(' ')
|
|
158
|
+
|
|
159
|
+
if tests.nil? || tests.empty?
|
|
160
|
+
# If we're not targetting specific tests...
|
|
161
|
+
extra_command = []
|
|
162
|
+
if config[:windows]
|
|
163
|
+
extra_command.push("--names-file=#{root_path}\\testing\\tests\\whitelist.txt")
|
|
164
|
+
if config[:from_filenames_path]
|
|
165
|
+
# Add the required command flag for the tests runner
|
|
166
|
+
extra_command.push("--from-filenames=#{root_path}\\testing\\#{config[:from_filenames_basename]}")
|
|
167
|
+
end
|
|
168
|
+
else
|
|
169
|
+
if config[:from_filenames].any?
|
|
170
|
+
extra_command.push("--from-filenames=#{config[:from_filenames].join(',')}")
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
command = "#{command} #{extra_command.join(' ')}"
|
|
174
|
+
else
|
|
175
|
+
command = "#{command} #{tests}"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
environment_vars = {}
|
|
179
|
+
if ENV['CI'] || ENV['DRONE'] || ENV['JENKINS_URL']
|
|
180
|
+
environment_vars['CI'] = 1
|
|
181
|
+
end
|
|
182
|
+
# Hash insert order matters, that's why we define a new one and merge
|
|
183
|
+
# the one from config
|
|
184
|
+
environment_vars.merge!(config[:environment_vars])
|
|
185
|
+
|
|
186
|
+
# Strip trailing whitespace
|
|
187
|
+
command = command.rstrip
|
|
188
|
+
|
|
97
189
|
if config[:windows]
|
|
98
190
|
command = "cmd.exe /c --% \"#{command}\" 2>&1"
|
|
99
191
|
end
|
|
100
|
-
info("Running Command: #{command}")
|
|
101
192
|
instance.transport.connection(state) do |conn|
|
|
102
193
|
begin
|
|
103
194
|
if config[:windows]
|
|
104
195
|
conn.execute('$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")')
|
|
105
|
-
conn.execute("$env:PythonPath = [Environment]::ExpandEnvironmentVariables(\"#{root_path}
|
|
196
|
+
conn.execute("$env:PythonPath = [Environment]::ExpandEnvironmentVariables(\"#{File.join(root_path, config[:testingdir])}\")")
|
|
197
|
+
conn.execute("[Environment]::SetEnvironmentVariable(\"KitchenTestingDir\", [Environment]::ExpandEnvironmentVariables(\"#{File.join(root_path, config[:testingdir])}\"), \"Machine\")")
|
|
198
|
+
environment_vars.each do |key, value|
|
|
199
|
+
conn.execute("[Environment]::SetEnvironmentVariable(\"#{key}\", \"#{value}\", \"Machine\")")
|
|
200
|
+
end
|
|
106
201
|
else
|
|
202
|
+
command_env = []
|
|
203
|
+
environment_vars.each do |key, value|
|
|
204
|
+
command_env.push("#{key}=#{value}")
|
|
205
|
+
end
|
|
206
|
+
if not command_env.empty?
|
|
207
|
+
command = "env #{command_env.join(' ')} #{command}"
|
|
208
|
+
end
|
|
107
209
|
begin
|
|
108
210
|
conn.execute(sudo("chown -R $USER #{root_path}"))
|
|
109
211
|
rescue => e
|
|
110
212
|
error("Failed to chown #{root_path} :: #{e}")
|
|
111
213
|
end
|
|
112
214
|
end
|
|
113
|
-
|
|
215
|
+
if not only_download_artefacts
|
|
216
|
+
if config[:from_filenames_path]
|
|
217
|
+
upload_file_path = "$env:KitchenTestingDir\\#{config[:from_filenames_basename]}"
|
|
218
|
+
info("Uploading #{config[:from_filenames_path]} to #{upload_file_path} on #{instance.to_str}")
|
|
219
|
+
conn.upload(config[:from_filenames_path], "#{upload_file_path}")
|
|
220
|
+
end
|
|
221
|
+
info("Running Command: #{command}")
|
|
114
222
|
conn.execute(sudo(command))
|
|
115
|
-
rescue => e
|
|
116
|
-
info("Verify command failed :: #{e}")
|
|
117
223
|
end
|
|
118
224
|
ensure
|
|
119
|
-
|
|
120
|
-
|
|
225
|
+
if not dont_download_artefacts
|
|
226
|
+
save.each do |remote, local|
|
|
227
|
+
if config[:windows]
|
|
228
|
+
if config[:zip_windows_artifacts]
|
|
229
|
+
begin
|
|
230
|
+
conn.execute("7z.exe a #{remote}artifacts.zip #{remote}")
|
|
231
|
+
rescue => e
|
|
232
|
+
begin
|
|
233
|
+
info("7z.exe failed, attempting zip with powershell Compress-Archive")
|
|
234
|
+
conn.execute("powershell Compress-Archive #{remote} #{remote}artifacts.zip -Force")
|
|
235
|
+
rescue => e2
|
|
236
|
+
error("Failed to create zip: #{e2}")
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
else
|
|
241
|
+
begin
|
|
242
|
+
conn.execute(sudo("chmod -R +r #{remote}"))
|
|
243
|
+
rescue => e
|
|
244
|
+
error("Failed to chown #{remote} :: #{e}")
|
|
245
|
+
end
|
|
246
|
+
end
|
|
121
247
|
begin
|
|
122
|
-
|
|
248
|
+
info("Copying #{remote} to #{local}")
|
|
249
|
+
if config[:windows]
|
|
250
|
+
if config[:zip_windows_artifacts]
|
|
251
|
+
conn.download(remote + "artifacts.zip", local + "/artifacts.zip")
|
|
252
|
+
system('unzip -o artifacts.zip')
|
|
253
|
+
system('rm artifacts.zip')
|
|
254
|
+
end
|
|
255
|
+
else
|
|
256
|
+
conn.download(remote, local)
|
|
257
|
+
end
|
|
123
258
|
rescue => e
|
|
124
|
-
error("Failed to
|
|
259
|
+
error("Failed to copy #{remote} to #{local} :: #{e}")
|
|
125
260
|
end
|
|
126
261
|
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
262
|
end
|
|
134
263
|
end
|
|
135
264
|
end
|
|
136
|
-
|
|
265
|
+
if only_download_artefacts
|
|
266
|
+
info("[#{name}] Download artefacts completed.")
|
|
267
|
+
else
|
|
268
|
+
debug("[#{name}] Verify completed.")
|
|
269
|
+
end
|
|
270
|
+
ensure
|
|
271
|
+
cleanup_sandbox
|
|
137
272
|
end
|
|
138
273
|
end
|
|
139
274
|
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]
|
data/lib/kitchen-salt/states.rb
CHANGED
|
@@ -20,6 +20,9 @@ module Kitchen
|
|
|
20
20
|
# load a top.sls from disk
|
|
21
21
|
if config[:local_salt_root].nil?
|
|
22
22
|
top_file = 'top.sls'
|
|
23
|
+
unless config[:state_collection].nil?
|
|
24
|
+
top_file = File.join(config[:state_collection], top_file)
|
|
25
|
+
end
|
|
23
26
|
else
|
|
24
27
|
top_file = File.join(config[:local_salt_root], 'salt/top.sls')
|
|
25
28
|
end
|
|
@@ -77,7 +80,7 @@ module Kitchen
|
|
|
77
80
|
cp_r_with_filter(File.join(path, formula), formula_dir, config[:salt_copy_filter])
|
|
78
81
|
|
|
79
82
|
# copy across the _modules etc directories for python implementation
|
|
80
|
-
%w(_modules _states _grains _renderers _returners).each do |extrapath|
|
|
83
|
+
%w(_modules _states _grains _renderers _returners _runners _utils).each do |extrapath|
|
|
81
84
|
prepare_formula_dir(path, extrapath)
|
|
82
85
|
end
|
|
83
86
|
end
|
|
@@ -96,6 +99,9 @@ module Kitchen
|
|
|
96
99
|
|
|
97
100
|
if config[:local_salt_root].nil?
|
|
98
101
|
states_location = config[:kitchen_root]
|
|
102
|
+
unless config[:state_collection].nil?
|
|
103
|
+
states_location = File.join(states_location, config[:state_collection])
|
|
104
|
+
end
|
|
99
105
|
else
|
|
100
106
|
states_location = File.join(config[:local_salt_root], 'salt')
|
|
101
107
|
end
|
data/lib/kitchen-salt/util.rb
CHANGED
data/lib/kitchen-salt/version.rb
CHANGED
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SaltStack Inc
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hashie
|
|
@@ -166,7 +166,7 @@ homepage: https://github.com/saltstack/kitchen-salt
|
|
|
166
166
|
licenses:
|
|
167
167
|
- Apache-2.0
|
|
168
168
|
metadata: {}
|
|
169
|
-
post_install_message:
|
|
169
|
+
post_install_message:
|
|
170
170
|
rdoc_options: []
|
|
171
171
|
require_paths:
|
|
172
172
|
- lib
|
|
@@ -181,9 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
181
181
|
- !ruby/object:Gem::Version
|
|
182
182
|
version: '0'
|
|
183
183
|
requirements: []
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
signing_key:
|
|
184
|
+
rubygems_version: 3.0.3
|
|
185
|
+
signing_key:
|
|
187
186
|
specification_version: 4
|
|
188
187
|
summary: salt provisioner for test-kitchen
|
|
189
188
|
test_files: []
|