Commit 60ae6cc4 authored by Rob Browning's avatar Rob Browning

(PDB-3917) Explicitly configure integration test versions

Instead of picking up the integration test subject versions from
PUPPET_VERSION and PUPPETSERVER_VERSION, require them to be explicitly
configured (and later changed) via ext/bin/config-puppet-test-ref and
ext/bin/config-puppetserver-test-ref.

Among other things, this makes the contents of ext/test-conf/ the
single source of truth with respect to the versions.  It also avoids
having to mangle the project.clj via sed for the integration tests,
and it makes it much less likely that the project.clj, Gemfile, and
whatever else might disagree (e.g. if you forgot to specify the
environment variables identically across command invocations).
parent 9bd489e7
...@@ -45,7 +45,10 @@ matrix: ...@@ -45,7 +45,10 @@ matrix:
PUPPETSERVER_VERSION=5.1.x PUPPETSERVER_VERSION=5.1.x
jdk: oraclejdk8 jdk: oraclejdk8
before_install: ext/bin/configure-int-tests before_install: >-
ext/bin/config-puppet-test-ref "$PUPPET_VERSION"
&& ext/bin/config-puppetserver-test-ref "$PUPPETSERVER_VERSION"
script: ext/travisci/test.sh script: ext/travisci/test.sh
on_success: ext/travisci/on-success on_success: ext/travisci/on-success
......
gemfile_home = File.dirname(__FILE__)
source ENV['GEM_SOURCE'] || "https://rubygems.org" source ENV['GEM_SOURCE'] || "https://rubygems.org"
puppet_ref = ENV['PUPPET_VERSION'] || "master"
oldest_supported_puppet = "5.0.0" oldest_supported_puppet = "5.0.0"
beaker_version = ENV['BEAKER_VERSION'] beaker_version = ENV['BEAKER_VERSION']
begin
puppet_ref = File.read(gemfile_home + '/ext/test-conf/puppet-requested').strip
rescue Errno::ENOENT
puppet_ref = File.read(gemfile_home + '/ext/test-conf/puppet-default').strip
end
def location_for(place, fake_version = nil) def location_for(place, fake_version = nil)
if place =~ /^(git:[^#]*)#(.*)/ if place =~ /^(git:[^#]*)#(.*)/
[fake_version, { :git => $1, :branch => $2, :require => false }].compact [fake_version, { :git => $1, :branch => $2, :require => false }].compact
......
...@@ -82,30 +82,37 @@ set `PDB_TEST_PRESERVE_DB_ON_FAIL` to true: ...@@ -82,30 +82,37 @@ set `PDB_TEST_PRESERVE_DB_ON_FAIL` to true:
$ PDB_TEST_KEEP_DB_ON_FAIL=true lein test $ PDB_TEST_KEEP_DB_ON_FAIL=true lein test
To run the integration tests, you'll need to ensure you have a To run the integration tests, you'll need to ensure you have a
suitable version of Ruby and Bundler available, and then run: suitable version of Ruby and Bundler available, and then run
$ ext/bin/configure-int-tests $ ext/bin/config-puppet-test-ref
$ ext/bin/config-puppetserver-test-ref
You can request specific versions of puppet or puppetserver with the The default puppet and puppetserver versions are recorded in
`PUPPET_VERSION` and `PUPPETSERVER_VERSION` environment variables: `ext/test-conf/`. You can request specific versions of puppet or
puppetserver by specifying arguments to the config tools like this:
$ PUPPET_VERSION=5.3.x PUPPETSERVER_VERSION=5.1.x \ $ ext/bin/config-puppet-test-ref 5.3.x
ext/bin/configure-int-tests $ ext/bin/config-puppetserver-test-ref 5.1.x
After configuration, you should be able to run the tests by specifying Run the tools again to change the requested versions, and `lein
distclean` will completely undo the configurations.
After configuration you should be able to run the tests by specifying
the `:integration` selector: the `:integration` selector:
$ lein test :integration $ lein test :integration
To run the local rspec tests (e.g. for the PuppetDB terminus code), To run the local rspec tests (e.g. for the PuppetDB terminus code),
first run `bundle install`, as described above, from the top of the you must have run `config-puppet-test-ref` as described above, and
source tree: then from within the `puppet/` directory run:
$ bundle install --path "$(pwd)/vendor" $ bundle exec rspec spec
and then from within the `puppet/` directory: ### Cleaning up
$ bundle exec rspec Running `lein clean` will clean up the relevant items related to
Clojure, but won't affect some other things, including the integration
test configuration. To clean up "everything", run `lein distclean`.
## Making Trivial Changes ## Making Trivial Changes
......
...@@ -6,6 +6,10 @@ script_home="$(cd "$(dirname "$0")" && pwd)" ...@@ -6,6 +6,10 @@ script_home="$(cd "$(dirname "$0")" && pwd)"
top="$script_home/../.." top="$script_home/../.."
cd "$top" # Always run from the top level of the tree cd "$top" # Always run from the top level of the tree
usage() {
echo "Usage: $(basename "$0") [REF]"
}
if test -z "$(type -t bundler)"; then if test -z "$(type -t bundler)"; then
cat 2>&1 <<-EOS cat 2>&1 <<-EOS
Ruby bundler does not appear to be available. Ruby bundler does not appear to be available.
...@@ -16,33 +20,23 @@ fi ...@@ -16,33 +20,23 @@ fi
set -x set -x
export PUPPETSERVER_HEAP_SIZE=1G rm -f ext/test-conf/puppet-requested
PDB_NO_PUPPETSERVER_INSTALL="${PDB_NO_PUPPETSERVER_INSTALL:-}" case "$#" in
PUPPET_VERSION="${PUPPET_VERSION:-master}" 0)
PUPPETSERVER_VERSION="${PUPPETSERVER_VERSION:-master}" puppet_ref="$(cat ext/test-conf/puppet-default)"
;;
lein-pprint() { 1)
lein with-profile dev,ci pprint "$@" | sed -e 's/^"//' -e 's/"$//' puppet_ref="$1"
} echo "$puppet_ref" > ext/test-conf/puppet-requested
;;
if test -d puppetserver; then *)
git -C puppetserver checkout "$PUPPETSERVER_VERSION" usage 1>&2
git -C puppetserver clean -fdx exit 2
else esac
git clone --depth 10 -b "$PUPPETSERVER_VERSION" https://github.com/puppetlabs/puppetserver
fi
(cd puppetserver
if test -z "$PDB_NO_PUPPETSERVER_INSTALL"; then
lein install
fi
dep_ver="$(lein-pprint :version)"
mkdir -p "$top/ext/test-conf"
echo "$dep_ver" > "$top/ext/test-conf/puppetserver-dep")
bundle install --without acceptance --path vendor/bundle bundle install --without acceptance --path vendor/bundle
lein install-gems bundle update
# Symlink vendor/puppet to the git tree bundler checked out. Use a # Symlink vendor/puppet to the git tree bundler checked out. Use a
# relative path so that moving the pdb tree around won't break things. # relative path so that moving the pdb tree around won't break things.
......
...@@ -33,5 +33,6 @@ lein clean ...@@ -33,5 +33,6 @@ lein clean
lein test lein test
export NO_ACCEPTANCE=true export NO_ACCEPTANCE=true
PDB_NO_PUPPETSERVER_INSTALL=true ext/bin/configure-int-tests ext/bin/config-puppet-test-ref
PDB_NO_PUPPETSERVER_INSTALL=true ext/bin/config-puppetserver-test-ref
exec lein test :integration exec lein test :integration
...@@ -16,7 +16,14 @@ run-unit-tests() ...@@ -16,7 +16,14 @@ run-unit-tests()
export PGHOST=127.0.0.1 export PGHOST=127.0.0.1
export PGPORT=5432 export PGPORT=5432
ext/bin/setup-pdb-pg "$pgdir" ext/bin/setup-pdb-pg "$pgdir"
ext/bin/pdb-test-env "$pgdir" lein test "$PDB_TEST_SELECTOR" case "$PDB_TEST_SELECTOR" in
:integration)
ext/bin/pdb-test-env "$pgdir" lein test :integration
;;
*)
ext/bin/pdb-test-env "$pgdir" lein test "$PDB_TEST_SELECTOR"
;;
esac
) )
case "$PDB_TEST_LANG" in case "$PDB_TEST_LANG" in
...@@ -26,10 +33,8 @@ case "$PDB_TEST_LANG" in ...@@ -26,10 +33,8 @@ case "$PDB_TEST_LANG" in
;; ;;
ruby) ruby)
ruby -v ruby -v
gem install bundler
bundle install --without acceptance
cd puppet cd puppet
bundle exec rspec spec/ bundle exec rspec spec
;; ;;
*) *)
echo "Invalid language: $PDB_TEST_LANG" 1>&2 echo "Invalid language: $PDB_TEST_LANG" 1>&2
......
...@@ -82,6 +82,9 @@ ...@@ -82,6 +82,9 @@
[".bundle" [".bundle"
".lein-failures" ".lein-failures"
"Gemfile.lock" "Gemfile.lock"
"ext/test-conf/puppet-requested"
"ext/test-conf/puppetserver-dep"
"ext/test-conf/puppetserver-requested"
"puppetserver" "puppetserver"
"vendor"])) "vendor"]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment