From b70d6dc5513eb71f3e55395b4ee737a4f7e2b849 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Fri, 14 Jul 2023 10:13:55 -0400 Subject: [PATCH] Simplify integration_test.sh, skip building and unit tests --- integration_test.sh | 209 ++++++++------------------------------------ 1 file changed, 35 insertions(+), 174 deletions(-) diff --git a/integration_test.sh b/integration_test.sh index 705f79bd9..577889e65 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -1,183 +1,44 @@ #!/bin/bash go clean --cache -results=() -./test.sh -results+=($?) -if [ "$#" -ne 0 ]; then -# to run the integration tests for gob only add `-rpc=*gob` as argument to this script -# to run for a single dbtype add `-dbtype=*mysql` as argument -# ./integaration_tes.sh -dbtype=*mysql -rpc=*gob -echo "go test github.com/cgrates/cgrates/apier/v1 -tags=integration $@" -go test github.com/cgrates/cgrates/apier/v1 -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/apier/v2 -tags=integration $@" -go test github.com/cgrates/cgrates/apier/v2 -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/engine -tags=integration $@" -go test github.com/cgrates/cgrates/engine -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/ers -tags=integration $@" -go test github.com/cgrates/cgrates/ers -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/loaders -tags=integration $@" -go test github.com/cgrates/cgrates/loaders -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/general_tests -tags=integration $@" -go test github.com/cgrates/cgrates/general_tests -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/agents -tags=integration $@" -go test github.com/cgrates/cgrates/agents -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/sessions -tags=integration $@" -go test github.com/cgrates/cgrates/sessions -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/dispatchers -tags=integration $@" -go test github.com/cgrates/cgrates/dispatchers -tags=integration $@ -results+=($?) -echo "go test github.com/cgrates/cgrates/apier/v1 -tags=offline $@" -go test github.com/cgrates/cgrates/apier/v1 -tags=offline $@ -results+=($?) -else -# Internal -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*internal' -go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*internal -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*internal' -go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*internal -results+=($?) -# SQL -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*mysql' -go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*mysql -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*mysql' -go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*mysql -results+=($?) -# Mongo -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*mongo' -go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*mongo -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*mongo' -go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*mongo -results+=($?) -# Postgres -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/general_tests -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/agents -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*postgres' -go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*postgres -results+=($?) -echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*postgres' -go test github.com/cgrates/cgrates/apier/v1 -tags=offline -dbtype=*postgres -results+=($?) +# Define directories to test and dbtypes +directories=("apier/v1" "apier/v2" "engine" "ers" "loaders" "general_tests" "agents" "sessions" "dispatchers") +dbtypes=("internal" "mysql" "mongo" "postgres") + +results=() + +# check if any arguments passed +if [ "$#" -ne 0 ]; then + for directory in "${directories[@]}"; do + command="go test github.com/cgrates/cgrates/$directory -tags=integration $@" + echo $command + $command + results+=($?) + done +else + # No arguments passed, running with predefined options + for dbtype in "${dbtypes[@]}"; do + for directory in "${directories[@]}"; do + command="go test github.com/cgrates/cgrates/$directory -tags=integration -dbtype=*${dbtype}" + echo $command + $command + results+=($?) + done + done fi -echo 'go test github.com/cgrates/cgrates/config -tags=integration' -go test github.com/cgrates/cgrates/config -tags=integration -results+=($?) -echo 'go test github.com/cgrates/cgrates/migrator -tags=integration' -go test github.com/cgrates/cgrates/migrator -tags=integration -results+=($?) -echo 'go test github.com/cgrates/cgrates/services -tags=integration' -go test github.com/cgrates/cgrates/services -tags=integration -results+=($?) - +# Run tests for packages that don't rely on db connections +directories=("config" "migrator" "services") +for directory in "${directories[@]}"; do + command="go test github.com/cgrates/cgrates/$directory -tags=integration" + echo $command + $command + results+=($?) +done +# Check if any tests failed pass=1 for val in ${results[@]}; do - (( pass=$pass||$val)) + (( pass=$pass||$val)) done -exit $pass \ No newline at end of file +exit $pass