Skip to content

Commit b79661c

Browse files
wu-huia-maurice
authored andcommitted
Add Linux emulator integration tests
PiperOrigin-RevId: 292959264
1 parent 732e4ad commit b79661c

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

firestore/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Note this means on mobile platforms, the integration tests are run within
2929
simulation, as there is no way to setup Firestore emulator if they are run on
3030
real devices.
3131

32+
#### Linux:
33+
34+
```bash
35+
blaze test //firebase/firestore/client/cpp:cc_emulator_tests
36+
```
37+
3238
#### iOS (running within iOS simulator on forge-on-mac, hence `darwin_x86_64`):
3339

3440
(TODO: When tests fail, the messages are not properly formatted, especially

firestore/integration_test_emulator.sh

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,51 @@ sys.exit(1)
4040
' "${1:-0}"
4141
}
4242

43+
# Find JAVA
44+
JAVABIN=$( "$TEST_SRCDIR"/google3/third_party/java/jdk/java_path )
45+
if [[ ! -f "$JAVABIN" ]]; then
46+
echo "Failed to locate java.";
47+
exit 1
48+
fi
49+
4350
# Find executable and shared libs
4451
BINDIR="$TEST_SRCDIR/google3/firebase/firestore/client/cpp"
4552
FIRESTORE_EMULATOR_JAR=$BINDIR/CloudFirestore_emulator.jar
4653
# Pick a random available port with timeout 0
4754
EMULATOR_PORT=$( reserve_random_unused_tcp_port 0 )
4855

49-
# Add java to PATH
50-
JAVABIN=$( ls -d "$TEST_SRCDIR"/google3/third_party/java/jdk/jdk*-k8/bin | \
51-
tail -1 )
52-
PATH=$JAVABIN:$PATH
53-
5456
# Start Firestore Emulator
55-
echo "Running java -jar $FIRESTORE_EMULATOR_JAR --port=$EMULATOR_PORT"
56-
java -jar "$FIRESTORE_EMULATOR_JAR" --port="$EMULATOR_PORT" &
57+
echo "Running $JAVABIN -jar $FIRESTORE_EMULATOR_JAR --port=$EMULATOR_PORT"
58+
"$JAVABIN" -jar "$FIRESTORE_EMULATOR_JAR" --port="$EMULATOR_PORT" &
5759
EMULATOR_PID=$!
5860
sleep 3
5961

6062
# Running Android tests.
6163
if [[ -f "$(ls "$BINDIR"/*_test_android_prod)" ]]; then
62-
for test in $(ls "$BINDIR"/*_test_android_prod); do
63-
"$test" --test_args=firestore_emulator_port="$EMULATOR_PORT" || \
64-
die "Test $test failed" $?
65-
done
64+
for test in $(ls "$BINDIR"/*_test_android_prod); do
65+
"$test" --test_args=firestore_emulator_port="$EMULATOR_PORT" || \
66+
die "Test $test failed" $?
67+
done
6668
fi
6769

6870
# Running iOS tests.
6971
if [[ -f "$(ls "$BINDIR"/*_test_ios)" ]]; then
70-
# Write Firestore Emulator address to a temp file
71-
echo "localhost:$EMULATOR_PORT" > /tmp/emulator_address
72-
for TEST in $(ls "$BINDIR"/*_test_ios); do
73-
"$TEST" || die "Test $TEST failed" $?
74-
done
75-
rm /tmp/emulator_address
72+
# Write Firestore Emulator address to a temp file
73+
echo "localhost:$EMULATOR_PORT" > /tmp/emulator_address
74+
for TEST in $(ls "$BINDIR"/*_test_ios); do
75+
"$TEST" || die "Test $TEST failed" $?
76+
done
77+
rm /tmp/emulator_address
78+
fi
79+
80+
# Running Linux tests.
81+
if [[ -f "$(ls "$BINDIR"/*_test)" ]]; then
82+
# Write Firestore Emulator address to a temp file
83+
echo "localhost:$EMULATOR_PORT" > /tmp/emulator_address
84+
for TEST in $(ls "$BINDIR"/*_test); do
85+
"$TEST" || die "Test $TEST failed" $?
86+
done
87+
rm /tmp/emulator_address
7688
fi
7789

7890
kill $EMULATOR_PID

0 commit comments

Comments
 (0)