Skip to content

Commit

Permalink
prod: tests common: add support for remote logging
Browse files Browse the repository at this point in the history
Added remote logging for all boards in main_tests

Signed-off-by: Ramona Alexandra Nechita <[email protected]>
  • Loading branch information
ranechita committed Apr 27, 2022
1 parent da17d25 commit 6ab7adc
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 39 deletions.
49 changes: 20 additions & 29 deletions main_tests/lib/production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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)"
}
Expand Down Expand Up @@ -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"
Expand All @@ -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 "<BOARD S/N> = OK/FAILED"
local RESULTSFILE=$LOGDIR/_results.log

# Remove temp log file start (if it exists)
rm -f "$LOGFILE"

Expand All @@ -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
Expand Down Expand Up @@ -317,13 +308,13 @@ 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
cat "$LOGFILE" > "$LOGDIR/no_date_passed_${BOARD_SERIAL}_${RUN_TIMESTAMP}.log"
fi
cat /dev/null > "$LOGFILE"
fi
telemetry prod-logs-upload --tdir $LOGDIR
}

4 changes: 2 additions & 2 deletions main_tests/production_ADRV9361_BOB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions main_tests/production_ADV9009_CRR-SOM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main_tests/production_ADV9361_CRR-SOM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions main_tests/production_FMCOMMS4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main_tests/production_SYNCHRONA.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion main_tests/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6ab7adc

Please sign in to comment.