Skip to content

Commit 7559729

Browse files
authored
Allow writing Dapr logs to file in e2e test shell script (#457)
Enhance test script Signed-off-by: Shubham Sharma <[email protected]>
1 parent 5ec2c8d commit 7559729

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

scripts/test-e2e-common.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,38 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

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+
1419
TEST_DAPR_HTTP_PORT=3500
1520
TEST_DAPR_GRPC_PORT=50000
1621
TEST_SERVER_HTTP_PORT=3501
1722
TEST_SERVER_GRPC_PORT=50001
1823

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+
1932
testIdentifier=$1
20-
if [ -z "$testIdentifier" ]; then
21-
$testIdentifier="*"
33+
if [ -z "$testIdentifier" ] || [[ "$testIdentifier" =~ "--debug" ]]; then
34+
testIdentifier="*"
2235
fi
2336
testMatchPattern="test/e2e/common/$testIdentifier.*.test.ts"
2437

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+
2541
# Stop on first error in execution
2642
set -e
2743

2844
stop_dapr() {
29-
echo "Stopping Dapr instances..."
45+
echo "[SCRIPT] Stopping Dapr instances..."
3046
dapr stop --app-id test-suite-grpc
3147
dapr stop --app-id test-suite-http
3248
}
@@ -35,17 +51,17 @@ trap stop_dapr ERR
3551

3652
npm run prebuild
3753

38-
echo "Starting Dapr instances..."
54+
echo "[SCRIPT] Starting Dapr instances..."
3955

4056
# Run Dapr with gRPC
4157
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 &
4359

4460
# Run Dapr with HTTP
4561
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 &
4763

48-
echo "Starting tests..."
64+
echo "[SCRIPT] Starting tests..."
4965

5066
# Run tests
5167
npm run test:e2e "$testMatchPattern"

0 commit comments

Comments
 (0)