Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Improve PCP broker and client usage in acceptance #336

Merged
merged 2 commits into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions acceptance/lib/pxp-agent/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

# This file contains general test helper methods for pxp-agent acceptance tests

# The standard path for git checkouts is where pcp-broker will be
GIT_CLONE_FOLDER = '/opt/puppet-git-repos'
Copy link
Author

Choose a reason for hiding this comment

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

I'm not happy with this being defined here. I've created PCP-298 to refactor this lib - possibly at this point pcp-broker deserves its own helper file

Copy link
Contributor

Choose a reason for hiding this comment

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

The comment says it's standard, so doesn't the place where it's standardised export a constant?

Copy link
Contributor

Choose a reason for hiding this comment

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

On checking out the branch and poking around I now follow - this is the standard place, as it's now common to the call to clone_git_repo_on in acceptance/setup/common/010_Setup_Broker.rb and the run_pcp_broker helper here. Will do for now.


# Some helpers for working with the log file
PXP_LOG_FILE_CYGPATH = '/cygdrive/c/ProgramData/PuppetLabs/pxp-agent/var/log/pxp-agent.log'
PXP_LOG_FILE_POSIX = '/var/log/puppetlabs/pxp-agent/pxp-agent.log'
Expand Down Expand Up @@ -40,7 +43,7 @@ def expect_file_on_host_to_contain(host, file, expected, seconds=30)

# Some helpers for working with a pcp-broker 'lein tk' instance
def run_pcp_broker(host)
on(host, 'cd /opt/puppet-git-repos/pcp-broker; export LEIN_ROOT=ok; lein tk </dev/null >/var/log/pcp-broker.log 2>&1 &')
on(host, "cd #{GIT_CLONE_FOLDER}/pcp-broker; export LEIN_ROOT=ok; lein tk </dev/null >/var/log/pcp-broker.log 2>&1 &"")
assert(port_open_within?(host, PCP_BROKER_PORT, 60),
"pcp-broker port #{PCP_BROKER_PORT.to_s} not open within 1 minutes of starting the broker")
broker_state = nil
Expand Down Expand Up @@ -276,7 +279,8 @@ def connect_pcp_client(broker)
client = PCP::Client.new({
:server => broker_ws_uri(broker),
:ssl_cert => "../test-resources/ssl/certs/controller01.example.com.pem",
:ssl_key => "../test-resources/ssl/private_keys/controller01.example.com.pem"
:ssl_key => "../test-resources/ssl/private_keys/controller01.example.com.pem",
:loglevel => logger.is_debug? ? Logger::DEBUG : Logger::WARN
})

retries = 0
Expand Down
12 changes: 3 additions & 9 deletions acceptance/setup/common/010_Setup_Broker.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'puppet/acceptance/install_utils'
extend Puppet::Acceptance::InstallUtils

pcp_broker_port = 8142
pcp_broker_minutes_to_start = 2
GIT_CLONE_FOLDER = '/opt/puppet-git-repos'
require 'pxp-agent/test_helper'

step 'Install build dependencies on master' do
MASTER_PACKAGES = {
Expand Down Expand Up @@ -35,9 +32,6 @@
on master, "cd #{GIT_CLONE_FOLDER}/pcp-broker; export LEIN_ROOT=ok; lein deps"
end

step "Run pcp-broker in trapperkeeper in background and wait for port #{pcp_broker_port.to_s}" do
on master, "cd #{GIT_CLONE_FOLDER}/pcp-broker; export LEIN_ROOT=ok; lein tk </dev/null >/var/log/pcp-broker.log 2>&1 &"
assert(port_open_within?(master, pcp_broker_port, 60 * pcp_broker_minutes_to_start),
"pcp-broker port #{pcp_broker_port.to_s} not open within " \
"#{pcp_broker_minutes_to_start.to_s} minutes of starting the broker")
step "Run pcp-broker in trapperkeeper in background and wait for it to report status 'running'" do
run_pcp_broker(master)
end