Skip to content

Commit

Permalink
CDRIVER-3749 test mongohouse for C driver
Browse files Browse the repository at this point in the history
  • Loading branch information
samantharitter committed Dec 16, 2020
1 parent 2df4bd3 commit 47db71e
Show file tree
Hide file tree
Showing 17 changed files with 760 additions and 13 deletions.
62 changes: 62 additions & 0 deletions .evergreen/config.yml
Expand Up @@ -671,6 +671,52 @@ functions:
set -o xtrace
export EXTRA_CONFIGURE_FLAGS="-DENABLE_COVERAGE=ON -DENABLE_EXAMPLES=OFF"
DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=OFF SSL=OPENSSL SKIP_MOCK_TESTS=ON sh .evergreen/compile.sh
build mongohouse:
- command: shell.exec
type: test
params:
working_dir: mongoc
shell: bash
script: |-
set -o errexit
set -o xtrace
set -o xtrace
if [ ! -d "drivers-evergreen-tools" ]; then
git clone git@github.com:mongodb-labs/drivers-evergreen-tools.git
fi
cd drivers-evergreen-tools
export DRIVERS_TOOLS=$(pwd)
sh .evergreen/atlas_data_lake/build-mongohouse-local.sh
cd ../
run mongohouse:
- command: shell.exec
type: test
params:
working_dir: mongoc
background: true
shell: bash
script: "set -o errexit\nset -o xtrace\nset -o xtrace\ncd drivers-evergreen-tools\
\ \nexport DRIVERS_TOOLS=$(pwd)\nsh .evergreen/atlas_data_lake/run-mongohouse-local.sh"
test mongohouse:
- command: shell.exec
type: test
params:
working_dir: mongoc
shell: bash
script: |-
set -o errexit
set -o xtrace
set -o xtrace
echo "testing that mongohouse is running..."
ps aux | grep mongohouse
echo $(pwd)
echo $(ls)
ls > dir.txt
cat dir.txt
echo $(cat dir.txt)
export RUN_MONGOHOUSE_TESTS=true
./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d
unset RUN_MONGOHOUSE_TESTS
run aws tests:
- command: shell.exec
type: test
Expand Down Expand Up @@ -17338,6 +17384,16 @@ tasks:
vars:
ASAN: 'on'
SSL: ssl
- name: test-mongohouse
depends_on:
name: debug-compile-sasl-openssl
commands:
- func: fetch build
vars:
BUILD_NAME: debug-compile-sasl-openssl
- func: build mongohouse
- func: run mongohouse
- func: test mongohouse
- name: test-coverage-mock-server
tags:
- test-coverage
Expand Down Expand Up @@ -23013,6 +23069,12 @@ buildvariants:
- test-latest-server-auth-sasl-openssl
- test-latest-replica-set-auth-sasl-openssl
batchtime: 1440
- name: mongohouse
display_name: Mongohouse Test
run_on: ubuntu1804-test
tasks:
- debug-compile-sasl-openssl
- test-mongohouse
- name: ocsp
display_name: OCSP tests
run_on: ubuntu1804-test
Expand Down
42 changes: 42 additions & 0 deletions build/evergreen_config_lib/functions.py
Expand Up @@ -458,6 +458,48 @@
DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=OFF SSL=OPENSSL SKIP_MOCK_TESTS=ON sh .evergreen/compile.sh
'''),
)),
('build mongohouse', Function(
shell_mongoc(r'''
set -o xtrace
if [ ! -d "drivers-evergreen-tools" ]; then
git clone git@github.com:mongodb-labs/drivers-evergreen-tools.git
fi
cd drivers-evergreen-tools
export DRIVERS_TOOLS=$(pwd)
sh .evergreen/atlas_data_lake/build-mongohouse-local.sh
cd ../
'''),
)),
('run mongohouse', Function(
shell_mongoc(r'''
set -o xtrace
cd drivers-evergreen-tools
export DRIVERS_TOOLS=$(pwd)
sh .evergreen/atlas_data_lake/run-mongohouse-local.sh
''', background=True),
)),
('test mongohouse', Function(
shell_mongoc(r'''
set -o xtrace
echo "testing that mongohouse is running..."
ps aux | grep mongohouse
echo $(pwd)
echo $(ls)
ls > dir.txt
cat dir.txt
echo $(cat dir.txt)
export RUN_MONGOHOUSE_TESTS=true
./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d
unset RUN_MONGOHOUSE_TESTS
'''),
)),
('run aws tests', Function(
shell_mongoc(r'''
# Add AWS variables to a file.
Expand Down
7 changes: 7 additions & 0 deletions build/evergreen_config_lib/tasks.py
Expand Up @@ -786,6 +786,13 @@ def __init__(self, *args, **kwargs):
tags=['test-asan'],
depends_on='debug-compile-asan-clang',
commands=[func('run mock server tests', ASAN='on', SSL='ssl')]),
PostCompileTask(
'test-mongohouse',
tags=[],
depends_on='debug-compile-sasl-openssl',
commands=[func('build mongohouse'),
func('run mongohouse'),
func('test mongohouse')]),
# Compile with a function, not a task: gcov files depend on the absolute
# path of the executable, so we can't compile as a separate task.
NamedTask(
Expand Down
6 changes: 6 additions & 0 deletions build/evergreen_config_lib/variants.py
Expand Up @@ -607,6 +607,12 @@ def days(n):
],
{ 'CC': 'gcc' },
batchtime=days(1)),
Variant('mongohouse',
'Mongohouse Test',
'ubuntu1804-test',
['debug-compile-sasl-openssl',
'test-mongohouse'],
{}),
Variant ('ocsp', 'OCSP tests', 'ubuntu1804-test', [
OD([('name', 'debug-compile-nosasl-openssl'), ('distros', ['ubuntu1804-test'])]),
OD([('name', 'debug-compile-nosasl-openssl-static'), ('distros', ['ubuntu1804-test'])]),
Expand Down
1 change: 1 addition & 0 deletions src/libmongoc/CMakeLists.txt
Expand Up @@ -955,6 +955,7 @@ set (test-libmongoc-sources
${PROJECT_SOURCE_DIR}/tests/test-mongoc-long-namespace.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-matcher.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-max-staleness.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-mongohouse.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-mongos-pinning.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-opts.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-primary-stepdown.c
Expand Down
25 changes: 15 additions & 10 deletions src/libmongoc/tests/json-test.c
Expand Up @@ -1459,10 +1459,11 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
test_framework_getenv ("MONGOC_TEST_AZURE_CLIENT_SECRET");

if (!azure_tenant_id || !azure_client_id || !azure_client_secret) {
fprintf (stderr, "Set MONGOC_TEST_AZURE_TENANT_ID, "
"MONGOC_TEST_AZURE_CLIENT_ID, and "
"MONGOC_TEST_AZURE_CLIENT_SECRET to enable CSFLE "
"tests.");
fprintf (stderr,
"Set MONGOC_TEST_AZURE_TENANT_ID, "
"MONGOC_TEST_AZURE_CLIENT_ID, and "
"MONGOC_TEST_AZURE_CLIENT_SECRET to enable CSFLE "
"tests.");
abort ();
}

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

if (!gcp_email || !gcp_privatekey) {
fprintf (stderr, "Set MONGOC_TEST_GCP_EMAIL and "
"MONGOC_TEST_GCP_PRIVATEKEY to enable CSFLE "
"tests.");
fprintf (stderr,
"Set MONGOC_TEST_GCP_EMAIL and "
"MONGOC_TEST_GCP_PRIVATEKEY to enable CSFLE "
"tests.");
abort ();
}

Expand Down Expand Up @@ -1692,7 +1694,8 @@ run_json_general_test (const json_test_config_t *config)

bson_free (selected_test);

uri = test_framework_get_uri ();
uri = (config->uri_str != NULL) ? mongoc_uri_new (config->uri_str)
: test_framework_get_uri ();

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

/* expect "operation was interrupted", ignore "command not found" */
/* expect "operation was interrupted", ignore "command not found" or "is
* not supported" */
if (!r && (error.domain != MONGOC_ERROR_SERVER ||
(error.code != 11601 && error.code != 59))) {
(error.code != 11601 && error.code != 59)) &&
(strstr (error.message, "is unsupported") == NULL)) {
MONGOC_WARNING ("Error in killAllSessions: %s", error.message);
}

Expand Down
8 changes: 5 additions & 3 deletions src/libmongoc/tests/json-test.h
Expand Up @@ -38,11 +38,13 @@ typedef struct _json_test_config_t {
json_test_events_check_cb_t events_check_cb;
bool command_started_events_only;
bool command_monitoring_allow_subset;
const char *uri_str;
} json_test_config_t;

#define JSON_TEST_CONFIG_INIT \
{ \
NULL, NULL, NULL, NULL, false \

#define JSON_TEST_CONFIG_INIT \
{ \
NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL \
}

bson_t *
Expand Down
53 changes: 53 additions & 0 deletions src/libmongoc/tests/json/mongohouse/aggregate.json
@@ -0,0 +1,53 @@
{
"collection_name": "driverdata",
"database_name": "test",
"tests": [
{
"description": "Aggregate with pipeline (project, sort, limit)",
"operations": [
{
"object": "collection",
"name": "aggregate",
"arguments": {
"pipeline": [
{
"$project": {
"_id": 0
}
},
{
"$sort": {
"a": 1
}
},
{
"$limit": 2
}
]
},
"result": [
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 2,
"b": 3,
"c": 4
}
]
}
],
"expectations": [
{
"command_started_event": {
"command": {
"aggregate": "driverdata"
}
}
}
]
}
]
}
25 changes: 25 additions & 0 deletions src/libmongoc/tests/json/mongohouse/estimatedDocumentCount.json
@@ -0,0 +1,25 @@
{
"collection_name": "driverdata",
"database_name": "test",
"tests": [
{
"description": "estimatedDocumentCount succeeds",
"operations": [
{
"object": "collection",
"name": "estimatedDocumentCount",
"result": 15
}
],
"expectations": [
{
"command_started_event": {
"command": {
"count": "driverdata"
}
}
}
]
}
]
}
65 changes: 65 additions & 0 deletions src/libmongoc/tests/json/mongohouse/find.json
@@ -0,0 +1,65 @@
{
"collection_name": "driverdata",
"database_name": "test",
"tests": [
{
"description": "Find with projection and sort",
"operations": [
{
"object": "collection",
"name": "find",
"arguments": {
"filter": {
"b": {
"$gt": 5
}
},
"projection": {
"_id": 0
},
"sort": {
"a": 1
},
"limit": 5
},
"result": [
{
"a": 5,
"b": 6,
"c": 7
},
{
"a": 6,
"b": 7,
"c": 8
},
{
"a": 7,
"b": 8,
"c": 9
},
{
"a": 8,
"b": 9,
"c": 10
},
{
"a": 9,
"b": 10,
"c": 11
}
]
}
],
"expectations": [
{
"command_started_event": {
"command": {
"find": "driverdata"
}
}
}
]
}
]
}

0 comments on commit 47db71e

Please sign in to comment.