From 92945bb0ffa2a8f604f3bae3111e1cd10af516b8 Mon Sep 17 00:00:00 2001 From: Minh Diep Date: Wed, 14 Sep 2022 20:41:37 -0700 Subject: [PATCH] LU-16183 tests: sanity-hsm/70 should detect python Check for python2 and python3 explicitly, since the generic python command does not exist in newer distros. Test-Parameters: env=SLOW=yes,ENABLE_QUOTA=yes \ clientdistro=sles15sp3 testlist=sanity-hsm Test-Parameters: env=SLOW=yes,ENABLE_QUOTA=yes \ clientdistro=el7.9 testlist=sanity-hsm Signed-off-by: Minh Diep Change-Id: I2251be461129310868868277bf9d46015545ffe2 Reviewed-on: https://review.whamcloud.com/48577 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Alex Deiter Reviewed-by: Andreas Dilger --- lustre/tests/sanity-hsm.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 6981896..a65d698 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -429,12 +429,20 @@ parse_json_event() { local raw_event=$1 # python2.6 in EL6 includes an internal json module + local PYTHON='python' local json_parser='import json; import fileinput;' - json_parser+=' print "\n".join(["local %s=\"%s\"" % tuple for tuple in ' + json_parser+=' print("\n".join(["local %s=\"%s\"" % tuple for tuple in ' json_parser+='json.loads([line for line in ' - json_parser+='fileinput.input()][0]).items()])' + json_parser+='fileinput.input()][0]).items()]))' - echo $raw_event | python -c "$json_parser" + # check if python/python2/python3 is available + if ! which $PYTHON > /dev/null 2>&1 ; then + PYTHON='python2' + if ! which $PYTHON > /dev/null 2>&1 ; then + PYTHON='python3' + fi + fi + echo $raw_event | $PYTHON -c "$json_parser" } get_agent_by_uuid_mdt() { -- 1.8.3.1