From 840e93ebc56a57ab7557001fd15b68ee408e229f Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Tue, 30 Mar 2021 09:11:33 +0000 Subject: SPEC-4003: Use pyartiproxy for uploading a file to artyfactory Dumpjournal will now dump to artyfactory by default. Bug-AGL: SPEC-4003 Change-Id: I2ae89be507062bceb84a6a7cbd054dcce09b6874 Signed-off-by: Corentin LABBE --- common/scripts/artiproxy-upload.sh | 37 +++++++++++++++++++++++++++++++++++++ common/scripts/dumpjournal.sh | 12 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 common/scripts/artiproxy-upload.sh diff --git a/common/scripts/artiproxy-upload.sh b/common/scripts/artiproxy-upload.sh new file mode 100755 index 0000000..c4b7dbe --- /dev/null +++ b/common/scripts/artiproxy-upload.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +if [ -z "$PYARTIPROXY_IP" ];then + #echo "ERROR: cannot upload, no PYARTIPROXY_IP" + #exit 1 + # TODO: lab-baylibre-agl does not get env as it should be. I will debug this later. + echo "DEBUG: No PYARTIPROXY_IP variable, fallback to baylibre one" + PYARTIPROXY_IP=10.1.1.47 +fi + +if [ -z "$1" ];then + echo "ERROR: missing path argument" + exit 1 +fi + +if [ -z "$2" ];then + echo "ERROR: missing filename argument" + exit 1 +fi + +curl --silent --show-error -F "filename=$2" -F "data=@$1" http://$PYARTIPROXY_IP:9090/cgi-bin/pyartiproxy.py --output curl.out +if [ $? -ne 0 ];then + echo "ERROR: with curl" + # retry without silent + curl --show-error -F "filename=$2" -F "data=@$1" http://$PYARTIPROXY_IP:9090/cgi-bin/pyartiproxy.py --output curl.out +fi +ARTI_URL=$(grep -E '^http://.*|https://.*' curl.out) +echo "===========================" +cat curl.out +echo "===========================" +if [ -z "$ARTI_URL" ];then + # No URL something is wrong + lava-test-reference artifactory-$2 --result fail + exit 1 +else + lava-test-reference artifactory-$2 --result pass --reference $ARTI_URL +fi diff --git a/common/scripts/dumpjournal.sh b/common/scripts/dumpjournal.sh index 696b994..9316676 100755 --- a/common/scripts/dumpjournal.sh +++ b/common/scripts/dumpjournal.sh @@ -19,6 +19,18 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # +if [ -x ./artiproxy-upload.sh ];then + DUMP_FILE=/tmp/dump + SYSTEMD_COLORS=false journalctl -a --no-pager > $DUMP_FILE + ./artiproxy-upload.sh $DUMP_FILE dumpjournal + # still dump to output if any error arise + if [ $? -eq 0 ];then + exit 0 + fi +else + echo "No upload, fallback to dump to console" +fi + SYSTEMD_COLORS=false journalctl -a --no-pager echo "dumpjournal: pass" exit 0 -- cgit 1.2.3-korg