Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
3 changes: 0 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,18 @@
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"8",
"9"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"8",
"9"
]
},
{
"operatingsystem": "AlmaLinux",
"operatingsystemrelease": [
"8",
"9"
]
}
Expand Down
13 changes: 13 additions & 0 deletions spec/acceptance/basic_spec.rb
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions spec/setup_acceptance_node.pp
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +11 to +12
Copy link
Member Author

Choose a reason for hiding this comment

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

This is obviously still a fake, but a much more elaborate one :D

We should be able to replace this with the "real" deal once a build is available.

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,
}
64 changes: 64 additions & 0 deletions spec/support/acceptance/curl_command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# https://github.com/mizzy/serverspec/pull/611 was rejected so adding it here.
Copy link
Member Author

Choose a reason for hiding this comment

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

This really should be in voxpupuli-acceptance

Copy link
Member

Choose a reason for hiding this comment

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

Being added here -- voxpupuli/voxpupuli-acceptance#89

begin
require 'serverspec'

module Serverspec
module Type
class CurlCommand < Command
def response_code
m = /Response-Code: (?<code>\d+)/.match(stderr)
return 0 unless m
m[:code].to_i
end

def body
command_result.stdout
end

def body_as_json
MultiJson.load(body)
end

private

def curl_command
# curl on EL8 is too old to support --write-out %stderr
command = "/opt/puppetlabs/puppet/bin/curl --silent --write-out '%{stderr}Response-Code: %{response_code}\\n' '#{@name}'"
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we can use plain EL-curl now?


@options.each do |option, value|
case option
when :cacert, :cert, :key
command += " --#{option} '#{value}'"
when :headers
value.each do |header, header_value|
if header_value
command += " --header '#{header}: #{header_value}'"
else
command += " --header '#{header};'"
end
end
else
raise "Unknown option #{option} (value: #{value})"
end
end

command
end

def command_result
@command_result ||= @runner.run_command(curl_command)
end
end
end

module Helper
module Type
def curl_command(*args)
Serverspec::Type::CurlCommand.new(*args)
end
end
end
end
rescue LoadError
# serverspec not present - usually in unit tests
end
13 changes: 13 additions & 0 deletions spec/support/acceptance/examples.rb
Original file line number Diff line number Diff line change
@@ -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