kitchen-dokken 2.9.0 → 2.11.2

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
  SHA256:
3
- metadata.gz: 44d4ff0b315649f0f9df9cd54cd86419b487d63ea5d71826a0a0962502ca34ca
4
- data.tar.gz: d8710f925f0cfb62f2a00aedaa1fe85d68fa6976a469a469e123ec1ce8e9bcd9
3
+ metadata.gz: ef0d3aea1c2839a2674ed7986dba589c8e672a19a600bdf9173689d286414160
4
+ data.tar.gz: ad29a7651abca534ff753140b67408adfa5e7a8c44252b810925a68f1ac2ca88
5
5
  SHA512:
6
- metadata.gz: 3619800e7157549da3b19081924d00926280d21a4cd61999117f194d228c2cbc0d674fe4d2cecf390a7f0fb6ac7731917ee55ea11c7a982a639b988427ee93fe
7
- data.tar.gz: e920198f9c34c893971996c03bcce43abf36d7bac808193b26602e0b6e57c04acab9964fa8533e9d2f8898f1a0cad27996bb873ea402b6e614844871694d9131
6
+ metadata.gz: e5056e47e61cd05b666a4058a0eaee09a4fa4907d331088f92ff783c41bd455cc33424ca25ac885b278270c4f8d8ebdc80cf5734d3b7363da6c4d34e1f2e74de
7
+ data.tar.gz: 50bec0744f44a44603dc887c99b3c73009eebe9c02f2832c10aecfa02bc46cea55c19d591d3d08efc409907a80139626bbf356aafbf73017872e607d65c857c9
@@ -15,9 +15,9 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'digest'
18
+ require 'digest' unless defined?(Digest)
19
19
  require 'kitchen'
20
- require 'tmpdir'
20
+ require 'tmpdir' unless defined?(Dir.mktmpdir)
21
21
  require 'docker'
22
22
  require 'lockfile'
23
23
  require_relative '../helpers'
@@ -61,6 +61,7 @@ module Kitchen
61
61
  default_config :userns_host, false
62
62
  default_config :pull_platform_image, true
63
63
  default_config :pull_chef_image, true
64
+ default_config :memory_limit, 0
64
65
 
65
66
  # (see Base#create)
66
67
  def create(state)
@@ -152,9 +153,9 @@ module Kitchen
152
153
  rescue Docker::Error::UnexpectedResponseError => e
153
154
  msg = 'work_image build failed: '
154
155
  msg += JSON.parse(e.to_s.split("\r\n").last)['error'].to_s
155
- msg += '. The common scenerios are incorrect intermediate'
156
+ msg += '. The common scenarios are incorrect intermediate '
156
157
  msg += 'instructions such as not including `-y` on an `apt-get` '
157
- msg += 'or similar. The other common scenerio is a transient '
158
+ msg += 'or similar. The other common scenario is a transient '
158
159
  msg += 'error such as an unresponsive mirror.'
159
160
  raise msg
160
161
  # fallback rescue above should catch most of the errors
@@ -300,6 +301,7 @@ module Kitchen
300
301
  'NetworkMode' => self[:network_mode],
301
302
  'PortBindings' => port_bindings,
302
303
  'Tmpfs' => dokken_tmpfs,
304
+ 'Memory' => self[:memory_limit],
303
305
  },
