-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathrun_tests.sh
101 lines (91 loc) · 2.17 KB
/
run_tests.sh
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
#!/bin/bash
set -eo pipefail
DATABASE_ENGINGE=mariadb
RUN_UNIT=false
RUN_LINT=false
RUN_INTEGRATION=false
RUN_ALL=true
CLEAN_INTEGRATION_ASSETS=true
function run_linter {
if [[ "$RUN_LINT" == "true" || "$RUN_ALL" == "true" ]]; then
helm lint .
fi
}
function run_unit_tests {
if [[ "$RUN_UNIT" == "true" || "$RUN_ALL" == "true" ]]; then
helm unittest --color .
fi
}
function run_integration_tests {
local database="$1"
if [[ "$RUN_INTEGRATION" == "true" || "$RUN_ALL" == "true" ]]; then
source tests/integration/fixtures/install_dependencies.sh
installDependencies
bash tests/integration/fixtures/create-cluster-with-passbolt.sh "$database"
"$HELM_BINARY" test --logs passbolt -n default
fi
}
function clean_integration_assets {
if [[ "$RUN_INTEGRATION" == "true" ]] || [[ "$RUN_ALL" == "true" ]] && [[ "$CLEAN_INTEGRATION_ASSETS" == "true" ]]; then
echo Cleaning integration testing assets...
rm -f helm kubectl kind mkcerts passbolt
fi
}
function showHelp {
echo "Run the available tests for passbolt helm charts"
echo
echo "Syntax: $0 [options]"
echo "$0 with no arguments will run all of the available tests."
echo
echo "options:"
echo "-h|--help Show this message."
echo "-l|--lint Run helm lint."
echo "-u|--unit Run helm unittest tests."
echo "-i|--integration Run integration tests."
echo "-d|--database [option] Database to run integration tests to [mariadb|postgresql]."
echo "-no-clean Skip cleaning step."
echo
exit 0
}
function run_all {
run_linter
run_unit_tests
run_integration_tests "$DATABASE_ENGINGE"
clean_integration_assets
}
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help)
showHelp
;;
-l | --lint)
RUN_ALL=false
RUN_LINT=true
shift
;;
-u | --unit)
RUN_ALL=false
RUN_UNIT=true
shift
;;
-i | --integration)
RUN_ALL=false
RUN_INTEGRATION=true
shift
;;
-d | --database)
shift
DATABASE_ENGINGE=$1
shift
;;
--no-clean)
CLEAN_INTEGRATION_ASSETS=false
shift
;;
*)
echo "Unknown argurment $1"
shift
;;
esac
done
run_all