github.com/m3db/m3@v1.5.1-0.20231129193456-75a402aa583b/scripts/comparator/run.sh (about) 1 #!/usr/bin/env bash 2 3 set -ex 4 export COMPARATOR=$GOPATH/src/github.com/m3db/m3/scripts/comparator 5 source $COMPARATOR/docker-setup.sh 6 7 export REVISION=$(git rev-parse HEAD) 8 9 CI=${CI:-true} 10 RUN_ONLY=${RUN_ONLY:-false} 11 12 export QUERY_FILE=$COMPARATOR/basic_queries/queries.json 13 export REGRESSION_DIR=$COMPARATOR/regression_data 14 export GRAFANA_PATH=$COMPARATOR/grafana 15 export DASHBOARD=$GRAFANA_PATH/dash.json.out 16 17 export END=${END:-$(date +%s)} 18 export START=${START:-$(( $END - 10800 ))} 19 # TODO: make this a bit less hacky in the future; e.g. take from config. 20 export COMPARATOR_WRITE="localhost:9001" 21 22 function generate_dash { 23 TEMPLATE=$GRAFANA_PATH/dashboard.tmpl 24 25 GENERATOR=$GRAFANA_PATH/generate_dash.go 26 27 go run $GENERATOR \ 28 -r=$REVISION \ 29 -q=$QUERY_FILE \ 30 -o=$DASHBOARD \ 31 -t=$TEMPLATE \ 32 -s=$START \ 33 -e=$END 34 } 35 36 if [[ "$RUN_ONLY" == "false" ]] 37 then 38 if [[ ! "$CI" == "true" ]] 39 then 40 echo "generating grafana dashboard" 41 generate_dash 42 fi 43 44 echo "setting up containers" 45 $COMPARATOR/setup.sh 46 47 echo "setting up docker" 48 setup_docker $CI 49 fi 50 51 comparator=$COMPARATOR/compare.out 52 go build -o $comparator $COMPARATOR/. 53 function defer { 54 rm $comparator 55 if [[ "$CI" == "true" ]] 56 then 57 teardown_docker $CI 58 else 59 if [[ "$RUN_ONLY" == "false" ]] 60 then 61 rm $DASHBOARD 62 fi 63 fi 64 } 65 66 if [[ "$RUN_ONLY" == "false" ]] 67 then 68 trap defer EXIT 69 fi 70 71 $comparator -input=$QUERY_FILE \ 72 -s=$START \ 73 -e=$END \ 74 -comparator=$COMPARATOR_WRITE \ 75 -regressionDir=$REGRESSION_DIR 76 77 # Run PromQL testdata tests 78 go test -v -timeout 300s -tags=compatibility -count=1 github.com/m3db/m3/src/query/test/compatibility/