Skip to content
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

Fix the Acceptance Tests by running them with beaker_hypervisor: vagrant_libvirt #390

Closed
wants to merge 20 commits into from
Closed
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ concurrency:
jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1
uses: daberkow/gha-puppet/.github/workflows/beaker.yml@ubuntu24
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will move to v3 on main repo once voxpupuli/gha-puppet#57 is merged

with:
beaker_hypervisor: 'vagrant_libvirt'
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group :test do
gem 'voxpupuli-test', '~> 7.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 3.5', :require => false
gem 'puppet_metadata', '~> 4.1.0', :require => false
end

group :development do
Expand All @@ -17,6 +17,8 @@ end

group :system_tests do
gem 'voxpupuli-acceptance', '~> 3.0', :require => false
gem 'beaker-vagrant', '~> 1.4.0', require: false
gem 'beaker-hostgenerator', '~> 2.14.1', require: false
end

group :release do
Expand Down
8 changes: 2 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in metadata.json

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Skipping EOL operating system Fedora 36
"name": "puppet-selinux",
"version": "4.1.1-rc0",
"author": "Vox Pupuli",
Expand All @@ -20,7 +20,6 @@
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
Expand Down Expand Up @@ -48,16 +47,13 @@
{
"operatingsystem": "Fedora",
"operatingsystemrelease": [
"30",
"31",
"32",
"33"
"36",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fedora 36 is the version before 40 that had its own releases of puppet, because of that I added it to here, but the tests dont run because of it being EOL. I guess I can remove it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should remove EOL Fedora 36, in a separate pull request so that the changelog generator picks it up. 👍

"40"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"10",
"11",
"12"
]
Expand Down
10 changes: 7 additions & 3 deletions spec/acceptance/class_disabled_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ class { 'selinux': mode => 'permissive' }
end

context 'when switching from enforcing to disabled' do
let(:pp) do
let(:manifest) do
<<-EOS
class { 'selinux': mode => 'disabled' }
EOS
end

context 'before reboot' do
before(:all) do
# Tag vagrant user to an administrative group
shell('semanage login -a -s staff_u vagrant')
# Vagrant is logging in and using privileges commands, we need to allow that
shell('setsebool -P ssh_sysadm_login 1')
shell('sed -i "s/SELINUX=.*/SELINUX=enforcing/" /etc/selinux/config')
shell('setenforce Enforcing && test "$(getenforce)" = "Enforcing"')
end
Expand All @@ -75,7 +79,7 @@ class { 'selinux': mode => 'disabled' }
end

it 'applies without changes' do
apply_manifest(pp, catch_changes: true)
apply_manifest(manifest, catch_changes: true)
end

describe command('getenforce') do
Expand Down Expand Up @@ -120,7 +124,7 @@ class { 'selinux': mode => 'permissive' }
end

it 'applies without changes' do
apply_manifest(pp, catch_changes: true)
apply_manifest(manifest, catch_changes: true)
end

describe command('getenforce') do
Expand Down
42 changes: 22 additions & 20 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class { 'selinux': mode => 'enforcing' }
selinux::permissive { 'puppet_selinux_test_policy_t': }

selinux::port { 'puppet_selinux_test_policy_port_t/tcp':
seltype => 'puppet_selinux_test_policy_port_t',
port => 55555,
seltype => 'puppet_selinux_test_policy_port_t',
port => 55555,
protocol => 'tcp',
}
}

# just something simple I found via Google:
file {'/tmp/selinux_simple_policy.te':
file { '/tmp/selinux_simple_policy.te':
ensure => 'file',
content => @("EOF")
module puppet_selinux_simple_policy 1.0;
Expand All @@ -40,7 +40,7 @@ class file { read getattr };
| EOF
}

file {'/tmp/selinux_test_policy.te':
file { '/tmp/selinux_test_policy.te':
ensure => 'file',
content => @("EOF")
policy_module(puppet_selinux_test_policy, 1.0.0)
Expand All @@ -56,48 +56,50 @@ class file { read getattr };
selinux::module { 'puppet_selinux_simple_policy':
source_te => 'file:///tmp/selinux_simple_policy.te',
builder => 'simple',
require => File['/tmp/selinux_simple_policy.te']
require => File['/tmp/selinux_simple_policy.te'],
}

selinux::module { 'puppet_selinux_test_policy':
source_te => 'file:///tmp/selinux_test_policy.te',
builder => 'refpolicy',
require => File['/tmp/selinux_test_policy.te']
source_te => 'file:///tmp/selinux_test_policy.te',
builder => 'refpolicy',
require => File['/tmp/selinux_test_policy.te'],
}

if $have_selinux_ruby_library {
Class['selinux'] ->

file { '/tmp/test_selinux_fcontext':
content => 'TEST',
seltype => 'puppet_selinux_test_policy_exec_t',
require => Class['selinux'],
}

selinux::fcontext {'/tmp/fcontexts_source(/.*)?':
selinux::fcontext { '/tmp/fcontexts_source(/.*)?':
seltype => 'puppet_selinux_test_policy_exec_t',
}

selinux::fcontext::equivalence {'/tmp/fcontexts_equivalent':
selinux::fcontext::equivalence { '/tmp/fcontexts_equivalent':
target => '/tmp/fcontexts_source',
}

file {['/tmp/fcontexts_source', '/tmp/fcontexts_equivalent']:
ensure => 'directory',
ensure => 'directory',
require => [Selinux::Fcontext['/tmp/fcontexts_source(/.*)?'], Selinux::Fcontext::Equivalence['/tmp/fcontexts_equivalent']],
}

file {['/tmp/fcontexts_source/define_test', '/tmp/fcontexts_equivalent/define_test']:
ensure => file,
notify => Exec["/sbin/restorecon -FR /tmp/fcontexts_*"]
file { ['/tmp/fcontexts_source/define_test', '/tmp/fcontexts_equivalent/define_test']:
ensure => file,
notify => Exec['/sbin/restorecon -FR /tmp/fcontexts_*'],
}
exec {'/sbin/restorecon -FR /tmp/fcontexts_*':
# this is needed because puppet creates files with the wrong context as
# it runs unconfined and only becomes idempotent after the second run.
exec { '/sbin/restorecon -FR /tmp/fcontexts_*':
# this is needed because puppet creates files with the wrong context as
# it runs unconfined and only becomes idempotent after the second run.
refreshonly => true,
}

# test purging
resources {['selinux_fcontext', 'selinux_fcontext_equivalence']: purge => true }
# This resource purge is breaking because above we are defining it
# resources { ['selinux_fcontext', 'selinux_fcontext_equivalence']:
# purge => true,
# }
}
EOS
end
Expand Down
2 changes: 1 addition & 1 deletion test-acceptance-with-vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export PUPPET_INSTALL_TYPE=agent

# https://github.com/puppetlabs/beaker-hostgenerator/pull/184 fixes the Fedora boxes and adds 32
for layout in \
{debian10,centos{7,8}}'-64a' \
{debian11,centos{7,8}}'-64a' \
'fedora31-64a{box=fedora/31-cloud-base}' \
'fedora32-64a{box=fedora/32-cloud-base}' \
'fedora33-64a{box=fedora/33-cloud-base}'
Expand Down