-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmongo-bench-entrypoint.sh
executable file
·79 lines (66 loc) · 2.79 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
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
#!/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 update test
echo 'Running update test...'
./mongo-bench --uri mongodb://root:example@mongodb:27017 --type update --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 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 'Single 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
if [ $? -ne 0 ]; then
echo 'Error: docs test with runAll failed.'
exit 1
fi
echo 'Running duration test...'
./mongo-bench --duration 10 --threads 10 -type insert --uri mongodb://root:example@mongodb:27017
if [ $? -ne 0 ]; then
echo 'Error: duration test with insert failed.'
exit 1
fi
./mongo-bench --duration 10 --threads 10 -type update --uri mongodb://root:example@mongodb:27017
if [ $? -ne 0 ]; then
echo 'Error: duration test with update failed.'
exit 1
fi