File: common.sh

package info (click to toggle)
puppetdb 7.12.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,484 kB
  • sloc: javascript: 23,285; ruby: 5,541; sh: 3,459; python: 389; xml: 181; makefile: 114
file content (36 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (3)
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
STATUS_URL="http://localhost:8080/status/v1/services/puppetdb-status"
QUERY_URL="http://localhost:8080/pdb/query/v4"

set -e

cleanup () {
	retval=$?
	set +e
	if [ -n "${AUTOPKGTEST_ARTIFACTS}" ]; then
		if [ -f /var/log/puppetdb/puppetdb.log ]; then
			cp /var/log/puppetdb/puppetdb.log "${AUTOPKGTEST_ARTIFACTS}"
		fi
		if [ -f /var/log/puppetdb/puppetserver.log ]; then
			cp /var/log/puppetdb/puppetserver.log "${AUTOPKGTEST_ARTIFACTS}"
		fi
		if [ -d /run/systemd/system ]; then
			journalctl -u puppetdb.service > "${AUTOPKGTEST_ARTIFACTS}/journal.log"
			if systemctl --no-pager list-unit-files puppetserver.service > /dev/null; then
				journalctl -u puppetserver.service > "${AUTOPKGTEST_ARTIFACTS}/journal.log"
			fi
		fi
	fi
	return $retval
}

get_status () {
	curl -s "$STATUS_URL"
}

check_status_var () {
	get_status | jq -e ".status[\"$1\"] == $2" >/dev/null 2>&1
}

query () {
	curl -s "${QUERY_URL}/$1"
}