kitchen-goss 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce5f8c25a4185a67fa5fe0c3199fc0379f7ca216
4
- data.tar.gz: b9708046daabc4f8f998a25f8d725ce32758dc43
3
+ metadata.gz: 9e96537e1b24496345c539fca26df41d821d98ac
4
+ data.tar.gz: 38c5ea624b276e3736084d9127d53e51455950e4
5
5
  SHA512:
6
- metadata.gz: 11e19b6cca2daf32e7c8dc9410443005626823f71eb7f887a55f416cae13cca993f9de454b81213331c29d06e2b27997e2df38f6ee65e54f40a800a928b900cd
7
- data.tar.gz: e7455947e4ef10287cd8cb120e434e3071f31c20b03e8623ac0b0c1d0b5cc5082ab993db59dcc770546412a2d6e905510f9fac44d888ff18b642769d6a473558
6
+ metadata.gz: 61108525c60316fee3bbb7a3dd35cee962f659a434e0dfb675490bea122b20ff56f53423bee14eb7dd8aa8eb71e432580b6c4f45081b81fb4a3c31476a04bfe0
7
+ data.tar.gz: f1e84433bcb08fa6ee8d22cae4c48a0be7bbc45003f988db4244aecbd0e07402c302009ae4d382c3bbbfdbbb253abb7613ccebf5bc72946b9f7aff139f4e80a1
data/README.md CHANGED
@@ -28,6 +28,12 @@ gem install kitchen-goss-<version>.gem
28
28
  ```yaml
29
29
  verifier :
30
30
  name : "goss"
31
+ sleep : 0
32
+ use_sudo : true
33
+ goss_version : "v0.3.6"
34
+ goss_link : "https://github.com/aelsabbahy/goss/releases/download/$VERSION/goss-linux-${ARCH}"
35
+ goss_var_path : "common.yml"
36
+ env_vars : {"test_uid": 123}
31
37
  ```
32
38
 
33
39
  ## kitchen.yml options
@@ -42,6 +48,7 @@ default_config :validate_output, "documentation"
42
48
  default_config :custom_install_command, nil
43
49
  default_config :goss_link, "https://github.com/aelsabbahy/goss/releases/download/$VERSION/goss-${DISTRO}-${ARCH}"
44
50
  default_config :goss_download_path, "/tmp/goss-${VERSION}-${DISTRO}-${ARCH}"
51
+ default_config :goss_var_path, nil
45
52
  ```
46
53
 
47
54
  ## Test structure
@@ -57,6 +64,7 @@ test/
57
64
  \_goss/
58
65
  \_test1.yml
59
66
  |_test2.yml
67
+ |_common.yml # --vars common.yml with .Vars render, not for goss test
60
68
  ```
61
69
 
62
70
 
@@ -4,7 +4,7 @@ module Kitchen
4
4
  module Verifier
5
5
  class Goss < Kitchen::Verifier::Base
6
6
  require 'mixlib/shellout'
7
- require "kitchen/util"
7
+ require 'kitchen/util'
8
8
  require 'pathname'
9
9
 
10
10
  kitchen_verifier_api_version 1
@@ -14,11 +14,12 @@ module Kitchen
14
14
  default_config :sleep, 0
15
15
  default_config :use_sudo, false
16
16
  default_config :env_vars, {}
17
- default_config :goss_version, "v0.1.5"
18
- default_config :validate_output, "documentation"
17
+ default_config :goss_version, 'v0.3.6'
18
+ default_config :validate_output, 'documentation'
19
19
  default_config :custom_install_command, nil
20
- default_config :goss_link, "https://github.com/aelsabbahy/goss/releases/download/$VERSION/goss-${DISTRO}-${ARCH}"
21
- default_config :goss_download_path, "/tmp/goss-${VERSION}-${DISTRO}-${ARCH}"
20
+ default_config :goss_link, 'https://github.com/aelsabbahy/goss/releases/download/$VERSION/goss-${DISTRO}-${ARCH}'
21
+ default_config :goss_download_path, '/tmp/goss-${VERSION}-${DISTRO}-${ARCH}'
22
+ default_config :goss_var_path, nil
22
23
 
