mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 23:58:44 +05:00
Revise integration_test.sh script
This commit is contained in:
committed by
Dan Christian Bogos
parent
4eb2b9d5d4
commit
baea103b07
@@ -1,44 +1,53 @@
|
||||
#!/bin/bash
|
||||
go clean --cache
|
||||
|
||||
# Define directories to test and dbtypes
|
||||
directories=("apier/v1" "apier/v2" "engine" "ers" "loaders" "general_tests" "agents" "sessions" "dispatchers")
|
||||
dbtypes=("internal" "mysql" "mongo" "postgres")
|
||||
# This script is used to run integration tests on various packages with different tags and dbtypes.
|
||||
# Usage:
|
||||
# - To run all the integration tests, don't add any arguments.
|
||||
# - To run the integration tests for gob only add `-rpc=*gob` as an argument to this script.
|
||||
# - To run for a single dbtype add `-dbtype=*mysql` as an argument.
|
||||
# Example:
|
||||
# ./integration_test.sh -dbtype=*mysql -rpc=*gob
|
||||
|
||||
packages=("agents" "apier/v1" "apier/v2" "dispatchers" "engine" "ers" "loaders" "general_tests" "sessions")
|
||||
dbtypes=("*internal" "*mysql" "*mongo" "*postgres")
|
||||
|
||||
# Tests that are independent of the dbtype flag and run only once
|
||||
single_run_packages=("config" "services" "migrator")
|
||||
|
||||
results=()
|
||||
|
||||
# check if any arguments passed
|
||||
execute_test() {
|
||||
echo "Executing: go test github.com/cgrates/cgrates/$1 -tags=$2 $3"
|
||||
go test "github.com/cgrates/cgrates/$1" -tags="$2" "$3"
|
||||
results+=($?)
|
||||
}
|
||||
|
||||
go clean --cache
|
||||
|
||||
# Execute tests based on passed arguments
|
||||
if [ "$#" -ne 0 ]; then
|
||||
for directory in "${directories[@]}"; do
|
||||
command="go test github.com/cgrates/cgrates/$directory -tags=integration $@"
|
||||
echo $command
|
||||
$command
|
||||
results+=($?)
|
||||
for pkg in "${packages[@]}"; do
|
||||
execute_test "$pkg" "integration" "$@"
|
||||
[ "$pkg" == "apier/v1" ] && execute_test "$pkg" "offline" "$@"
|
||||
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+=($?)
|
||||
# Execute tests for all db types if no arguments have been passed
|
||||
for db in "${dbtypes[@]}"; do
|
||||
for pkg in "${packages[@]}"; do
|
||||
execute_test "$pkg" "integration" "-dbtype=$db"
|
||||
[ "$pkg" == "apier/v1" ] && execute_test "$pkg" "offline" "-dbtype=$db"
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
# 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+=($?)
|
||||
# Execute the tests that run only once
|
||||
for test in "${single_run_packages[@]}"; do
|
||||
execute_test "$test" "integration"
|
||||
done
|
||||
|
||||
# Check if any tests failed
|
||||
# Check the results and exit with an appropriate code
|
||||
pass=1
|
||||
for val in ${results[@]}; do
|
||||
(( pass=$pass||$val))
|
||||
for val in "${results[@]}"; do
|
||||
(( pass=pass||val))
|
||||
done
|
||||
exit $pass
|
||||
exit $pass
|
||||
Reference in New Issue
Block a user