From ed37005f7a802e1ac0605746ba31224df002320d Mon Sep 17 00:00:00 2001 From: Brian Witt Date: Wed, 28 Oct 2026 21:19:32 -0700 Subject: [PATCH] add basic acceptance tests Signed-off-by: Brian Witt --- .github/workflows/ci.yml | 28 ++++++++++++++- .sync.yml | 2 ++ spec/acceptance/apache_spec.rb | 66 ++++++++++++++++++++++++++++++++++ spec/spec_helper_acceptance.rb | 10 ++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 spec/acceptance/apache_spec.rb create mode 100644 spec/spec_helper_acceptance.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c1e164..db06cc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,29 @@ on: branches: - main - master + workflow_dispatch: + inputs: + beaker_staging_url: + description: |- + URL to a staging Server to test unreleased packages. + We will append the version to the Server and assume all packages are in the same directory. + Only supported for AIO packages. + required: false + type: string + default: 'https://artifacts.voxpupuli.org/openvox-agent' + beaker_collection: + description: |- + When set to staging, we will download the packages from staging_url. + Otherwise we will use the official repos. Supported values: puppet7, puppet8, openvox7, openvox8, staging. + When unset, we will generate a list of supported collections based on metadata.json. + required: false + type: string + beaker_staging_version: + description: |- + The package version we want to test. + Only used for beaker_collection = staging + required: false + type: string concurrency: group: ${{ github.ref_name }} @@ -22,6 +45,9 @@ permissions: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v4 + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v4 with: + beaker_staging_url: ${{ inputs.beaker_staging_url }} + beaker_collection: ${{ inputs.beaker_collection }} + beaker_staging_version: ${{ inputs.beaker_staging_version }} additional_packages: 'libaugeas-dev augeas-tools' diff --git a/.sync.yml b/.sync.yml index 80feb26..4ea93fc 100644 --- a/.sync.yml +++ b/.sync.yml @@ -9,3 +9,5 @@ Gemfile: spec/spec_helper.rb: spec_overrides: - "require 'spec_helper_local'" +spec/spec_helper_acceptance.rb: + unmanaged: false diff --git a/spec/acceptance/apache_spec.rb b/spec/acceptance/apache_spec.rb new file mode 100644 index 0000000..c3dc9bf --- /dev/null +++ b/spec/acceptance/apache_spec.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +require 'spec_helper_acceptance' + +describe 'apache_directive and apache_setenv' do + before(:all) do + shell("printf 'ServerName foo.example.com\\n\\n StartServers 2\\n\\n' > /tmp/apache_test.conf") + end + + context 'with ensure => present' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<~PUPPET + apache_directive { 'Timeout': + ensure => present, + args => '60', + target => '/tmp/apache_test.conf', + } + apache_directive { 'StartServers for mpm_prefork_module': + ensure => present, + name => 'StartServers', + context => 'IfModule[arg="mpm_prefork_module"]', + args => '4', + target => '/tmp/apache_test.conf', + } + apache_setenv { 'SPECIAL_PATH': + ensure => present, + value => '/foo/bin', + target => '/tmp/apache_test.conf', + } + PUPPET + end + end + + describe file('/tmp/apache_test.conf') do + its(:content) { is_expected.to match(%r{^ServerName foo\.example\.com$}) } + its(:content) { is_expected.to match(%r{^Timeout 60$}) } + its(:content) { is_expected.to match(%r{^\n\s+StartServers 4\n$}) } + its(:content) { is_expected.to match(%r{^SetEnv SPECIAL_PATH /foo/bin$}) } + end + end + + context 'with ensure => absent' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<~PUPPET + apache_directive { 'ServerName': + ensure => absent, + args => 'foo.example.com', + target => '/tmp/apache_test.conf', + } + apache_setenv { 'SPECIAL_PATH': + ensure => absent, + target => '/tmp/apache_test.conf', + } + PUPPET + end + end + + describe file('/tmp/apache_test.conf') do + its(:content) { is_expected.not_to match(%r{ServerName}) } + its(:content) { is_expected.not_to match(%r{SPECIAL_PATH}) } + its(:content) { is_expected.to match(%r{^Timeout 60$}) } + end + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..2681792 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +require 'voxpupuli/acceptance/spec_helper_acceptance' + +configure_beaker(modules: :metadata) + +Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }