Skip to content

Commit 47db71e

Browse files
CDRIVER-3749 test mongohouse for C driver
1 parent 2df4bd3 commit 47db71e

17 files changed

+760
-13
lines changed

.evergreen/config.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,52 @@ functions:
671671
set -o xtrace
672672
export EXTRA_CONFIGURE_FLAGS="-DENABLE_COVERAGE=ON -DENABLE_EXAMPLES=OFF"
673673
DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=OFF SSL=OPENSSL SKIP_MOCK_TESTS=ON sh .evergreen/compile.sh
674+
build mongohouse:
675+
- command: shell.exec
676+
type: test
677+
params:
678+
working_dir: mongoc
679+
shell: bash
680+
script: |-
681+
set -o errexit
682+
set -o xtrace
683+
set -o xtrace
684+
if [ ! -d "drivers-evergreen-tools" ]; then
685+
git clone [email protected]:mongodb-labs/drivers-evergreen-tools.git
686+
fi
687+
cd drivers-evergreen-tools
688+
export DRIVERS_TOOLS=$(pwd)
689+
sh .evergreen/atlas_data_lake/build-mongohouse-local.sh
690+
cd ../
691+
run mongohouse:
692+
- command: shell.exec
693+
type: test
694+
params:
695+
working_dir: mongoc
696+
background: true
697+
shell: bash
698+
script: "set -o errexit\nset -o xtrace\nset -o xtrace\ncd drivers-evergreen-tools\
699+
\ \nexport DRIVERS_TOOLS=$(pwd)\nsh .evergreen/atlas_data_lake/run-mongohouse-local.sh"
700+
test mongohouse:
701+
- command: shell.exec
702+
type: test
703+
params:
704+
working_dir: mongoc
705+
shell: bash
706+
script: |-
707+
set -o errexit
708+
set -o xtrace
709+
set -o xtrace
710+
echo "testing that mongohouse is running..."
711+
ps aux | grep mongohouse
712+
echo $(pwd)
713+
echo $(ls)
714+
ls > dir.txt
715+
cat dir.txt
716+
echo $(cat dir.txt)
717+
export RUN_MONGOHOUSE_TESTS=true
718+
./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d
719+
unset RUN_MONGOHOUSE_TESTS
674720
run aws tests:
675721
- command: shell.exec
676722
type: test
@@ -17338,6 +17384,16 @@ tasks:
1733817384
vars:
1733917385
ASAN: 'on'
1734017386
SSL: ssl
17387+
- name: test-mongohouse
17388+
depends_on:
17389+
name: debug-compile-sasl-openssl
17390+
commands:
17391+
- func: fetch build
17392+
vars:
17393+
BUILD_NAME: debug-compile-sasl-openssl
17394+
- func: build mongohouse
17395+
- func: run mongohouse
17396+
- func: test mongohouse
1734117397
- name: test-coverage-mock-server
1734217398
tags:
1734317399
- test-coverage
@@ -23013,6 +23069,12 @@ buildvariants:
2301323069
- test-latest-server-auth-sasl-openssl
2301423070
- test-latest-replica-set-auth-sasl-openssl
2301523071
batchtime: 1440
23072+
- name: mongohouse
23073+
display_name: Mongohouse Test
23074+
run_on: ubuntu1804-test
23075+
tasks:
23076+
- debug-compile-sasl-openssl
23077+
- test-mongohouse
2301623078
- name: ocsp
2301723079
display_name: OCSP tests
2301823080
run_on: ubuntu1804-test

build/evergreen_config_lib/functions.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,48 @@
458458
DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=OFF SSL=OPENSSL SKIP_MOCK_TESTS=ON sh .evergreen/compile.sh
459459
'''),
460460
)),
461+
('build mongohouse', Function(
462+
shell_mongoc(r'''
463+
set -o xtrace
464+
if [ ! -d "drivers-evergreen-tools" ]; then
465+
git clone [email protected]:mongodb-labs/drivers-evergreen-tools.git
466+
fi
467+
cd drivers-evergreen-tools
468+
export DRIVERS_TOOLS=$(pwd)
469+
470+
sh .evergreen/atlas_data_lake/build-mongohouse-local.sh
471+
cd ../
472+
'''),
473+
)),
474+
('run mongohouse', Function(
475+
shell_mongoc(r'''
476+
set -o xtrace
477+
478+
cd drivers-evergreen-tools
479+
export DRIVERS_TOOLS=$(pwd)
480+
481+
sh .evergreen/atlas_data_lake/run-mongohouse-local.sh
482+
''', background=True),
483+
)),
484+
('test mongohouse', Function(
485+
shell_mongoc(r'''
486+
set -o xtrace
487+
echo "testing that mongohouse is running..."
488+
ps aux | grep mongohouse
489+
490+
echo $(pwd)
491+
echo $(ls)
492+
493+
ls > dir.txt
494+
cat dir.txt
495+
echo $(cat dir.txt)
496+
497+
export RUN_MONGOHOUSE_TESTS=true
498+
./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d
499+
unset RUN_MONGOHOUSE_TESTS
500+
501+
'''),
502+
)),
461503
('run aws tests', Function(
462504
shell_mongoc(r'''
463505
# Add AWS variables to a file.

