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 1, 2019
1 parent 251f8b8 commit 90a75c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 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
11 changes: 9 additions & 2 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 @@ -236,11 +241,13 @@ def clean_certificate(agent_name)
# Puppet Agent Helpers
######################################################################

def run_agent(agent_name, network, server = get_container_hostname(get_service_container('puppet')))
def run_agent(agent_name, network, server = get_container_hostname(get_service_container('puppet')), hosts = {})
# 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}")
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}")
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?
result = run_command("docker run --rm --network #{network} #{host_map} --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, hosts)
expect(status).to eq(0)
end

Expand Down

0 comments on commit 90a75c5

Please sign in to comment.