Skip to content

[IAC-291] Convert acceptance tests to Litmus #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ fixtures:
powershell: 'puppetlabs-powershell'
reboot: 'puppetlabs-reboot'
repositories:
facts: 'git://github.com/puppetlabs/puppetlabs-facts.git'
puppet_agent: 'git://github.com/puppetlabs/puppetlabs-puppet_agent.git'
provision: 'git://github.com/puppetlabs/provision.git'
yumrepo_core:
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
puppet_version: ">= 6.0.0"
symlinks:
docker: "#{source_dir}"
docker: "#{source_dir}"
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "release"

on:
push:
branches:
- 'release'

jobs:
LitmusAcceptance:
env:
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
HONEYCOMB_DATASET: litmus tests
runs-on: self-hosted
strategy:
matrix:
ruby_version: [2.5.x]
puppet_gem_version: [~> 6.0]
platform: [release_checks]
agent_family: ['puppet5', 'puppet6']

steps:
- uses: actions/checkout@v1
- name: Litmus Parallel
uses: puppetlabs/action-litmus_parallel@master
with:
platform: ${{ matrix.platform }}
agent_family: ${{ matrix.agent_family }}
Spec:
runs-on: self-hosted
strategy:
matrix:
check: [spec, 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop']
ruby_version: [2.5.x]
puppet_gem_version: [~> 5.0, ~> 6.0]
exclude:
- puppet_gem_version: ~> 5.0
check: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop'
- ruby_version: 2.5.x
puppet_gem_version: ~> 5.0
steps:
- uses: actions/checkout@v1
- name: Spec Tests
uses: puppetlabs/action-litmus_spec@master
with:
puppet_gem_version: ${{ matrix.puppet_gem_version }}
check: ${{ matrix.check }}
37 changes: 37 additions & 0 deletions .github/workflows/ubuntu16_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "ubuntu1604"

on: [push, pull_request]

jobs:
LitmusAcceptance:
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6
- name: Prepare inventory file
run: |
cat <<EOF >> inventory.yaml
---
version: 2
groups:
- name: local
targets:
- uri: litmus_localhost
config:
transport: local
- name: ssh_nodes
targets: []
- name: winrm_nodes
targets: []
EOF
- name: Install gems and puppet agent
run: |
bundle install
sudo -u root env "PATH=$PATH" bundle exec rake 'litmus:install_agent'
- name: Install module
run: bundle exec rake 'litmus:install_module'
- name: Run acceptance tests
run: sudo -u root env "PATH=$PATH" bundle exec rake 'litmus:acceptance:localhost'
37 changes: 37 additions & 0 deletions .github/workflows/ubuntu18_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "ubuntu1804"

on: [push, pull_request]

jobs:
LitmusAcceptance:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6
- name: Prepare inventory file
run: |
cat <<EOF >> inventory.yaml
---
version: 2
groups:
- name: local
targets:
- uri: litmus_localhost
config:
transport: local
- name: ssh_nodes
targets: []
- name: winrm_nodes
targets: []
EOF
- name: Install gems and puppet agent
run: |
bundle install
sudo -u root env "PATH=$PATH" bundle exec rake 'litmus:install_agent'
- name: Install module
run: bundle exec rake 'litmus:install_module'
- name: Run acceptance tests
run: sudo -u root env "PATH=$PATH" bundle exec rake 'litmus:acceptance:localhost'
45 changes: 45 additions & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "weekly"

on:
schedule:
- cron: '0 0 * * 6'

jobs:
LitmusAcceptance:
env:
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
HONEYCOMB_DATASET: litmus tests
runs-on: self-hosted
strategy:
matrix:
ruby_version: [2.5.x]
puppet_gem_version: [~> 6.0]
platform: [release_checks]
agent_family: ['puppet5', 'puppet6']

steps:
- uses: actions/checkout@v1
- name: Litmus Parallel
uses: puppetlabs/action-litmus_parallel@master
with:
platform: ${{ matrix.platform }}
agent_family: ${{ matrix.agent_family }}
Spec:
runs-on: self-hosted
strategy:
matrix:
check: [spec, 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop']
ruby_version: [2.5.x]
puppet_gem_version: [~> 5.0, ~> 6.0]
exclude:
- puppet_gem_version: ~> 5.0
check: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop'
- ruby_version: 2.5.x
puppet_gem_version: ~> 5.0
steps:
- uses: actions/checkout@v1
- name: Spec Tests
uses: puppetlabs/action-litmus_spec@master
with:
puppet_gem_version: ${{ matrix.puppet_gem_version }}
check: ${{ matrix.check }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@
.DS_Store
.project
.envrc
/inventory.yaml
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ extra_gemfiles.each do |gemfile|
eval(File.read(gemfile), binding)
end
end
gem "puppet_litmus", git: "https://github.com/puppetlabs/puppet_litmus", require: false, platforms: [:ruby, :mswin, :mingw, :x64_mingw] if ENV['PUPPET_GEM_VERSION'].nil? or ENV['PUPPET_GEM_VERSION'] !~ %r{ 5}
# vim: syntax=ruby
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
4. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
7. [Acceptance](#acceptance)


## Description
Expand Down Expand Up @@ -1012,3 +1013,8 @@ This module supports:
## Development

If you would like to contribute to this module, see the guidelines in [CONTRIBUTING.MD](https://github.com/puppetlabs/puppetlabs-docker/blob/master/CONTRIBUTING.md).

## Acceptance

Acceptance tests for this module leverage [puppet_litmus](https://github.com/puppetlabs/puppet_litmus).
To run the acceptance tests follow the instructions [here](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module).
16 changes: 16 additions & 0 deletions provision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
default:
provisioner: vagrant
images: [ 'ubuntu/xenial64', 'ubuntu/bionic64']
centos:
provisioner: vagrant
images: ['centos/7']
debian:
provisioner: vagrant
images: ['debian/stretch64', 'debian/buster64']
win:
provisioner: vagrant
images: ['gusztavvargadr/windows-server']
release_checks:
provisioner: vmpooler
images: ['redhat-7-x86_64','centos-7-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'win-2016-x86_64', 'win-2019-x86_64']
38 changes: 19 additions & 19 deletions spec/acceptance/compose_v3_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
require 'spec_helper_acceptance'

if fact('osfamily') == 'windows'
if os[:family] == 'windows'
install_dir = '/cygdrive/c/Program Files/Docker'
file_extension = '.exe'
docker_args = 'docker_ee => true'
tmp_path = 'C:/cygwin64/tmp'
test_container = if fact('os.release.major') == '2019'
test_container = if os[:release] =~ %r{2019}
'nanoserver'
else
'nanoserver-sac2016'
end
else
docker_args = if fact('os.name') == 'RedHat'
docker_args = if os[:name] == 'RedHat'
"repo_opt => '--enablerepo=localmirror-extras'"
elsif fact('os.name') == 'Centos'
elsif os[:name] == 'Centos'
"repo_opt => '--enablerepo=localmirror-extras'"
elsif fact('os.name') == 'Ubuntu' && fact('os.release.full') == '14.04'
elsif os[:name] == 'Ubuntu' && os[:release][:full] == '14.04'
"version => '18.06.1~ce~3-0~ubuntu'"
else
''
Expand All @@ -39,7 +39,7 @@ class { 'docker::compose':
end
end

context 'Creating compose v3 projects' do
context 'Creating compose v3 projects', win_broken: true do
let(:install_pp) do
<<-MANIFEST
docker_compose { 'web':
Expand All @@ -50,19 +50,19 @@ class { 'docker::compose':
end

it 'is idempotent' do
idempotent_apply(default, install_pp, {})
idempotent_apply(install_pp)
end

it 'has docker compose installed' do
shell('docker-compose --help', acceptable_exit_codes: [0])
run_shell('docker-compose --help', expect_failures: false)
end

it 'finds a docker container' do
shell('docker inspect web_compose_test_1', acceptable_exit_codes: [0])
run_shell('docker inspect web_compose_test_1', expect_failures: false)
end
end

context 'creating compose projects with multi compose files' do
context 'creating compose projects with multi compose files', win_broken: true do
before(:all) do
install_pp = <<-MANIFEST
docker_compose { 'web1':
Expand All @@ -75,11 +75,11 @@ class { 'docker::compose':
end

it "should find container with #{test_container} tag" do
shell("docker inspect web1_compose_test_1 | grep #{test_container}", acceptable_exit_codes: [0])
run_shell("docker inspect web1_compose_test_1 | grep #{test_container}", acceptable_exit_codes: [0])
end
end

context 'Destroying project with multiple compose files' do
context 'Destroying project with multiple compose files', win_broken: true do
let(:destroy_pp) do
<<-MANIFEST
docker_compose { 'web1':
Expand All @@ -101,11 +101,11 @@ class { 'docker::compose':
end

it 'is idempotent' do
idempotent_apply(default, destroy_pp, {})
idempotent_apply(destroy_pp)
end

it 'does not find a docker container' do
shell('docker inspect web1_compose_test_1', acceptable_exit_codes: [1])
run_shell('docker inspect web1_compose_test_1', expect_failures: true)
end
end

Expand All @@ -120,11 +120,11 @@ class { 'docker::compose':
version => '#{version}',
}
MANIFEST
idempotent_apply(default, pp, {})
idempotent_apply(pp)
end

it 'has installed the requested version' do
shell('docker-compose --version', acceptable_exit_codes: [0]) do |r|
run_shell('docker-compose --version', expect_failures: false) do |r|
expect(r.stdout).to match(%r{#{version}})
end
end
Expand All @@ -142,12 +142,12 @@ class { 'docker::compose':
version => '#{version}',
}
MANIFEST
idempotent_apply(default, pp, {})
idempotent_apply(pp)
end

it 'has removed the relevant files' do
shell("test -e \"#{install_dir}/docker-compose#{file_extension}\"", acceptable_exit_codes: [1])
shell("test -e \"#{install_dir}/docker-compose-#{version}#{file_extension}\"", acceptable_exit_codes: [1])
run_shell("test -e \"#{install_dir}/docker-compose#{file_extension}\"", expect_failures: true)
run_shell("test -e \"#{install_dir}/docker-compose-#{version}#{file_extension}\"", expect_failures: true)
end

after(:all) do
Expand Down
Loading