diff --git a/.fixtures.yml b/.fixtures.yml index 73f5c1d..7dca64d 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -5,6 +5,8 @@ fixtures: repo: "https://github.com/ehelms/puppet-certs.git" branch: "advisor-certs" extlib: 'https://github.com/voxpupuli/puppet-extlib' + foreman: "https://github.com/theforeman/puppet-foreman.git" + redis: "https://github.com/voxpupuli/puppet-redis" podman: 'https://github.com/southalc/podman' selinux_core: 'https://github.com/puppetlabs/puppetlabs-selinux_core' stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0961b62..e5992e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 with: rubocop: false cache-version: '1' diff --git a/Gemfile b/Gemfile index 9126e66..b675da4 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'voxpupuli-test', '~> 7.0', {"groups"=>["test"]} gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]} gem 'puppet_metadata', '~> 4.0' gem 'puppet-blacksmith', '>= 6.0.0', {"groups"=>["development"]} -gem 'voxpupuli-acceptance', '~> 3.0', {"groups"=>["system_tests"]} +gem 'voxpupuli-acceptance', '~> 3.0', groups: ["system_tests"], github: 'evgeni/voxpupuli-acceptance', branch: 'curl_command' gem 'puppetlabs_spec_helper', {"groups"=>["system_tests"]} # vim:ft=ruby diff --git a/metadata.json b/metadata.json index 2074dbb..fba3ee8 100644 --- a/metadata.json +++ b/metadata.json @@ -34,21 +34,18 @@ { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "8", "9" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "8", "9" ] }, { "operatingsystem": "AlmaLinux", "operatingsystemrelease": [ - "8", "9" ] } diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb new file mode 100644 index 0000000..06a777c --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper_acceptance' + +describe 'basic installation' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + include iop_advisor_engine + PUPPET + end + end + + include_examples 'the default iop-advisor-engine application' +end diff --git a/spec/setup_acceptance_node.pp b/spec/setup_acceptance_node.pp new file mode 100644 index 0000000..1db8e84 --- /dev/null +++ b/spec/setup_acceptance_node.pp @@ -0,0 +1,54 @@ +class { 'foreman::repo': + repo => 'nightly', +} + +stdlib::ensure_packages(['podman']) + +$container_file = "[Unit] +Description=Advisor Engine +After=network-online.target +[Container] +Image=registry.access.redhat.com/ubi9/python-312 +Exec=python /usr/local/bin/python-https-server +Network=host +Volume=/usr/local/bin/python-https-server:/usr/local/bin/python-https-server +[Service] +Restart=always +[Install] +WantedBy=default.target +" + +$python_server = " +from http.server import HTTPServer, SimpleHTTPRequestHandler +import ssl +import os + +context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) +context.load_cert_chain(certfile='/opt/app-root/src/cert.pem', keyfile='/opt/app-root/src/key.pem') +context.check_hostname = False + +port=int(os.environ.get('IOP_ADVISOR_ENGINE_PORT', 8000)) + +with HTTPServer(('localhost', port), SimpleHTTPRequestHandler) as httpd: + httpd.socket = context.wrap_socket(httpd.socket, server_side=True) + httpd.serve_forever() +" + +file { '/etc/containers/systemd/iop-advisor-engine.container': + ensure => present, + content => $container_file, + require => Package['podman'], +} + +file { '/usr/local/bin/python-https-server': + ensure => present, + content => $python_server, +} + +file { '/etc/foreman-proxy': + ensure => directory, +} + +group { 'foreman-proxy': + ensure => present, +} diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index bdf14c4..aa030ef 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,4 +1,5 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' +require 'voxpupuli/acceptance/serverspec_extensions' ENV['BEAKER_setfile'] ||= 'centos8-64{hostname=centos8-64.example.com}' diff --git a/spec/support/acceptance/examples.rb b/spec/support/acceptance/examples.rb new file mode 100644 index 0000000..dbaccb7 --- /dev/null +++ b/spec/support/acceptance/examples.rb @@ -0,0 +1,13 @@ +shared_examples 'the default iop-advisor-engine application' do + engine_port = 8000 + + describe port(engine_port) do + it { is_expected.to be_listening } + end + + # FIXME: this needs to call the right "ping" endpoint once we have one + describe curl_command("https://localhost:#{engine_port}/", cacert: "/etc/pki/katello/certs/katello-default-ca.crt") do + its(:response_code) { is_expected.to eq(200) } + its(:exit_status) { is_expected.to eq 0 } + end +end