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

Update multihost-test to use tmt topology #423

Merged
merged 1 commit into from
Aug 4, 2023
Merged
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
41 changes: 30 additions & 11 deletions Multihost/basic-attestation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@
[ -n "$REVOCATION_NOTIFIER" ] || REVOCATION_NOTIFIER=agent


function assign_server_roles() {
if [ -f ${TMT_TOPOLOGY_BASH} ]; then
# assign roles based on tmt topology data
cat ${TMT_TOPOLOGY_BASH}
. ${TMT_TOPOLOGY_BASH}

Check warning

Code scanning / shellcheck

ShellCheck can't follow non-constant source. Use a directive to specify location. Warning test

ShellCheck can't follow non-constant source. Use a directive to specify location.

export VERIFIER=${TMT_GUESTS["verifier.hostname"]}
export REGISTRAR=${TMT_GUESTS["registrar.hostname"]}
export AGENT=${TMT_GUESTS["agent.hostname"]}
# AGENT2 may not be defined
if [ -n "${TMT_GUESTS["agent2.hostname"]}" ]; then
export AGENT2=${TMT_GUESTS["agent2.hostname"]}
fi
elif [ -n "$SERVERS" ]; then
# assign roles using SERVERS and CLIENTS variables
export VERIFIER=$( echo "$SERVERS $CLIENTS" | awk '{ print $1 }')
export REGISTRAR=$( echo "$SERVERS $CLIENTS" | awk '{ print $2 }')
export AGENT=$( echo "$SERVERS $CLIENTS" | awk '{ print $3 }')
export AGENT2=$( echo "$SERVERS $CLIENTS" | awk '{ print $4 }')
fi

MY_IP=$( hostname -I | awk '{ print $1 }' )
[ -n "$VERIFIER" ] && export VERIFIER_IP=$( get_IP $VERIFIER )
[ -n "$REGISTRAR" ] && export REGISTRAR_IP=$( get_IP $REGISTRAR )
[ -n "${AGENT}" ] && export AGENT_IP=$( get_IP ${AGENT} )
[ -n "${AGENT2}" ] && export AGENT2_IP=$( get_IP ${AGENT2} )
}

function get_IP() {
if echo $1 | grep -E -q '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then
echo $1
Expand Down Expand Up @@ -470,18 +498,9 @@
rlRun 'rlImport "./test-helpers"' || rlDie "cannot import keylime-tests/test-helpers library"
rlRun 'rlImport "./sync"' || rlDie "cannot import keylime-tests/sync library"
rlRun 'rlImport "openssl/certgen"' || rlDie "cannot import openssl/certgen library"

# assigne custom roles using SERVERS and CLIENTS variables
export VERIFIER=$( echo "$SERVERS $CLIENTS" | awk '{ print $1 }')
export REGISTRAR=$( echo "$SERVERS $CLIENTS" | awk '{ print $2 }')
export AGENT=$( echo "$SERVERS $CLIENTS" | awk '{ print $3 }')
export AGENT2=$( echo "$SERVERS $CLIENTS" | awk '{ print $4 }')

MY_IP=$( hostname -I | awk '{ print $1 }' )
[ -n "$VERIFIER" ] && export VERIFIER_IP=$( get_IP $VERIFIER )
[ -n "$REGISTRAR" ] && export REGISTRAR_IP=$( get_IP $REGISTRAR )
[ -n "${AGENT}" ] && export AGENT_IP=$( get_IP ${AGENT} )
[ -n "${AGENT2}" ] && export AGENT2_IP=$( get_IP ${AGENT2} )
assign_server_roles

rlLog "VERIFIER: $VERIFIER ${VERIFIER_IP}"
rlLog "REGISTRAR: $REGISTRAR ${REGISTRAR_IP}"
rlLog "AGENT: ${AGENT} ${AGENT_IP}"
Expand Down