build/evergreen_config_lib/tasks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,13 @@ def __init__(self, *args, **kwargs):
786786
tags=['test-asan'],
787787
depends_on='debug-compile-asan-clang',
788788
commands=[func('run mock server tests', ASAN='on', SSL='ssl')]),
789+
PostCompileTask(
790+
'test-mongohouse',
791+
tags=[],
792+
depends_on='debug-compile-sasl-openssl',
793+
commands=[func('build mongohouse'),
794+
func('run mongohouse'),
795+
func('test mongohouse')]),
789796
# Compile with a function, not a task: gcov files depend on the absolute
790797
# path of the executable, so we can't compile as a separate task.
791798
NamedTask(

build/evergreen_config_lib/variants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ def days(n):
607607
],
608608
{ 'CC': 'gcc' },
609609
batchtime=days(1)),
610+
Variant('mongohouse',
611+
'Mongohouse Test',
612+
'ubuntu1804-test',
613+
['debug-compile-sasl-openssl',
614+
'test-mongohouse'],
615+
{}),
610616
Variant ('ocsp', 'OCSP tests', 'ubuntu1804-test', [
611617
OD([('name', 'debug-compile-nosasl-openssl'), ('distros', ['ubuntu1804-test'])]),
612618
OD([('name', 'debug-compile-nosasl-openssl-static'), ('distros', ['ubuntu1804-test'])]),

src/libmongoc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ set (test-libmongoc-sources
955955
${PROJECT_SOURCE_DIR}/tests/test-mongoc-long-namespace.c
956956
${PROJECT_SOURCE_DIR}/tests/test-mongoc-matcher.c
957957
${PROJECT_SOURCE_DIR}/tests/test-mongoc-max-staleness.c
958+
${PROJECT_SOURCE_DIR}/tests/test-mongoc-mongohouse.c
958959
${PROJECT_SOURCE_DIR}/tests/test-mongoc-mongos-pinning.c
959960
${PROJECT_SOURCE_DIR}/tests/test-mongoc-opts.c
960961
${PROJECT_SOURCE_DIR}/tests/test-mongoc-primary-stepdown.c

src/libmongoc/tests/json-test.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,10 +1459,11 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
14591459
test_framework_getenv ("MONGOC_TEST_AZURE_CLIENT_SECRET");
14601460

14611461
if (!azure_tenant_id || !azure_client_id || !azure_client_secret) {
1462-
fprintf (stderr, "Set MONGOC_TEST_AZURE_TENANT_ID, "
1463-
"MONGOC_TEST_AZURE_CLIENT_ID, and "
1464-
"MONGOC_TEST_AZURE_CLIENT_SECRET to enable CSFLE "
1465-
"tests.");
1462+
fprintf (stderr,
1463+
"Set MONGOC_TEST_AZURE_TENANT_ID, "
1464+
"MONGOC_TEST_AZURE_CLIENT_ID, and "
1465+
"MONGOC_TEST_AZURE_CLIENT_SECRET to enable CSFLE "
1466+
"tests.");
14661467
abort ();
14671468
}
14681469

@@ -1486,9 +1487,10 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
14861487
gcp_privatekey = test_framework_getenv ("MONGOC_TEST_GCP_PRIVATEKEY");
14871488

14881489
if (!gcp_email || !gcp_privatekey) {
1489-
fprintf (stderr, "Set MONGOC_TEST_GCP_EMAIL and "
1490-
"MONGOC_TEST_GCP_PRIVATEKEY to enable CSFLE "
1491-
"tests.");
1490+
fprintf (stderr,
1491+
"Set MONGOC_TEST_GCP_EMAIL and "
1492+
"MONGOC_TEST_GCP_PRIVATEKEY to enable CSFLE "
1493+
"tests.");
14921494
abort ();
14931495
}
14941496

@@ -1692,7 +1694,8 @@ run_json_general_test (const json_test_config_t *config)
16921694

16931695
bson_free (selected_test);
16941696

1695-
uri = test_framework_get_uri ();
1697+
uri = (config->uri_str != NULL) ? mongoc_uri_new (config->uri_str)
1698+
: test_framework_get_uri ();
16961699

16971700
/* If we are using multiple mongos, hardcode them in, for now, but keep
16981701
* the other URI components (CDRIVER-3285) */
@@ -1734,9 +1737,11 @@ run_json_general_test (const json_test_config_t *config)
17341737
NULL,
17351738
&error);
17361739

1737-
/* expect "operation was interrupted", ignore "command not found" */
1740+
/* expect "operation was interrupted", ignore "command not found" or "is
1741+
* not supported" */
17381742
if (!r && (error.domain != MONGOC_ERROR_SERVER ||
1739-
(error.code != 11601 && error.code != 59))) {
1743+
(error.code != 11601 && error.code != 59)) &&
1744+
(strstr (error.message, "is unsupported") == NULL)) {
17401745
MONGOC_WARNING ("Error in killAllSessions: %s", error.message);
17411746
}
17421747

src/libmongoc/tests/json-test.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ typedef struct _json_test_config_t {
3838
json_test_events_check_cb_t events_check_cb;
3939
bool command_started_events_only;
4040
bool command_monitoring_allow_subset;
41+
const char *uri_str;
4142
} json_test_config_t;
4243

43-
#define JSON_TEST_CONFIG_INIT \
44-
{ \
45-
NULL, NULL, NULL, NULL, false \
44+
45+
#define JSON_TEST_CONFIG_INIT \
46+
{ \
47+
NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL \
4648
}
4749

4850
bson_t *
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "Aggregate with pipeline (project, sort, limit)",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "aggregate",
11+
"arguments": {
12+
"pipeline": [
13+
{
14+
"$project": {
15+
"_id": 0
16+
}
17+
},
18+
{
19+
"$sort": {
20+
"a": 1
21+
}
22+
},
23+
{
24+
"$limit": 2
25+
}
26+
]
27+
},
28+
"result": [
29+
{
30+
"a": 1,
31+
"b": 2,
32+
"c": 3
33+
},
34+
{
35+
"a": 2,
36+
"b": 3,
37+
"c": 4
38+
}
39+
]
40+
}
41+
],
42+
"expectations": [
43+
{
44+
"command_started_event": {
45+
"command": {
46+
"aggregate": "driverdata"
47+
}
48+
}
49+
}
50+
]
51+
}
52+
]
53+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "estimatedDocumentCount succeeds",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "estimatedDocumentCount",
11+
"result": 15
12+
}
13+
],
14+
"expectations": [
15+
{
16+
"command_started_event": {
17+
"command": {
18+
"count": "driverdata"
19+
}
20+
}
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "Find with projection and sort",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "find",
11+
"arguments": {
12+
"filter": {
13+
"b": {
14+
"$gt": 5
15+
}
16+
},
17+
"projection": {
18+
"_id": 0
19+
},
20+
"sort": {
21+
"a": 1
22+
},
23+
"limit": 5
24+
},
25+
"result": [
26+
{
27+
"a": 5,
28+
"b": 6,
29+
"c": 7
30+
},
31+
{
32+
"a": 6,
33+
"b": 7,
34+
"c": 8
35+
},
36+
{
37+
"a": 7,
38+
"b": 8,
39+
"c": 9
40+
},
41+
{
42+
"a": 8,
43+
"b": 9,
44+
"c": 10
45+
},
46+
{
47+
"a": 9,
48+
"b": 10,
49+
"c": 11
50+
}
51+
]
52+
}
53+
],
54+
"expectations": [
55+
{
56+
"command_started_event": {
57+
"command": {
58+
"find": "driverdata"
59+
}
60+
}
61+
}
62+
]
63+
}
64+
]
65+
}

0 commit comments

Comments
 (0)