23
24
  def install_command
24
25
  # If cutom install
@@ -54,7 +55,7 @@ module Kitchen
54
55
  # (see Base#init_command)
55
56
  def init_command
56
57
  return if local_suite_files.empty?
57
- debug("Remove root_path on remote server.")
58
+ debug('Remove root_path on remote server.')
58
59
  <<-CMD
59
60
  suite_dir="#{config[:root_path]}"
60
61
  if [ "${suite_dir}" = "x" ]; then
@@ -74,19 +75,19 @@ module Kitchen
74
75
  # @raise [ActionFailed] if the action could not be completed
75
76
  def call(state)
76
77
  create_sandbox
77
- sandbox_dirs = Dir.glob(File.join(sandbox_path, "*"))
78
+ sandbox_dirs = Dir.glob(File.join(sandbox_path, '*'))
78
79
 
79
80
  instance.transport.connection(state) do |conn|
80
81
  conn.execute(install_command)
81
82
  conn.execute(init_command)
82
83
  info("Transferring files to #{instance.to_str}")
83
84
  conn.upload(sandbox_dirs, config[:root_path])
84
- debug("Transfer complete")
85
+ debug('Transfer complete')
85
86
  conn.execute(prepare_command)
86
87
  conn.execute(run_command)
87
88
  end
88
89
  rescue Kitchen::Transport::TransportFailed => ex
89
- if ex.message .include? "<TEST EXECUTION FAILED>"
90
+ if ex.message .include? '<TEST EXECUTION FAILED>'
90
91
  raise ActionFailed, "Action #verify failed for #{instance.to_str}."
91
92
  else
92
93
  raise ActionFailed, ex.message
@@ -99,7 +100,7 @@ module Kitchen
99
100
  def run_command
100
101
  return if local_suite_files.empty?
101
102
 
102
- debug("Running tests")
103
+ debug('Running tests')
103
104
  prefix_command(wrap_shell_code(Util.outdent!(<<-CMD)))
104
105
  set +e
105
106
  #{goss_filename_flags}
@@ -115,9 +116,9 @@ module Kitchen
115
116
  base = File.join(config[:test_base_path], config[:suite_name])
116
117
 
117
118
  local_suite_files.each do |src|
118
- dest = File.join(sandbox_suites_dir, src.sub("#{base}/", ""))
119
+ dest = File.join(sandbox_suites_dir, src.sub("#{base}/", ''))
119
120
  FileUtils.mkdir_p(File.dirname(dest))
120
- FileUtils.cp(src, dest, :preserve => true)
121
+ FileUtils.cp(src, dest, preserve: true)
121
122
  end
122
123
  end
123
124
 
@@ -129,8 +130,8 @@ module Kitchen
129
130
  # @api private
130
131
  def local_suite_files
131
132
  base = File.join(config[:test_base_path], config[:suite_name])
132
- glob = File.join(base, "goss/**/*")
133
- #testfiles = Dir.glob(glob).reject { |f| File.directory?(f) }
133
+ glob = File.join(base, 'goss/**/*')
134
+ # testfiles = Dir.glob(glob).reject { |f| File.directory?(f) }
134
135
  Dir.glob(glob).reject { |f| File.directory?(f) }
135
136
  end
136
137
 
@@ -143,7 +144,7 @@ module Kitchen
143
144
  # @return [String] path to suites directory under sandbox path
144
145
  # @api private
145
146
  def sandbox_suites_dir
146
- File.join(sandbox_path, "suites")
147
+ File.join(sandbox_path, 'suites')
147
148
  end
148
149
 
149
150
  def env_vars
