beaker-docker 0.7.0 → 0.8.3

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: 861122c5034db5ced0eff3c80985dc76b22e1cd2fdf5bb8adaec166273c0d2c1
4
- data.tar.gz: 6859e69fce6351716083d866b413bfc293be22a377dcf4f65c67d56f9e61732f
3
+ metadata.gz: 334f12192e1c187506529fd753491a8aba885ccf5512d2f681b7b659f4b7f525
4
+ data.tar.gz: ee99cc4537be2eb938639fd4078aa1f95eba859b338531ba206c4035587e103a
5
5
  SHA512:
6
- metadata.gz: de860c99c3586574c9593a2e58e314d917674a8d5314b6f54395dcb59eb6563d0b3b830ae9d5dd21c307a51a1fbd73a0faf4a4438881f9a94a3f8f55109bfa6e
7
- data.tar.gz: c9f73baba29ca208f6d04a6a599e1f069aa8bf79ea646b30c48f27249e7d29127738c217d25f1ae4a8d17d8a75890a4ccb44fafa67c341bb8b258191dcb1471f
6
+ metadata.gz: 9df1580cf398c8b43641d9b06e53be3090d2141fd9a9172c1f1a6290f362b5d02819e720ee05046e024c4051a8201001569663feb7716263616f578b0d66fbac
7
+ data.tar.gz: 9e1d910176b66e2576cb170f31b80a97491274248a698c89c5925413c35165afc96cd9da9e4ba2acd4fcd1dea548cec5753211ed796ff0e84a91edce9719ce49
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "13:00"
8
+ open-pull-requests-limit: 10
@@ -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/Gemfile.local ADDED
@@ -0,0 +1,5 @@
1
+ group :acceptance_testing do
2
+ # Needed for podman testing
3
+ gem "docker-api", :git => 'https://github.com/trevor-vaughan/docker-api', :branch => 'podman-compat'
4
+ gem "beaker-rspec"
5
+ end
data/README.md CHANGED
@@ -2,54 +2,118 @@
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
47
-
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.
117
+ ## Releasing
50
118
 
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.
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)).
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'
35
+ s.add_runtime_dependency 'docker-api', '< 3.0.0'
36
36
 
37
37
  end
38
38