Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
#!/bin/bash

check_for_success() {
    "${@}" && echo -e "\n ---> Passed test of '${@}'\n\n" || exit 1
}

check_for_failure() {
    "${@}" && exit 1 || echo -e "\n ---> Passed test of '${@}'\n\n"
}

check_for_full(){
    count=`echo ${@} | python3 -c 'import json,sys;data=json.load(sys.stdin);print(len(data.keys()))'`
    echo $count
    if [[ $count -gt 0 ]]
    then 
	entries=`echo ${@} | python3 -c 'import json,sys;data=json.load(sys.stdin);print(list(data.keys()))'`
	echo -e "\n ---> passed getPayloadData.py --discover test : found $count entries: $entries"
    else 
	echo -e "getPayloadData.py --discover test not passed... found no entries"
	exit 1
    fi
}

########################################
# Test help function
########################################
check_for_success getPayloadData.py --help

########################################
# Test discover function
########################################
check_for_success getPayloadData.py --discover

########################################
# Test length of discovered dictionary
########################################
OUT=$(getPayloadData.py --discover)
check_for_full $OUT

########################################
# Test BasicPayload mult-iov single tag
########################################
check_for_success getPayloadData.py \
    --plugin pluginBasicPayload_PayloadInspector \
    --plot plot_BasicPayload_data0 \
    --tag BasicPayload_v0 \
    --time_type Run \
    --iovs '{"start_iov": "1", "end_iov": "101"}' \
    --db Prod \
    --test ;

########################################
# Test BasicPayload with input
########################################
check_for_success getPayloadData.py \
    --plugin pluginBasicPayload_PayloadInspector \
    --plot plot_BasicPayload_data0_withInput \
    --tag BasicPayload_v0 \
    --input_params '{"Factor":"1","Offset":"2","Scale":"3"}' \
    --time_type Run \
    --iovs '{"start_iov": "1", "end_iov": "101"}' \
    --db Prod \
    --test ;

########################################
# Test BasicPayload with wrong inputs
########################################
check_for_failure getPayloadData.py \
    --plugin pluginBasicPayload_PayloadInspector \
    --plot plot_BasicPayload_data0 \
    --tag BasicPayload \
    --time_type Run \
    --iovs '{"start_iov": "1", "end_iov": "101"}' \
    --db Prod \
    --test ;

########################################
# Test BasicPayload single-iov, multi-tag
########################################
check_for_success getPayloadData.py \
    --plugin pluginBasicPayload_PayloadInspector \
    --plot plot_BasicPayload_data7 \
    --tag BasicPayload_v0 \
    --tagtwo BasicPayload_v1 \
    --time_type Run \
    --iovs '{"start_iov": "1", "end_iov": "1"}' \
    --iovstwo '{"start_iov": "101", "end_iov": "101"}' \
    --db Prod \
    --test ;

########################################
# Test BasicPayload single-iov, with suppress output
########################################
check_for_success getPayloadData.py \
    --plugin pluginBasicPayload_PayloadInspector \
    --plot plot_BasicPayload_data5 \
    --tag BasicPayload_v10.0 \
    --input_params '{}' \
    --time_type Run \
    --iovs '{"start_iov": "601", "end_iov": "601"}' \
    --db Prod \
    --suppress-output ;

########################################
# Test in production style
########################################
check_for_success getPayloadData.py \
    --plugin pluginBasicPayload_PayloadInspector \
    --plot plot_BasicPayload_data6 \
    --tag BasicPayload_v0 \
    --input_params '{}' \
    --time_type Run \
    --iovs '{"start_iov": "1", "end_iov": "1"}' \
    --db Prod \
    --suppress-output \
    --image_plot;