304
306
  'NetworkingConfig' => {
305
307
  'EndpointsConfig' => {
@@ -366,8 +368,16 @@ module Kitchen
366
368
  lockfile = Lockfile.new "#{home_dir}/.dokken-#{chef_container_name}.lock"
367
369
  begin
368
370
  lockfile.lock
369
- with_retries { ::Docker::Container.get(chef_container_name, {}, docker_connection) }
371
+ with_retries {
372
+ # TEMPORARY FIX - docker-api 2.0.0 has a buggy Docker::Container.get - use .all instead
373
+ # https://github.com/swipely/docker-api/issues/566
374
+ # ::Docker::Container.get(chef_container_name, {}, docker_connection)
375
+ found = ::Docker::Container.all({all: true}, docker_connection).select { |c| c.info["Names"].include?("/#{chef_container_name}") }
376
+ raise ::Docker::Error::NotFoundError.new(chef_container_name) if found.empty?
377
+ debug "Chef container already exists, continuing"
378
+ }
370
379
  rescue ::Docker::Error::NotFoundError
380
+ debug "Chef container does not exist, creating a new Chef container"
371
381
  with_retries do
372
382
  begin
373
383
  debug "driver - creating volume container #{chef_container_name} from #{chef_image}"
@@ -18,6 +18,6 @@
18
18
  module Kitchen
19
19
  module Driver
20
20
  # Version string for Dokken Kitchen driver
21
- DOKKEN_VERSION = '2.9.0'.freeze
21
+ DOKKEN_VERSION = '2.11.2'.freeze
22
22
  end
23
23
  end
@@ -1,8 +1,8 @@
1
1
  module Dokken
2
2
  module Helpers
3
3
  # https://stackoverflow.com/questions/517219/ruby-see-if-a-port-is-open
4
- require 'socket'
5
- require 'timeout'
4
+ require 'socket' unless defined?(Socket)
5
+ require 'timeout' unless defined?(Timeout)
6
6
 
7
7
  def port_open?(ip, port)
8
8
  begin
@@ -11,7 +11,7 @@ module Dokken
11
11
  s = TCPSocket.new(ip, port)
12
12
  s.close
13
13
  return true
14
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
14
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::ENETDOWN
15
15
  return false
16
16
  end
17
17
  end
@@ -243,7 +243,7 @@ VOLUME /opt/verifier
243
243
 
244
244
  def remote_docker_host?
245
245
  return false if config[:docker_info]['OperatingSystem'].include?('Boot2Docker')
246
- return true if config[:docker_host_url] =~ /^tcp:/
246
+ return true if /^tcp:/.match?(config[:docker_host_url])
247
247
  false
248
248
  end
249
249
 
@@ -55,6 +55,7 @@ module Kitchen
55
55
  # (see Base#call)
56
56
  def call(state)
57
57
  create_sandbox
58
+ write_run_command(run_command)
58
59
  instance.transport.connection(state) do |conn|
59
60
  if remote_docker_host?
60
61
  info("Transferring files to #{instance.to_str}")
@@ -63,7 +64,7 @@ module Kitchen
63
64
 
64
65
  conn.execute(prepare_command)
65
66
  conn.execute_with_retry(
66
- run_command,
67
+ "sh #{config[:root_path]}/run_command",
67
68
  config[:retry_on_exit_code],
68
69
  config[:max_retries],
69
70
  config[:wait_for_retry]
@@ -105,6 +106,12 @@ module Kitchen
105
106
  cmd << " -F #{config[:chef_output_format]}"
106
107
  cmd << ' -c /opt/kitchen/client.rb'
107
108
  cmd << ' -j /opt/kitchen/dna.json'
109
+
110
+ chef_cmd(cmd)
111
+ end
112
+
113
+ def write_run_command(command)
114
+ File.write("#{dokken_kitchen_sandbox}/run_command", command)
108
115
  end
109
116
 
110
117
  def runner_container_name
@@ -17,8 +17,8 @@
17
17
 
18
18
  require 'kitchen'
19
19
  require 'net/scp'
20
- require 'tmpdir'
21
- require 'digest/sha1'
20
+ require 'tmpdir' unless defined?(Dir.mktmpdir)
21
+ require 'digest/sha1' unless defined?(Digest::SHA1)
22
22
  require_relative '../helpers'
23
23
 
24
24
  include Dokken::Helpers
@@ -82,7 +82,7 @@ module Kitchen
82
82
  ssh_ip = options[:host_ip_override]
83
83
  ssh_port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort]
84
84
 
85
- elsif options[:docker_host_url] =~ /unix:/
85
+ elsif /unix:/.match?(options[:docker_host_url])
86
86
  if options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostIp] == '0.0.0.0'
87
87
  ssh_ip = options[:data_container][:NetworkSettings][:IPAddress]
88
88
  ssh_port = '22'
@@ -92,16 +92,16 @@ module Kitchen
92
92
  ssh_port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort]
93
93
  end
94
94
 
95
- elsif options[:docker_host_url] =~ /tcp:/
95
+ elsif /tcp:/.match?(options[:docker_host_url])
96
96
  name = options[:data_container][:Name]
97
97
 
98
98
  # DOCKER_HOST
99
99
  docker_host_url_ip = options[:docker_host_url].split('tcp://')[1].split(':')[0]
100
100
 
101
101
  # mapped IP of data container
102
- candidate_ip = ::Docker::Container.all.select do |x|
102
+ candidate_ip = ::Docker::Container.all.find do |x|
103
103
  x.info['Names'][0].eql?(name)
104
- end.first.info['NetworkSettings']['Networks']['dokken']['IPAddress']
104
+ end.info['NetworkSettings']['Networks']['dokken']['IPAddress']
105
105
 
106
106
  # mapped port
107
107
  candidate_ssh_port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort]
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dokken
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.33'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.33'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: lockfile
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -58,7 +64,8 @@ dependencies:
58
64
  - - "<"
59
65
  - !ruby/object:Gem::Version
60
66
  version: '3'
61
- description: A Test Kitchen Driver for Dokken
67
+ description: A Test Kitchen Driver for Docker & Chef Infra optimized for rapid testing
68
+ using Chef Infra docker images
62
69
  email:
63
70
  - sean@sean.io
64
71
  executables: []
@@ -75,7 +82,7 @@ homepage: https://github.com/someara/kitchen-dokken
75
82
  licenses:
76
83
  - Apache-2.0
77
84
  metadata: {}
78
- post_install_message:
85
+ post_install_message:
79
86
  rdoc_options: []
80
87
  require_paths:
81
88
  - lib
@@ -90,9 +97,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
97
  - !ruby/object:Gem::Version
91
98
  version: '0'
92
99
  requirements: []
93
- rubygems_version: 3.1.2
94
- signing_key:
100
+ rubygems_version: 3.1.4
101
+ signing_key:
95
102
  specification_version: 4
96
- summary: A Test Kitchen Driver that talks to the Docker Remote API and uses Volumes
97
- to produce sparse container images
103
+ summary: A Test Kitchen Driver for Docker & Chef Infra optimized for rapid testing
104
+ using Chef Infra docker images
98
105
  test_files: []