Skip to content

Commit 8949542

Browse files
committed
review comments
1 parent 6b863c7 commit 8949542

14 files changed

+88
-139
lines changed

.evergreen/config.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ functions:
424424
COMPRESSORS=${COMPRESSORS} \
425425
AUTH=${AUTH} \
426426
SSL=${SSL} \
427+
DATA_LAKE=${DATA_LAKE} \
427428
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
428429
429430
"run enterprise auth tests":
@@ -446,23 +447,6 @@ functions:
446447
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
447448
PYTHON_BINARY=${PYTHON_BINARY} ATLAS_REPL='${atlas_repl}' ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' sh ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
448449
449-
"run datalake tests":
450-
- command: shell.exec
451-
type: test
452-
params:
453-
working_dir: "src"
454-
script: |
455-
if [ -n "${set_xtrace_on}" ]; then
456-
set -o xtrace
457-
export SET_XTRACE_ON="${set_xtrace_on}"
458-
fi
459-
${PREPARE_SHELL}
460-
PYTHON_BINARY=${PYTHON_BINARY} \
461-
C_EXTENSIONS=${C_EXTENSIONS} \
462-
AUTH=${AUTH} \
463-
SSL=${SSL} \
464-
sh ${PROJECT_DIRECTORY}/.evergreen/run-datalake-tests.sh
465-
466450
"add aws auth variables to file":
467451
- command: shell.exec
468452
type: test
@@ -1196,9 +1180,9 @@ tasks:
11961180
- name: atlas-data-lake-tests
11971181
commands:
11981182
- func: "bootstrap datalake"
1199-
- func: "run datalake tests"
1183+
- func: "run tests"
12001184
vars:
1201-
TOPOLOGY: "server"
1185+
DATA_LAKE: "true"
12021186

12031187
- name: test-ocsp-rsa-valid-cert-server-staples
12041188
tags: ["ocsp", "ocsp-rsa", "ocsp-staple"]
@@ -2593,10 +2577,10 @@ buildvariants:
25932577
- matrix_name: "data-lake-spec-tests"
25942578
matrix_spec:
25952579
platform: ubuntu-16.04
2596-
python-version: ["2.7", "3.7", "3.8"]
2580+
python-version: ["2.7", "3.4", "3.8"]
25972581
auth: "auth"
2598-
ssl: "nossl"
2599-
display_name: "Atlas Data Lake ${python-version}"
2582+
c-extensions: "*"
2583+
display_name: "Atlas Data Lake ${python-version} ${c-extensions}"
26002584
tasks:
26012585
- name: atlas-data-lake-tests
26022586

.evergreen/run-datalake-tests.sh

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ else
1414
set +x
1515
fi
1616

17+
PYTHON="$PYTHON_BINARY"
1718
AUTH=${AUTH:-noauth}
18-
SSL=${SSL:-nossl}
1919
PYTHON_BINARY=${PYTHON_BINARY:-}
2020
C_EXTENSIONS=${C_EXTENSIONS:-}
2121

@@ -24,29 +24,6 @@ if [ "$AUTH" != "noauth" ]; then
2424
export DB_PASSWORD="pencil"
2525
fi
2626

27-
if [ "$SSL" != "nossl" ]; then
28-
export CLIENT_PEM="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
29-
export CA_PEM="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
30-
fi
31-
32-
if [ -z "$PYTHON_BINARY" ]; then
33-
VIRTUALENV=$(command -v virtualenv) || true
34-
if [ -z "$VIRTUALENV" ]; then
35-
PYTHON=$(command -v python || command -v python3) || true
36-
if [ -z "$PYTHON" ]; then
37-
echo "Cannot test without python or python3 installed!"
38-
exit 1
39-
fi
40-
else
41-
$VIRTUALENV pymongotestvenv
42-
. pymongotestvenv/bin/activate
43-
PYTHON=python
44-
trap "deactivate; rm -rf pymongotestvenv" EXIT HUP
45-
fi
46-
else
47-
PYTHON="$PYTHON_BINARY"
48-
fi
49-
5027
echo "Running $AUTH tests over $SSL with python $PYTHON"
5128
$PYTHON -c 'import sys; print(sys.version)'
5229

@@ -78,4 +55,4 @@ if [ -z "$C_EXTENSIONS" -a $PYTHON_IMPL = "CPython" ]; then
7855
fi
7956

8057
echo "Running tests"
81-
$PYTHON setup.py $C_EXTENSIONS test -s test.data_lake.test_data_lake $OUTPUT
58+
$PYTHON setup.py $C_EXTENSIONS test -s test.data_lake.test_data_lake $OUTPUT

.evergreen/run-tests.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ else
1919
set +x
2020
fi
2121

22-
2322
AUTH=${AUTH:-noauth}
2423
SSL=${SSL:-nossl}
2524
PYTHON_BINARY=${PYTHON_BINARY:-}
@@ -30,6 +29,7 @@ COMPRESSORS=${COMPRESSORS:-}
3029
TEST_ENCRYPTION=${TEST_ENCRYPTION:-}
3130
LIBMONGOCRYPT_URL=${LIBMONGOCRYPT_URL:-}
3231
SETDEFAULTENCODING=${SETDEFAULTENCODING:-}
32+
DATA_LAKE=${DATA_LAKE:-}
3333

