beaker-docker 0.7.1 → 0.8.4

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: 1656bc0ada39719991d068356033f018e0e8a2d3ad36b9fb8abc7285f2bf4e0f
4
- data.tar.gz: b2207cae132edc1bf03e4b6dd0f5bf34139e30868f20e6e6f585291a72cf310e
3
+ metadata.gz: a33de485fa44a24ca53428bc873ee91359d6d872abe4d0794a72e037a189aa4c
4
+ data.tar.gz: 3e58d56f2878a8cfcfea37fb7dbafb10b6ad9a2500b3f1cad069283fb886ddfb
5
5
  SHA512:
6
- metadata.gz: 9054afd2e705cd0cdf2910bb243aa4e103aa58e9575c11b23b3192fa0215d7fe90465544b679e805f89f311c337cbd5af2acf92c3d0123e93e00e23a99d8647b
7
- data.tar.gz: d5f352ca1ccc5a37ac60c76344fdcc2265fde3120f2c9c68ec963149c081b9477a490a84eaf926139274c30d27d59f3f37cefd593f17465edcc2038045ada7a2
6
+ metadata.gz: 95fbe3d0582ce0ff014441f45f38e3c2d174f02c2eb323236a6b77a236327a9392eea43765e05bef87e26d9600be81d84c29ea2170b35d926aa9f1419bb23b77
7
+ data.tar.gz: 67533e7a604103891b076a07ddf54808c360ef18833b3a1a094f1681c1ee69676fbeae8bd5db0b483c7c84e7c643c60e78f3aeaefa16b0893223c7261e590d6b
@@ -0,0 +1,24 @@
1
+ name: Release
2
+
3
+ on:
4
+ create:
5
+ ref_type: tag
6
+
7
+ jobs:
8
+ release:
9
+ runs-on: ubuntu-latest
10
+ if: github.repository == 'voxpupuli/beaker-docker'
11
+ env:
12
+ BUNDLE_WITHOUT: release
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Install Ruby 2.7
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: '2.7'
19
+ - name: Build gem
20
+ run: gem build *.gemspec
21
+ - name: Publish gem
22
+ run: gem push *.gem
23
+ env:
24
+ GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
@@ -0,0 +1,105 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - test_me_github
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ - master
11
+
12
+ jobs:
13
+ rspec:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ fail-fast: true
17
+ matrix:
18
+ ruby:
19
+ - "2.4"
20
+ - "2.5"
21
+ - "2.6"
22
+ - "2.7"
23
+ env:
24
+ BUNDLE_WITHOUT: release
25
+ name: RSpec - Ruby ${{ matrix.ruby }}
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+ - name: Install Ruby ${{ matrix.ruby }}
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ bundler-cache: true
33
+ - name: install bundler
34
+ run: |
35
+ gem install bundler -v '~> 1.17.3'
36
+ bundle update
37
+ - name: spec tests
38
+ run: bundle exec rake test:spec
39
+
40
+ docker:
41
+ runs-on: ubuntu-latest
42
+ strategy:
43
+ fail-fast: true
44
+ matrix:
45
+ ruby:
46
+ - "2.6"
47
+ env:
48
+ BUNDLE_WITHOUT: release
49
+ name: Docker - Ruby ${{ matrix.ruby }}
50
+ steps:
51
+ - uses: actions/checkout@v2
52
+ - name: Install Ruby ${{ matrix.ruby }}
53
+ uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby }}
56
+ bundler-cache: true
57
+ - name: install bundler
58
+ run: |
59
+ gem install bundler -v '~> 1.17.3'
60
+ bundle update
61
+ - name: install container runtime
62
+ run: |
63
+ sudo apt-get remove -y docker docker-engine docker.io containerd runc ||:
64
+ sudo apt-get update -y
65
+ sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
66
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
67
+ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
68
+ sudo apt-get update -y
69
+ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
70
+ sudo systemctl start docker
71
+ - name: Run acceptance tests
72
+ run: bundle exec rake test:acceptance
73
+
74
+ podman:
75
+ runs-on: ubuntu-latest
76
+ strategy:
77
+ fail-fast: true
78
+ matrix:
79
+ ruby:
80
+ - "2.6"
81
+ env:
82
+ BUNDLE_WITHOUT: release
83
+ name: Podman - Ruby ${{ matrix.ruby }}
84
+ steps:
85
+ - uses: actions/checkout@v2
86
+ - name: Install Ruby ${{ matrix.ruby }}
87
+ uses: ruby/setup-ruby@v1
88
+ with:
89
+ ruby-version: ${{ matrix.ruby }}
90
+ bundler-cache: true
91
+ - name: install bundler
92
+ run: |
93
+ gem install bundler -v '~> 1.17.3'
94
+ bundle update
95
+ # We need the latest version of podman for this to work
96
+ - name: install container runtime
97
+ run: |
98
+ . /etc/os-release
99
+ curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
100
+ echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/podman.list > /dev/null
101
+ sudo apt-get update
102
+ sudo apt-get -y install podman
103
+ sudo systemctl start podman
104
+ - name: Run acceptance tests
105
+ run: bundle exec rake test:acceptance
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on
6
+ [Keep a Changelog](http://keepachangelog.com)
7
+ & makes a strong effort to adhere to
8
+ [Semantic Versioning](http://semver.org).
9
+
10
+ Tracking in this Changelog began for this project in version 0.8.4.
11
+ If you're looking for changes from before this, refer to the project's
12
+ git logs & PR history.
13
+
14
+ The headers used in [Keep a Changelog](http://keepachangelog.com) are:
15
+
16
+ - Added - for new features.
17
+ - Changed - for changes in existing functionality.
18
+ - Deprecated - for soon-to-be removed features.
19
+ - Removed - for now removed features.
20
+ - Fixed - for any bug fixes.
21
+ - Security - in case of vulnerabilities.
22
+
23
+ # [0.8.4](https://github.com/voxpupuli/beaker/compare/0.8.3...0.8.4) - 03-15-2021
24
+
25
+ ### Fixed
26
+
27
+ - Use the `docker-api` function `::Docker.rootless?` to see if the container
28
+ ecosystem is running in `rootless` mode. This reduces false positive
29
+ failures across the board.
30
+ - Ensure that the correct port and IP is used for local docker connections
31
+ - Added the `force` option to ensure container removal on error
data/Gemfile.local ADDED
@@ -0,0 +1,3 @@
1
+ group :acceptance_testing do
2
+ gem "beaker-rspec"
3
+ end
data/README.md CHANGED
@@ -2,54 +2,120 @@
2
2
 
3
3
  Beaker library to use docker hypervisor
4
4
 
5
- # How to use this wizardry
5
+ ## How to use this wizardry
6
6
 
7
- This gem that allows you to use hosts with [docker](docker.md) hypervisor with [beaker](https://github.com/puppetlabs/beaker).
7
+ This gem that allows you to use hosts with [docker](docker.md) hypervisor with [beaker](https://github.com/voxpupuli/beaker).
8
8
 
9
- Beaker will automatically load the appropriate hypervisors for any given hosts file, so as long as your project dependencies are satisfied there's nothing else to do. No need to `require` this library in your tests.
9
+ Beaker will automatically load the appropriate hypervisors for any given hosts
10
+ file, so as long as your project dependencies are satisfied there's nothing else
11
+ to do. No need to `require` this library in your tests.
10
12
 
11
- ## With Beaker 3.x
13
+ In order to use a specific hypervisor or DSL extension library in your project,
14
+ you will need to include them alongside Beaker in your Gemfile or
15
+ project.gemspec. E.g.
12
16
 
13
- This library is included as a dependency of Beaker 3.x versions, so there's nothing to do.
17
+ ```ruby
18
+ # Gemfile
19
+ gem 'beaker', '~> 4.0'
20
+ gem 'beaker-docker'
21
+ # project.gemspec
22
+ s.add_runtime_dependency 'beaker', '~> 4.0'
23
+ s.add_runtime_dependency 'beaker-docker'
24
+ ```
14
25
 
15
- ## With Beaker 4.x
26
+ ### Nodeset Options
27
+
28
+ The following is a sample nodeset:
29
+
30
+ ```yaml
31
+ HOSTS:
32
+ el8:
33
+ platform: el-8-x86_64
34
+ hypervisor: docker
35
+ image: centos:8
36
+ docker_cmd: '["/sbin/init"]'
37
+ # Run arbitrary things
38
+ docker_image_commands:
39
+ - 'touch /tmp/myfile'
40
+ dockeropts:
41
+ Labels:
42
+ thing: 'stuff'
43
+ HostConfig:
44
+ Privileged: true
45
+ el7:
46
+ platform: el-7-x86_64
47
+ hypervisor: docker
48
+ image: centos:7
49
+ # EL7 images do not support nested systemd
50
+ docker_cmd: '/usr/sbin/sshd -D -E /var/log/sshd.log'
51
+ CONFIG:
52
+ docker_cap_add:
53
+ - AUDIT_WRITE
54
+ ```
16
55
 
17
- As of Beaker 4.0, all hypervisor and DSL extension libraries have been removed and are no longer dependencies. In order to use a specific hypervisor or DSL extension library in your project, you will need to include them alongside Beaker in your Gemfile or project.gemspec. E.g.
56
+ ### Privileged containers
18
57
 
19
- ~~~ruby
20
- # Gemfile
21
- gem 'beaker', '~>4.0'
22
- gem 'beaker-aws'
23
- # project.gemspec
24
- s.add_runtime_dependency 'beaker', '~>4.0'
25
- s.add_runtime_dependency 'beaker-aws'
26
- ~~~
58
+ Containers are run in privileged mode by default unless capabilities are set.
59
+
60
+ If you wish to disable privileged mode, simply set the following in your node:
61
+
62
+ ```yaml
63
+ dockeropts:
64
+ HostConfig:
65
+ Privileged: false
66
+ ```
67
+
68
+ ### Cleaning up after tests
69
+
70
+ Containers created by this plugin may not be destroyed unless the tests complete
71
+ successfully. Each container created is prefixed by `beaker-` to make filtering
72
+ for clean up easier.
27
73
 
28
- # Spec tests
74
+ A quick way to clean up all nodes is as follows:
75
+
76
+ ```sh
77
+ podman rm -f $( podman ps -q -f name="beaker-*" )
78
+ ```
79
+
80
+ ## Working with `podman`
81
+
82
+ If you're using a version of `podman` that has API socket support then you
83
+ should be able to simply set `DOCKER_HOST` to your socket and connect as usual.
84
+
85
+ You also need to ensure that you're using a version of the `docker-api` gem that
86
+ supports `podman`.
87
+
88
+ You may find that not all of your tests work as expected. This will be due to
89
+ the tighter system restrictions placed on containers by `podman`. You may need
90
+ to edit the `dockeropts` hash in your nodeset to include different flags in the
91
+ `HostConfig` section.
92
+
93
+ See the
94
+ [HostConfig](https://any-api.com/docker_com/engine/docs/Definitions/HostConfig)
95
+ portion of the docker API for more information.
96
+
97
+ ## Spec tests
29
98
 
30
99
  Spec test live under the `spec` folder. There are the default rake task and therefore can run with a simple command:
100
+
31
101
  ```bash
32
102
  bundle exec rake test:spec
33
103
  ```
34
104
 
35
- # Acceptance tests
105
+ ## Acceptance tests
106
+
107
+ There is a simple rake task to invoke acceptance test for the library:
36
108
 
37
- There is a simple rake task to invoke acceptance test for the library:
38
109
  ```bash
39
110
  bundle exec rake test:acceptance
40
111
  ```
41
112
 
42
- # Contributing
113
+ ## Contributing
43
114
 
44
115
  Please refer to puppetlabs/beaker's [contributing](https://github.com/puppetlabs/beaker/blob/master/CONTRIBUTING.md) guide.
45
116
 
46
- # Releasing
117
+ ## Releasing
47
118
 
48
- To release new versions of beaker-docker, please use this [jenkins job](https://cinext-jenkinsmaster-sre-prod-1.delivery.puppetlabs.net/view/all/job/qe_beaker-docker_init-multijob_master/). This job
49
- lives on Puppet-internal infrastructure, so you'll need to be a part of the Puppet org to do this.
119
+ To release new versions of beaker-docker, please use update `lib/beaker-docker/version.rb` with the new version number. The version should adhere to [semantic version standards](https://semver.org). When in doubt, ask in the `#voxpupuli` channel of the Puppet community Slack or in `#voxpupuli` on irc.freenode.net ([Webinterface](https://webchat.freenode.net/?channels=%23voxpupuli)).
50
120
 
51
- To run the job, click on `Build with Parameters` in the menu on the left. Make
52
- sure you check the box next to `PUBLIC` and enter the appropriate version. The
53
- version should adhere to [semantic version standards](https://semver.org).
54
- When in doubt, consult the [maintainers of Beaker](https://github.com/puppetlabs/beaker/blob/master/CODEOWNERS)
55
- for guidance.
121
+ Once the version file has been updated, a contributor can push a new git tag to match and GitHub Actions will do the release to RubyGems.
data/Rakefile CHANGED
@@ -6,14 +6,14 @@ namespace :test do
6
6
 
7
7
  desc "Run spec tests"
8
8
  RSpec::Core::RakeTask.new(:run) do |t|
9
- t.rspec_opts = ['--color']
9
+ t.rspec_opts = ['--color', '--format documentation']
10
10
  t.pattern = 'spec/'
11
11
  end
12
12
 
13
13
  desc "Run spec tests with coverage"
14
14
  RSpec::Core::RakeTask.new(:coverage) do |t|
15
15
  ENV['BEAKER_DOCKER_COVERAGE'] = 'y'
16
- t.rspec_opts = ['--color']
16
+ t.rspec_opts = ['--color', '--format documentation']
17
17
  t.pattern = 'spec/'
18
18
  end
19
19
 
@@ -32,11 +32,15 @@ A quick acceptance test, named because it has no pre-suites to run
32
32
  beaker_test_base_dir = File.join(beaker_gem_dir, 'acceptance/tests/base')
33
33
  load_path_option = File.join(beaker_gem_dir, 'acceptance/lib')
34
34
 
35
+ ENV['BEAKER_setfile'] = 'acceptance/config/nodes/hosts.yaml'
35
36
  sh("beaker",
36
37
  "--hosts", "acceptance/config/nodes/hosts.yaml",
37
- "--tests", beaker_test_base_dir,
38
+ # We can't run these tests until the rsync support in the main
39
+ # beaker/host.rb is updated to work with passwords.
40
+ # "--tests", beaker_test_base_dir,
41
+ # "--load-path", load_path_option,
42
+ "--tests", 'acceptance/tests/',
38
43
  "--log-level", "debug",
39
- "--load-path", load_path_option,
40
44
  "--debug")
41
45
  end
42
46
 
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  HOSTS:
3
- ubuntu1604-64-1:
4
- platform: ubuntu-1604-x86_64
3
+ centos8:
4
+ platform: el-8-x86_64
5
5
  hypervisor: docker
6
- image: ubuntu:16.04
6
+ image: centos:8
7
7
  roles:
8
8
  - master
9
9
  - agent
@@ -12,22 +12,29 @@ HOSTS:
12
12
  - classifier
13
13
  - default
14
14
  docker_cmd: '["/sbin/init"]'
15
- dockeropts:
16
- Labels:
17
- one: '1'
18
- two: '2'
19
- ubuntu1604-64-2:
20
- platform: ubuntu-1604-x86_64
15
+ centos7:
16
+ platform: el-7-x86_64
21
17
  hypervisor: docker
22
- image: ubuntu:16.04
18
+ image: centos:7
23
19
  roles:
24
20
  - agent
25
- docker_cmd: '["/sbin/init"]'
21
+ docker_cmd: '/usr/sbin/sshd -D -E /var/log/sshd.log'
22
+ use_image_entrypoint: true
26
23
  CONFIG:
27
24
  nfs_server: none
28
25
  consoleport: 443
29
26
  log_level: verbose
27
+ # Ubuntu runners need to run with full privileges
28
+ # RHEL derivitives just need the docker cap AUDIT_WRITE
30
29
  dockeropts:
31
- Labels:
32
- one: '3'
33
- two: '4'
30
+ HostConfig:
31
+ Privileged: true
32
+ # docker_cap_add:
33
+ # - AUDIT_WRITE
34
+ type: aio
35
+ ssh:
36
+ verify_host_key: false
37
+ user_known_hosts_file: '/dev/null'
38
+ password: root
39
+ auth_methods:
40
+ - password
@@ -0,0 +1,10 @@
1
+ require 'beaker'
2
+ require 'beaker-rspec'
3
+
4
+ RSpec.describe 'it can connect' do
5
+ hosts.each do |host|
6
+ context "on #{host}" do
7
+ on(host, 'ls /tmp')
8
+ end
9
+ end
10
+ end
@@ -5,12 +5,17 @@ require 'beaker-docker/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "beaker-docker"
7
7
  s.version = BeakerDocker::VERSION
8
- s.authors = ["Rishi Javia, Kevin Imber, Tony Vu"]
9
- s.email = ["rishi.javia@puppet.com, kevin.imber@puppet.com, tony.vu@puppet.com"]
10
- s.homepage = "https://github.com/puppetlabs/beaker-docker"
8
+ s.authors = [
9
+ "Vox Pupuli",
10
+ "Rishi Javia",
11
+ "Kevin Imber",
12
+ "Tony Vu"
13
+ ]
14
+ s.email = ["voxpupuli@groups.io"]
15
+ s.homepage = "https://github.com/voxpupuli/beaker-docker"
11
16
  s.summary = %q{Beaker DSL Extension Helpers!}
12
17
  s.description = %q{For use for the Beaker acceptance testing tool}
13
- s.license = 'Apache2'
18
+ s.license = 'Apache-2.0'
14
19
 
15
20
  s.files = `git ls-files`.split("\n")
16
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -19,20 +24,15 @@ Gem::Specification.new do |s|
19
24
 
20
25
  # Testing dependencies
21
26
  s.add_development_dependency 'rspec', '~> 3.0'
22
- s.add_development_dependency 'rspec-its'
23
- # pin fakefs for Ruby < 2.3
24
- if RUBY_VERSION < "2.3"
25
- s.add_development_dependency 'fakefs', '~> 0.6', '< 0.14'
26
- else
27
- s.add_development_dependency 'fakefs', '~> 0.6'
28
- end
29
- s.add_development_dependency 'rake', '~> 10.1'
30
- s.add_development_dependency 'simplecov'
27
+ s.add_development_dependency 'rspec-its', '~> 1.3'
28
+ s.add_development_dependency 'fakefs', '~> 1.3'
29
+ s.add_development_dependency 'rake', '~> 13.0'
30
+ s.add_development_dependency 'simplecov', '~> 0.18'
31
31
  s.add_development_dependency 'pry', '~> 0.10'
32
32
 
33
33
  # Run time dependencies
34
34
  s.add_runtime_dependency 'stringify-hash', '~> 0.0.0'
35
- s.add_runtime_dependency 'docker-api', '< 2.0.0'
35
+ s.add_runtime_dependency 'docker-api', '~> 2.1'
36
36
 
37
37
  end
38
38