Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Commit

Permalink
(maint) Container test with a puppetserver
Browse files Browse the repository at this point in the history
 - Introduce a new test that spins up a puppetserver and connects an
   agent

   The agent waits for 30s before trying to connect to the server, then
   tries to connect 5 times with a 5s delay
  • Loading branch information
Iristyle committed Apr 8, 2021
1 parent 2dcc834 commit de74954
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ services:
image: ${PUPPET_AGENT_IMAGE:-puppet/puppet-agent-ubuntu}
entrypoint: 'facter'
command: 'is_virtual'

puppet:
environment:
# overrides default shared service definition
- USE_PUPPETDB=false

agent-run:
hostname: agent-run
image: ${PUPPET_AGENT_IMAGE:-puppet/puppet-agent-ubuntu}
entrypoint: '/bin/bash'
# give server a 30s start buffer, then try agent runs for 15s before exiting
command: "-c 'sleep 30; i=0; while ! /opt/puppetlabs/bin/puppet agent --verbose --onetime --no-daemonize --summarize --server puppet --certname agent-run --masterport 8140 --ca_server puppet --ca_port 8140 --waitforcert 180; do sleep 5; i=$$((i+1)); if [ $$i -gt 5 ]; then exit 1; fi; done;'"
4 changes: 2 additions & 2 deletions spec/dockerfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
RSpec.configure do |c|
c.before(:suite) do
ENV['PUPPET_AGENT_IMAGE'] = require_test_image
pull_images(['agent-apply', 'agent-facter'])
pull_images(['agent_apply', 'agent_facter', 'agent-run'])
teardown_cluster
# no certs to preload, but if the suite adds puppetserver, be explicit
docker_compose_up(preload_certs: false)
end

Expand All @@ -23,6 +22,7 @@
{
'agent-apply': 'be able to run a puppet apply',
'agent-facter': 'be able to run facter',
'agent-run': 'be able to run against a server'
}.each do |container, op|
it "should #{op}" do
container = get_service_container(container)
Expand Down

0 comments on commit de74954

Please sign in to comment.