3434
if [ -n "$COMPRESSORS" ]; then
3535
export COMPRESSORS=$COMPRESSORS
@@ -38,8 +38,13 @@ fi
3838
export JAVA_HOME=/opt/java/jdk8
3939

4040
if [ "$AUTH" != "noauth" ]; then
41-
export DB_USER="bob"
42-
export DB_PASSWORD="pwd123"
41+
if [ -z "$DATA_LAKE" ]; then
42+
export DB_USER="bob"
43+
export DB_PASSWORD="pwd123"
44+
else
45+
export DB_USER="mhuser"
46+
export DB_PASSWORD="pencil"
47+
fi
4348
fi
4449

4550
if [ "$SSL" != "nossl" ]; then
@@ -149,9 +154,15 @@ fi
149154

150155
PYTHON_IMPL=$($PYTHON -c "import platform, sys; sys.stdout.write(platform.python_implementation())")
151156
if [ $PYTHON_IMPL = "Jython" ]; then
152-
EXTRA_ARGS="-J-XX:-UseGCOverheadLimit -J-Xmx4096m"
157+
PYTHON_ARGS="-J-XX:-UseGCOverheadLimit -J-Xmx4096m"
158+
else
159+
PYTHON_ARGS=""
160+
fi
161+
162+
if [ -z "$DATA_LAKE" ]; then
163+
TEST_ARGS="-s test.test_data_lake"
153164
else
154-
EXTRA_ARGS=""
165+
TEST_ARGS=""
155166
fi
156167

157168
# Don't download unittest-xml-reporting from pypi, which often fails.
@@ -200,7 +211,7 @@ if [ -z "$GREEN_FRAMEWORK" ]; then
200211
# causing this script to exit.
201212
$PYTHON -c "from bson import _cbson; from pymongo import _cmessage"
202213
fi
203-
$COVERAGE_OR_PYTHON $EXTRA_ARGS $COVERAGE_ARGS setup.py $C_EXTENSIONS test $OUTPUT
214+
$COVERAGE_OR_PYTHON $PYTHON_ARGS $COVERAGE_ARGS setup.py $C_EXTENSIONS test $TEST_ARGS $OUTPUT
204215
else
205216
# --no_ext has to come before "test" so there is no way to toggle extensions here.
206217
$PYTHON green_framework_test.py $GREEN_FRAMEWORK $OUTPUT

test/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def __init__(self):
191191
self.sessions_enabled = False
192192
self.client = None
193193
self.conn_lock = threading.Lock()
194-
self.data_lake = False
194+
self.is_data_lake = False
195195

196196
if COMPRESSORS:
197197
self.default_client_options["compressors"] = COMPRESSORS
@@ -236,7 +236,7 @@ def _init_client(self):
236236
if self.client is not None:
237237
build_info = self.client.admin.command('buildInfo')
238238
if 'dataLake' in build_info:
239-
self.data_lake = True
239+
self.is_data_lake = True
240240
self.auth_enabled = True
241241
self.client = self._connect(
242242
host, port, username=db_user, password=db_pwd)
@@ -857,7 +857,7 @@ def teardown():
857857
if garbage:
858858
assert False, '\n'.join(garbage)
859859
c = client_context.client
860-
if c and not client_context.data_lake:
860+
if c and not client_context.is_data_lake:
861861
c.drop_database("pymongo-pooling-tests")
862862
c.drop_database("pymongo_test")
863863
c.drop_database("pymongo_test1")

test/data_lake/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/data_lake/test_data_lake.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

test/test_data_lake.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2020-present MongoDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Test Atlas Data Lake."""
16+
17+
import os
18+
import sys
19+
20+
sys.path[0:0] = [""]
21+
22+
from test import client_context, unittest
23+
from test.test_crud_v2 import TestSpec
24+
from test.utils import TestCreator
25+
26+
27+
# Location of JSON test specifications.
28+
_TEST_PATH = os.path.join(
29+
os.path.dirname(os.path.realpath(__file__)), "data_lake")
30+
31+
# Default test database and collection names.
32+
TEST_DB = 'test'
33+
TEST_COLLECTION = 'driverdata'
34+
35+
36+
class DataLakeTestSpec(TestSpec):
37+
def maybe_skip_scenario(self, test):
38+
# Skip these tests unless connected to data lake.
39+
if not client_context.is_data_lake:
40+
raise unittest.skipTest('Not connected to Atlas Data Lake')
41+
42+
def setup_scenario(self, scenario_def):
43+
# Spec tests MUST NOT insert data/drop collection for
44+
# data lake testing.
45+
pass
46+
47+
48+
def create_test(scenario_def, test, name):
49+
def run_scenario(self):
50+
self.run_scenario(scenario_def, test)
51+
52+
return run_scenario
53+
54+
55+
test_creator = TestCreator(
56+
create_test, DataLakeTestSpec, _TEST_PATH).create_tests()
57+
58+
59+
if __name__ == "__main__":
60+
unittest.main()

0 commit comments

Comments
 (0)