@@ -151,12 +152,26 @@ module Kitchen
151
152
  config[:env_vars].map { |k, v| "#{k}=#{v}" }.join(' ')
152
153
  end
153
154
 
155
+ def remote_var_file
156
+ base_path = File.join(config[:test_base_path], config[:suite_name])
157
+ remote_base_path = File.join(config[:root_path], 'suites')
158
+ result = ''
159
+ local_suite_files.each do |src|
160
+ if File.basename(src) == config[:goss_var_path]
161
+ result = src.sub(base_path, remote_base_path)
162
+ end
163
+ end
164
+ result
165
+ end
166
+
154
167
  # @return [String] the run command to execute tests
155
168
  # @api private
156
169
  def run_test_command
157
170
  command = config[:goss_download_path]
158
171
  command = "sudo -E #{command}" if !config[:use_sudo] == true
159
- command = "#{env_vars} #{command}" if !config[:env_vars].none?
172
+ command = "#{env_vars} #{command}" if config[:env_vars].any?
173
+ command = "#{command} --vars #{remote_var_file}" if config[:goss_var_path]
174
+ puts command
160
175
 
161
176
  <<-CMD
162
177
  if [ ! -x "#{config[:goss_download_path]}" ]; then
@@ -183,7 +198,7 @@ module Kitchen
183
198
  end
184
199
 
185
200
  def goss_filename_flags
186
- <<-CMD
201
+ <<-CMD
187
202
  ## Set the flags for GOSS command path
188
203
  VERSION="#{config[:goss_version]}"
189
204
  DISTRO="$(uname)"
@@ -193,15 +208,39 @@ module Kitchen
193
208
  else
194
209
  ARCH="386"
195
210
  fi
211
+
212
+ if [ -f /etc/os-release ]; then
213
+
214
+ if [ "$(grep -i 'ubuntu' /etc/os-release)" != "" ]; then
215
+ OS="ubuntu"
216
+ fi
217
+ if [ "$(grep -i 'centos' /etc/os-release)" != "" ]; then
218
+ OS="centos"
219
+ fi
220
+ if [ "$(grep -i '7' /etc/os-release)" != "" ]; then
221
+ VER='7'
222
+ fi
223
+ if [ "$(grep -i '16.04' /etc/os-release)" != "" ]; then
224
+ VER='16.04'
225
+ fi
226
+ else
227
+ OS="centos"
228
+ VER="6"
229
+ fi
230
+
231
+ OS_VERSION=${OS}${VER}
232
+ echo $OS_VERSION
196
233
  CMD
197
234
  end
198
235
 
199
236
  def get_test_name
200
237
  base_path = File.join(config[:test_base_path], config[:suite_name])
201
- remote_base_path = File.join(config[:root_path], "suites")
202
- all_tests = ""
238
+ remote_base_path = File.join(config[:root_path], 'suites')
239
+ all_tests = ''
203
240
  local_suite_files.each do |test_file|
204
- all_tests += " " + test_file.sub(base_path, remote_base_path)
241
+ if File.basename(test_file) != config[:goss_var_path] && File.basename(test_file).end_with?('.yml')
242
+ all_tests += ' ' + test_file.sub(base_path, remote_base_path)
243
+ end
205
244
  end
206
245
  all_tests
207
246
  end
@@ -215,7 +254,6 @@ module Kitchen
215
254
  sleep 1
216
255
  end
217
256
  end
218
-
219
257
  end
220
258
  end
221
- end
259
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kitchen
4
4
  module Verifier
5
- GOSS_VERSION = '0.1.0'
5
+ GOSS_VERSION = '0.1.1'.freeze
6
6
  end
7
- end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-goss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adham Helal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-31 00:00:00.000000000 Z
11
+ date: 2019-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project: "[none]"
87
- rubygems_version: 2.5.2
87
+ rubygems_version: 2.5.2.3
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: A test-kitchen verifier plugin for GOSS