-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongo-bench-entrypoint.sh
executable file
·51 lines (42 loc) · 1.85 KB
/
mongo-bench-entrypoint.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
#!/bin/bash
# Wait for MongoDB to be ready
until nc -z mongodb 27017; do
echo 'Waiting for MongoDB...'
sleep 2
done
# Run the insert test
echo 'Running insert test...'
./mongo-bench --uri mongodb://root:example@mongodb:27017 --type insert --threads 11 --docs 80055
# Check the document count and verify it's 1000
echo 'Checking document count...'
DOC_COUNT=$(mongosh 'mongodb://root:example@mongodb:27017/?authSource=admin' --quiet --eval 'JSON.stringify({count: db.getSiblingDB("benchmarking").testdata.countDocuments()})' | jq -r '.count')
if [ -z "$DOC_COUNT" ]; then
echo 'Error: Failed to retrieve document count.'
exit 1
elif [ "$DOC_COUNT" -ne 80055 ]; then
echo "Error: Expected 80055 documents, found $DOC_COUNT"
exit 1
fi
# Run the delete test
echo 'Running delete test...'
./mongo-bench --uri mongodb://root:example@mongodb:27017 --type delete --threads 10 --docs 80055
echo 'Checking document count...'
DOC_COUNT=$(mongosh 'mongodb://root:example@mongodb:27017/?authSource=admin' --quiet --eval 'JSON.stringify({count: db.getSiblingDB("benchmarking").testdata.countDocuments()})' | jq -r '.count')
if [ "$DOC_COUNT" -ne 0 ]; then
echo "Error: Expected 0 documents, found $DOC_COUNT"
exit 1
fi
# Run the upsert test
echo 'Running upsert test...'
./mongo-bench --uri mongodb://root:example@mongodb:27017 --type upsert --threads 10 --docs 80000
echo 'Checking document count...'
DOC_COUNT=$(mongosh 'mongodb://root:example@mongodb:27017/?authSource=admin' --quiet --eval 'JSON.stringify({count: db.getSiblingDB("benchmarking").testdata.countDocuments()})' | jq -r '.count')
if [ "$DOC_COUNT" -gt 0 ]; then
echo 'All tests passed successfully.'
else
echo "Error: Expected >0 documents, found $DOC_COUNT"
exit 1
fi
# Run the all test
echo 'Running all test...'
./mongo-bench --uri mongodb://root:example@mongodb:27017 --runAll --threads 10 --docs 80000