Skip to content

Commit

Permalink
WIP - rekick - remove after this commit passes *
Browse files Browse the repository at this point in the history
  • Loading branch information
Iristyle committed May 3, 2019
1 parent 871724c commit bfb29b5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pool:
# self-hosted agent on Windows 10 1709 environment
# includes newer Docker engine with LCOW enabled, new build of LCOW image
# includes Ruby 2.5, Go 1.10, Node.js 10.10, hadolint
name: Default
name: Internal LCOW

variables:
COMPOSE_PROJECT_NAME: pupperware
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:
- puppet.internal

postgres:
hostname: postgres.internal
image: postgres:9.6
environment:
- POSTGRES_PASSWORD=puppetdb
Expand All @@ -51,7 +52,7 @@ services:
- PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-true}
# This name is an FQDN so the short name puppet doesn't collide outside compose network
- PUPPETSERVER_HOSTNAME=puppet.internal
- PUPPETDB_DATABASE_CONNECTION="//postgres.internal:5432/puppetdb"
- PUPPETDB_POSTGRES_HOSTNAME=postgres.internal
- PUPPETDB_PASSWORD=puppetdb
- PUPPETDB_USER=puppetdb
ports:
Expand Down
9 changes: 9 additions & 0 deletions gem/lib/pupperware/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def get_container_hostname(container)
return fqdn || inspect_container(container, '{{.Config.Hostname}}')
end

# this only works when a container has a single network
def get_container_ip(container)
inspect_container(container, '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
end

def emit_log(container)
container_name = get_container_name(container)
STDOUT.puts("#{'*' * 80}\nContainer logs for #{container_name} / #{container}\n#{'*' * 80}\n")
Expand Down Expand Up @@ -240,6 +245,10 @@ def run_agent(agent_name, network, server = get_container_hostname(get_service_c
# setting up a Windows TTY is difficult, so we don't
# allocating a TTY will show container pull output on Linux, but that's not good for tests
STDOUT.puts("running agent #{agent_name} in network #{network} against #{server}")
# NOTE: --add-host doesn't do anything in LCOW!!
# host_map = hosts.map { |k, v| "--add-host=\"#{k}:#{v}\"" }.join(' ')
# STDOUT.puts("adding hosts #{host_map} to agents /etc/hosts") unless host_map.nil?
# TODO: try puppet-agent instead of puppet-agent-alpine
result = run_command("docker run --rm --network #{network} --name #{agent_name} --hostname #{agent_name} puppet/puppet-agent-alpine agent --verbose --onetime --no-daemonize --summarize --server #{server}")
return result[:status].exitstatus
end
Expand Down
6 changes: 5 additions & 1 deletion spec/examples/running_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
end

it 'should be able to run an agent' do
status = run_agent(@test_agent, 'pupperware_default')
# to workaround DNS resolution problems, add a /etc/hosts entry
puppetserver_container = get_service_container('puppet')
puppetserver_hostname = get_container_hostname(puppetserver_container)
# hosts = { puppetserver_hostname => get_container_ip(puppetserver_container) }
status = run_agent(@test_agent, 'pupperware_default', puppetserver_hostname)
expect(status).to eq(0)
end

Expand Down

0 comments on commit bfb29b5

Please sign in to comment.