From 390f979253ee22a97be3eb7822a883be925907a3 Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Tue, 7 Mar 2023 14:59:48 -0500 Subject: [PATCH] Invoke pbench-agent `profile` for PUT API We use a level of indirection in the `pbench-server.cfg` file to configure the location of the pbench-agent `profile` to use. The `pbench-server` section will have option of `agent-profile` that specifies (typically) `/etc/profile.d/pbench-agent.sh`. --- server/bin/pbench-dispatch.sh | 8 ++++++++ server/bin/state/test-12.config/pbench-server.cfg | 1 + server/bin/state/test-12.reset | 4 ++++ server/bin/state/test-12.setup | 3 +++ server/bin/state/test-21.reset | 1 + server/bin/test-bin/pbench-results-push | 6 +++++- 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 server/bin/state/test-12.reset create mode 120000 server/bin/state/test-21.reset mode change 120000 => 100755 server/bin/test-bin/pbench-results-push diff --git a/server/bin/pbench-dispatch.sh b/server/bin/pbench-dispatch.sh index a7138c8925..82ebb0c46e 100755 --- a/server/bin/pbench-dispatch.sh +++ b/server/bin/pbench-dispatch.sh @@ -63,6 +63,14 @@ fi # Optional "PUT API" bearer token for sending tar balls to the "new" Pbench # Server. put_token=$(getconf.py put-token pbench-server) +if [[ -n "${put_token}" ]]; then + agent_profile=$(getconf.py agent-profile pbench-server) + if [[ ! -e "${agent_profile}" ]]; then + echo "Failed: PUT API token provided but no pbench-agent profile" >> ${errlog} + exit 2 + fi + source ${agent_profile} +fi qdir=$(getconf.py pbench-quarantine-dir pbench-server) if [[ -z "${qdir}" ]]; then diff --git a/server/bin/state/test-12.config/pbench-server.cfg b/server/bin/state/test-12.config/pbench-server.cfg index 98a5600c26..c833e80a5c 100644 --- a/server/bin/state/test-12.config/pbench-server.cfg +++ b/server/bin/state/test-12.config/pbench-server.cfg @@ -2,6 +2,7 @@ install-dir = %(unittest-dir)s/opt/pbench-server [pbench-server] put-token = 71ac1fe3f0743aa710e82000e553ec30 +agent-profile = %(unittest-dir)s/agent-profile [config] path = %(unittest-dir)s/tmp, %(install-dir)s/lib/config diff --git a/server/bin/state/test-12.reset b/server/bin/state/test-12.reset new file mode 100755 index 0000000000..e0e4d78197 --- /dev/null +++ b/server/bin/state/test-12.reset @@ -0,0 +1,4 @@ +#!/bin/bash + +rm ${_testroot}/agent-profile +exit ${?} diff --git a/server/bin/state/test-12.setup b/server/bin/state/test-12.setup index 8b4394651c..a6e81a58d4 100755 --- a/server/bin/state/test-12.setup +++ b/server/bin/state/test-12.setup @@ -1,4 +1,7 @@ #!/bin/bash +cat > ${_testroot}/agent-profile <<-EOF + export _PBENCH_AGENT_CONFIG="fake" + EOF mkdir pbench-local/archive.backup exit ${?} diff --git a/server/bin/state/test-21.reset b/server/bin/state/test-21.reset new file mode 120000 index 0000000000..2e9e2bed08 --- /dev/null +++ b/server/bin/state/test-21.reset @@ -0,0 +1 @@ +test-12.reset \ No newline at end of file diff --git a/server/bin/test-bin/pbench-results-push b/server/bin/test-bin/pbench-results-push deleted file mode 120000 index 1a7a95c2f9..0000000000 --- a/server/bin/test-bin/pbench-results-push +++ /dev/null @@ -1 +0,0 @@ -_mock_simple_cmd_suc \ No newline at end of file diff --git a/server/bin/test-bin/pbench-results-push b/server/bin/test-bin/pbench-results-push new file mode 100755 index 0000000000..520c080106 --- /dev/null +++ b/server/bin/test-bin/pbench-results-push @@ -0,0 +1,5 @@ +#! /bin/bash + +echo "${0##*/} $*" >> $_testlog +test -n "${_PBENCH_AGENT_CONFIG}" +exit ${?}