11
11
# See the License for the specific language governing permissions and
12
12
# limitations under the License.
13
13
14
+ # Usage: ./scripts/test-e2e-common.sh [testIdentifier] [--debug]
15
+ # testIdentifier: The test identifier to run. If not specified, all tests will be run. Possible values: "client" and "server".
16
+ # --debug: If passed, Dapr logs will be output to a file.
17
+ # Flag should always be the last argument.
18
+
14
19
TEST_DAPR_HTTP_PORT=3500
15
20
TEST_DAPR_GRPC_PORT=50000
16
21
TEST_SERVER_HTTP_PORT=3501
17
22
TEST_SERVER_GRPC_PORT=50001
18
23
24
+ GRPC_OUTPUT_FILE=" /dev/null"
25
+ HTTP_OUTPUT_FILE=" /dev/null"
26
+ # If --debug is passed, output Dapr logs to a file.
27
+ if [[ " $@ " =~ " --debug" ]]; then
28
+ GRPC_OUTPUT_FILE=" dapr-grpc.log"
29
+ HTTP_OUTPUT_FILE=" dapr-http.log"
30
+ fi
31
+
19
32
testIdentifier=$1
20
- if [ -z " $testIdentifier " ]; then
21
- $ testIdentifier =" *"
33
+ if [ -z " $testIdentifier " ] || [[ " $testIdentifier " =~ " --debug " ]] ; then
34
+ testIdentifier=" *"
22
35
fi
23
36
testMatchPattern=" test/e2e/common/$testIdentifier .*.test.ts"
24
37
38
+ echo " [SCRIPT] Running tests matching pattern: $testMatchPattern "
39
+ echo " [SCRIPT] Outputting Dapr logs to $GRPC_OUTPUT_FILE (gRPC) and $HTTP_OUTPUT_FILE (HTTP)"
40
+
25
41
# Stop on first error in execution
26
42
set -e
27
43
28
44
stop_dapr () {
29
- echo " Stopping Dapr instances..."
45
+ echo " [SCRIPT] Stopping Dapr instances..."
30
46
dapr stop --app-id test-suite-grpc
31
47
dapr stop --app-id test-suite-http
32
48
}
@@ -35,17 +51,17 @@ trap stop_dapr ERR
35
51
36
52
npm run prebuild
37
53
38
- echo " Starting Dapr instances..."
54
+ echo " [SCRIPT] Starting Dapr instances..."
39
55
40
56
# Run Dapr with gRPC
41
57
dapr run --app-id test-suite-grpc --app-protocol grpc --app-port $TEST_SERVER_GRPC_PORT \
42
- --dapr-grpc-port $TEST_DAPR_GRPC_PORT --components-path ./test/components/common > /dev/null 2>&1 &
58
+ --dapr-grpc-port $TEST_DAPR_GRPC_PORT --components-path ./test/components/common > $GRPC_OUTPUT_FILE 2>&1 &
43
59
44
60
# Run Dapr with HTTP
45
61
dapr run --app-id test-suite-http --app-protocol http --app-port $TEST_SERVER_HTTP_PORT \
46
- --dapr-http-port $TEST_DAPR_HTTP_PORT --components-path ./test/components/common > /dev/null 2>&1 &
62
+ --dapr-http-port $TEST_DAPR_HTTP_PORT --components-path ./test/components/common > $HTTP_OUTPUT_FILE 2>&1 &
47
63
48
- echo " Starting tests..."
64
+ echo " [SCRIPT] Starting tests..."
49
65
50
66
# Run tests
51
67
npm run test:e2e " $testMatchPattern "
0 commit comments