From 6ab7adcf4442a290ea1743b39c2281bcd29aae21 Mon Sep 17 00:00:00 2001 From: Ramona Alexandra Nechita Date: Thu, 21 Apr 2022 12:35:14 +0300 Subject: [PATCH] prod: tests common: add support for remote logging Added remote logging for all boards in main_tests Signed-off-by: Ramona Alexandra Nechita --- main_tests/lib/production.sh | 49 ++++++++++-------------- main_tests/production_ADRV9361_BOB.sh | 4 +- main_tests/production_ADV9009_CRR-SOM.sh | 6 +-- main_tests/production_ADV9361_CRR-SOM.sh | 2 +- main_tests/production_FMCOMMS4.sh | 4 +- main_tests/production_SYNCHRONA.sh | 2 +- main_tests/setup_env.sh | 7 +++- 7 files changed, 35 insertions(+), 39 deletions(-) diff --git a/main_tests/lib/production.sh b/main_tests/lib/production.sh index bf285041..0bfaf8de 100644 --- a/main_tests/lib/production.sh +++ b/main_tests/lib/production.sh @@ -41,7 +41,6 @@ dut_date_sync() { handle_error_state() { local serial="$1" FAILED=1 - inc_fail_stats "$serial" console_ascii_failed if [ $SYNCHRONIZATION -eq 0 ]; then cat "$LOGFILE" > "$LOGDIR/failed_${serial}_${RUN_TIMESTAMP}.log" @@ -54,7 +53,6 @@ handle_error_state() { handle_skipped_state() { local serial="$1" FAILED=1 - inc_fail_stats "$serial" echo_blue "CALIBRATION WAS SKIPPED. POSSIBLY DUE TO INCOMPATIBLE DEVICE OR LONG INITIALIZATION. PLEASE MAKE SURE YOU USE THE SPECIFIED FREQUENCY COUNTER HAMEG HM8123, 5.12 AND TRY AGAIN" if [ $SYNCHRONIZATION -eq 0 ]; then cat "$LOGFILE" > "$LOGDIR/skipped_${serial}_${RUN_TIMESTAMP}.log" @@ -68,23 +66,6 @@ need_to_read_eeprom() { [ "$FAILED" == "1" ] || ! have_eeprom_vars_loaded } -inc_fail_stats() { - local serial="$1" - let FAILED_CNT='FAILED_CNT + 1' - echo "PASSED_CNT=$PASSED_CNT" > $STATSFILE - echo "FAILED_CNT=$FAILED_CNT" >> $STATSFILE - [ -z "$serial" ] || echo "FAILED $serial" >> $RESULTSFILE -} - -inc_pass_stats() { - local serial="$1" - let PASSED_CNT='PASSED_CNT + 1' - echo "PASSED_CNT=$PASSED_CNT" > $STATSFILE - echo "FAILED_CNT=$FAILED_CNT" >> $STATSFILE - echo "PASSED $serial" >> $RESULTSFILE - console_ascii_passed -} - console_ascii_passed() { echo_green "$(cat $SCRIPT_DIR/lib/passed.ascii)" } @@ -161,7 +142,8 @@ stop_gps_spoofing(){ production() { local TARGET="$1" local MODE="$2" - local IIO_REMOTE=analog.local + local BOARD="$3" + local IIO_REMOTE=analog.local [ -n "$TARGET" ] || { echo_red "No target specified" @@ -182,16 +164,14 @@ production() { # * _errors.log - all errors that don't yet have a S/N # * _stats.log - number of PASSED & FAILED + export DBSERVER="cluster0.oiqey.mongodb.net" + export DBUSERNAME="dev_production1" + export DBNAME="dev_${BOARD}_prod" + export BOARD_NAME="$BOARD" + local LOGDIR=$SCRIPT_DIR/log - # temp log to store stuff, before we know the S/N of device + # temp log to store stuff, before we know the S/N of device local LOGFILE=$LOGDIR/temp.log - # errors that cannot be mapped to any device (because no S/N) - local ERRORSFILE=$LOGDIR/_errors.log - # stats ; how many passes/fails - local STATSFILE=$LOGDIR/_stats.log - # format is " = OK/FAILED" - local RESULTSFILE=$LOGDIR/_results.log - # Remove temp log file start (if it exists) rm -f "$LOGFILE" @@ -204,6 +184,17 @@ production() { RUN_TIMESTAMP="$(date +"%Y-%m-%d_%H-%M-%S")" + if [ -f $SCRIPT_DIR/password.txt ]; then + export DBPASSWORD=$(cat $SCRIPT_DIR/password.txt) + else + echo "Please input the password provided for storing log files remotely" + read $PASSWD + echo $PASSWD > $SCRIPT_DIR/password.txt + export DBPASSWORD=$(cat $SCRIPT_DIR/password.txt) + fi + + + timedatectl | grep "synchronized: yes" SYNCHRONIZATION=$? if [ $SYNCHRONIZATION -ne 0 ]; then @@ -317,7 +308,6 @@ production() { fi if [ "$FAILED" == "0" ] ; then - inc_pass_stats "$BOARD_SERIAL" if [ $SYNCHRONIZATION -eq 0 ]; then cat "$LOGFILE" > "$LOGDIR/passed_${BOARD_SERIAL}_${RUN_TIMESTAMP}.log" else @@ -325,5 +315,6 @@ production() { fi cat /dev/null > "$LOGFILE" fi + telemetry prod-logs-upload --tdir $LOGDIR } diff --git a/main_tests/production_ADRV9361_BOB.sh b/main_tests/production_ADRV9361_BOB.sh index d8b4891c..531c4b59 100755 --- a/main_tests/production_ADRV9361_BOB.sh +++ b/main_tests/production_ADRV9361_BOB.sh @@ -21,12 +21,12 @@ while true; do wait_for_board_online get_board_serial echo_blue "Starting FMCOMMS4 Calibration Test" - production "crr" "$opt" + production "crr" "$opt" "ADRV9361_BOB" break ;; 2) wait_for_board_online get_board_serial - echo_blue "Starting FMCOMMS4 Test" + echo_blue "Starting FMCOMMS4 Test" "ADRV9361_BOB" production "crr" "$opt" break ;; 3) diff --git a/main_tests/production_ADV9009_CRR-SOM.sh b/main_tests/production_ADV9009_CRR-SOM.sh index ff525c5d..d5a90846 100755 --- a/main_tests/production_ADV9009_CRR-SOM.sh +++ b/main_tests/production_ADV9009_CRR-SOM.sh @@ -35,13 +35,13 @@ while true; do wait_for_board_online get_board_serial echo_blue "Starting ADRV Carrier Test" - production "crr" "$opt" + production "crr" "$opt" "ADV9009_CRR-SOM" break ;; 4) wait_for_board_online get_board_serial echo_blue "Starting ADRV SOM Test" - production "som" "$opt" + production "som" "$opt" "ADV9009_CRR-SOM" break ;; 5) wait_for_board_online @@ -52,7 +52,7 @@ while true; do wait_for_board_online echo_blue "Starting FMCOMMS8 Test" dut_date_sync - production "fmcomms8" "$opt" + production "fmcomms8" "$opt" "ADV9009_CRR-SOM" break ;; 7) enforce_root diff --git a/main_tests/production_ADV9361_CRR-SOM.sh b/main_tests/production_ADV9361_CRR-SOM.sh index c15ffc42..dde05757 100755 --- a/main_tests/production_ADV9361_CRR-SOM.sh +++ b/main_tests/production_ADV9361_CRR-SOM.sh @@ -29,7 +29,7 @@ while true; do wait_for_board_online get_board_serial echo_blue "Starting ADRV Carrier Test" - production "crr" "$opt" + production "crr" "$opt" "ADRV9361_CRR-SOM" break ;; 3) enforce_root diff --git a/main_tests/production_FMCOMMS4.sh b/main_tests/production_FMCOMMS4.sh index fc5042a2..9c387e6d 100755 --- a/main_tests/production_FMCOMMS4.sh +++ b/main_tests/production_FMCOMMS4.sh @@ -21,13 +21,13 @@ while true; do wait_for_board_online get_board_serial echo_blue "Starting FMCOMMS4 Calibration Test" - production "crr" "$opt" + production "crr" "$opt" "FMCOMMS4" break ;; 2) wait_for_board_online get_board_serial echo_blue "Starting FMCOMMS4 Test" - production "crr" "$opt" + production "crr" "$opt" "FMCOMMS4" break ;; 3) enforce_root diff --git a/main_tests/production_SYNCHRONA.sh b/main_tests/production_SYNCHRONA.sh index 565c2c73..ad1ac88f 100755 --- a/main_tests/production_SYNCHRONA.sh +++ b/main_tests/production_SYNCHRONA.sh @@ -21,7 +21,7 @@ while true; do wait_for_board_online get_board_serial echo_blue "Starting Synchrona Test" - production "crr" "$opt" + production "crr" "$opt" "SYNCHRONA" break ;; 2) enforce_root diff --git a/main_tests/setup_env.sh b/main_tests/setup_env.sh index 1e5e3ba1..c2b2800d 100755 --- a/main_tests/setup_env.sh +++ b/main_tests/setup_env.sh @@ -137,6 +137,11 @@ setup_pyadi-iio() { popd } +setup_telemetry() { + pip3 install git+https://github.com/sdgtt/telemetry.git + pip3 install junitparser +} + setup_write_autostart_config() { local autostart_path="$HOME/.config/autostart" local configs_disable="blueman light-locker polkit-gnome-authentication-agent-1" @@ -428,7 +433,7 @@ STEPS="bashrc_update disable_sudo_passwd misc_profile_cleanup raspi_config xfce4 STEPS="$STEPS thunar_volman disable_lxde_automount apt_install_prereqs" STEPS="$STEPS write_autostart_config libiio pyadi-iio adm1266" STEPS="$STEPS pi_boot_config disable_pi_screen_blanking" -STEPS="$STEPS dhcp_config" +STEPS="$STEPS dhcp_config telemetry" RAN_ONCE=0 for step in $STEPS ; do