1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#!/usr/bin/env bash
# Entrypoint for CI test running on multiple platforms and operating systems
# Requires testing spec argument
# Ex: run core+ext/openjdk-8/pg-13
set -uexo pipefail
usage() { echo 'Usage: $(basename "$0") PDB_TEST_SPEC'; }
misuse() { usage 1>&2; exit 2; }
# Validate arguments
test $# -eq 1 || misuse
spec="$1"
flavor=$(ext/bin/flavor-from-spec "$spec")
case "$flavor" in
core|ext|core+ext)
# Get PostgreSQL version from test spec
pgver="$(ext/bin/prefixed-ref-from-spec "$spec" pg-)"
# Set PostgreSQL test options
ext/bin/test-config --set pgver "$pgver"
ext/bin/test-config --set pgport 34335
# Validate test spec
ext/bin/check-spec-env "$spec"
case "$flavor" in
core|core+ext)
# Run core lein tests with ephemeral PuppetDB and PostgreSQL sandboxes
# Leiningen dev profile adds org.bouncycastle/bcpkix-jdk18on dependency
ext/bin/boxed-core-tests --pglog pg.log \
-- lein with-profiles "${LEIN_PROFILES:-dev}" test 2>&1 \
| tee >(ts "%Y-%m-%d %H:%M:%.S %Z" > test.log)
;;
esac
case "$flavor" in
core+ext) # core will have already run host-info
# Run external tests on a PuppetDB uberjar
ext/bin/run-external-tests
;;
ext)
# Print out host machine info for logging
ext/bin/host-info
# Run external tests on a PuppetDB uberjar
ext/bin/run-external-tests
;;
esac
;;
lint)
# Validate test spec
ext/bin/check-spec-env "$spec"
# Run eastwood linter
lein eastwood
# Run clj-kondo linter
lein kondo --lint src test
;;
rspec)
# Get Puppet version from test spec
puppet_ref="$(ext/bin/prefixed-ref-from-spec "$spec" pup-)"
# Validate test spec
ext/bin/check-spec-env "$spec"
# Run rspec Ruby tests on Ruby code in puppet/ directory
ext/bin/run-rspec-tests "$puppet_ref"
;;
int)
# Get version numbers from test spec
pgver="$(ext/bin/prefixed-ref-from-spec "$spec" pg-)"
puppet="$(ext/bin/prefixed-ref-from-spec "$spec" pup-)"
server="$(ext/bin/prefixed-ref-from-spec "$spec" srv-)"
# Set test options from info in test spec
ext/bin/test-config --set pgver "$pgver"
ext/bin/test-config --set pgport 34335
ext/bin/test-config --set puppet-ref "$puppet"
ext/bin/test-config --set puppetserver-ref "$server"
# If "rich" is in test spec, run rich data tests
PDB_TEST_RICH_DATA="$(ext/bin/spec-includes "$spec" rich)"
export PDB_TEST_RICH_DATA
# Validate test spec
ext/bin/check-spec-env "$spec"
# Run integration tests with Leiningen profile
ext/bin/boxed-integration-tests --pglog pg.log \
-- lein with-profiles "${LEIN_PROFILES:-dev}" test :integration 2>&1 \
| tee >(ts "%Y-%m-%d %H:%M:%.S %Z" > test.log)
;;
*)
# Error when test spec is unrecognized
echo "Unrecognized spec: $flavor" 1>&2;
exit 2
;;
esac
|