Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
258a0cb
PYTHON-2545 Run test-suite against proxy as a mongos
prashantmital Jul 1, 2021
3791da5
Get trivial example working locally
prashantmital Jul 7, 2021
d4ae3bc
cleanup evg config
prashantmital Jul 7, 2021
5f069c6
ensure driver is able to connect to serverless instance
prashantmital Jul 8, 2021
00ccaf2
remove debugging cruft
prashantmital Jul 8, 2021
dc09d95
Skip some crud V1 tests on serverless
prashantmital Jul 9, 2021
b0c5776
reync spec tests
prashantmital Jul 9, 2021
fd6ac53
augment username/password information to URI
prashantmital Jul 9, 2021
199f751
Only run on unified format crud tests
prashantmital Jul 9, 2021
8c2c812
skip more tests
prashantmital Jul 9, 2021
8cab22c
ensure tests that require server connectivity inherit from Integratio…
prashantmital Jul 12, 2021
893f728
connect to a single mongos
prashantmital Jul 12, 2021
c95cd66
skip changestream tests
prashantmital Jul 13, 2021
5fcfaa8
skip Map Reduce tests
prashantmital Jul 13, 2021
0bfdf88
ensure runOn is honored
prashantmital Jul 13, 2021
86f9a2e
skip currentOp tests on serverless
prashantmital Jul 13, 2021
ea21540
skip out and collation on retryable reads spec tests
prashantmital Jul 14, 2021
153188e
only skip on serverless
prashantmital Jul 14, 2021
82e3b1d
update crud tests
prashantmital Jul 26, 2021
2f8e405
properly skip tests
prashantmital Jul 26, 2021
2df9fde
run ignore deprecations tests on serverless
prashantmital Jul 27, 2021
5544ae0
ensure test suite fails when not connected to serverless and TEST_SER…
prashantmital Jul 27, 2021
8232d17
edit check
prashantmital Jul 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,12 @@ functions:
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}"
fi
if [ -n "${test_serverless}" ]; then
export TEST_SERVERLESS=1
export MONGODB_URI="${MONGODB_URI}"
export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
fi

PYTHON_BINARY=${PYTHON_BINARY} \
GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \
Expand Down Expand Up @@ -836,9 +842,41 @@ post:
- func: "cleanup"
- func: "teardown_docker"

tasks:

task_groups:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I haven't since "task_groups" before. I gather it's a way to add arbitrary setup/teardown code to an existing task?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I too, haven't used them before. I picked this right out of the sample in https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/config.yml

- name: serverless_task_group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: "fetch source"
- func: "prepare resources"
- command: shell.exec
params:
shell: "bash"
script: |
${PREPARE_SHELL}
set +o xtrace
SERVERLESS_DRIVERS_GROUP=${SERVERLESS_DRIVERS_GROUP} \
SERVERLESS_API_PUBLIC_KEY=${SERVERLESS_API_PUBLIC_KEY} \
SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- command: expansions.update
params:
file: serverless-expansion.yml
teardown_group:
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
set +o xtrace
SERVERLESS_DRIVERS_GROUP=${SERVERLESS_DRIVERS_GROUP} \
SERVERLESS_API_PUBLIC_KEY=${SERVERLESS_API_PUBLIC_KEY} \
SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
SERVERLESS_INSTANCE_NAME=${SERVERLESS_INSTANCE_NAME} \
bash ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
tasks:
- ".serverless"

tasks:
# Wildcard task. Do you need to find out what tools are available and where?
# Throw it here, and execute this task on all buildvariants
- name: getdata
Expand Down Expand Up @@ -1184,6 +1222,11 @@ tasks:
TOPOLOGY: "sharded_cluster"
- func: "run tests"

- name: "test-serverless"
tags: ["serverless"]
commands:
- func: "run tests"

- name: "test-enterprise-auth"
tags: ["enterprise-auth"]
commands:
Expand Down Expand Up @@ -2040,6 +2083,15 @@ axes:
test_loadbalancer: true
batchtime: 10080 # 7 days

- id: serverless
display_name: "Serverless"
values:
- id: "enabled"
display_name: "Serverless"
variables:
test_serverless: true
batchtime: 10080 # 7 days

buildvariants:
- matrix_name: "tests-all"
matrix_spec:
Expand Down Expand Up @@ -2473,6 +2525,16 @@ buildvariants:
tasks:
- name: "atlas-connect"

- matrix_name: "serverless"
matrix_spec:
platform: awslinux
python-version: *amazon1-pythons
auth-ssl: auth-ssl
serverless: "*"
display_name: "Serverless ${python-version} ${platform}"
tasks:
- "serverless_task_group"

- matrix_name: "data-lake-spec-tests"
matrix_spec:
platform: ubuntu-16.04
Expand Down
11 changes: 7 additions & 4 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ if [ -n "$MONGODB_API_VERSION" ]; then
fi

if [ "$AUTH" != "noauth" ]; then
if [ -z "$DATA_LAKE" ]; then
export DB_USER="bob"
export DB_PASSWORD="pwd123"
else
if [ ! -z "$DATA_LAKE" ]; then
export DB_USER="mhuser"
export DB_PASSWORD="pencil"
elif [ ! -z "$TEST_SERVERLESS" ]; then
export DB_USER=$SERVERLESS_ATLAS_USER
export DB_PASSWORD=$SERVERLESS_ATLAS_PASSWORD
else
export DB_USER="bob"
export DB_PASSWORD="pwd123"
fi
fi

Expand Down
101 changes: 64 additions & 37 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
COMPRESSORS = os.environ.get("COMPRESSORS")
MONGODB_API_VERSION = os.environ.get("MONGODB_API_VERSION")
TEST_LOADBALANCER = bool(os.environ.get("TEST_LOADBALANCER"))
TEST_SERVERLESS = bool(os.environ.get("TEST_SERVERLESS"))
SINGLE_MONGOS_LB_URI = os.environ.get("SINGLE_MONGOS_LB_URI")
MULTI_MONGOS_LB_URI = os.environ.get("MULTI_MONGOS_LB_URI")
if TEST_LOADBALANCER:
Expand All @@ -104,6 +105,13 @@
host, port = res['nodelist'][0]
db_user = res['username'] or db_user
db_pwd = res['password'] or db_pwd
elif TEST_SERVERLESS:
res = parse_uri(os.environ["MONGODB_URI"])
host, port = res['nodelist'].pop(0)
additional_serverless_mongoses = res['nodelist']
db_user = res['username'] or db_user
db_pwd = res['password'] or db_pwd
TLS_OPTIONS = {'tls': True}


def is_server_resolvable():
Expand Down Expand Up @@ -231,6 +239,7 @@ def __init__(self):
self.conn_lock = threading.Lock()
self.is_data_lake = False
self.load_balancer = TEST_LOADBALANCER
self.serverless = TEST_SERVERLESS
if self.load_balancer:
self.default_client_options["loadBalanced"] = True
if COMPRESSORS:
Expand Down Expand Up @@ -309,22 +318,26 @@ def _init_client(self):
if self.client:
self.connected = True

try:
self.cmd_line = self.client.admin.command('getCmdLineOpts')
except pymongo.errors.OperationFailure as e:
msg = e.details.get('errmsg', '')
if e.code == 13 or 'unauthorized' in msg or 'login' in msg:
# Unauthorized.
self.auth_enabled = True
else:
raise
if self.serverless:
self.auth_enabled = True
else:
self.auth_enabled = self._server_started_with_auth()
try:
self.cmd_line = self.client.admin.command('getCmdLineOpts')
except pymongo.errors.OperationFailure as e:
msg = e.details.get('errmsg', '')
if e.code == 13 or 'unauthorized' in msg or 'login' in msg:
# Unauthorized.
self.auth_enabled = True
else:
raise
else:
self.auth_enabled = self._server_started_with_auth()

if self.auth_enabled:
# See if db_user already exists.
if not self._check_user_provided():
_create_user(self.client.admin, db_user, db_pwd)
if not self.serverless:
# See if db_user already exists.
if not self._check_user_provided():
_create_user(self.client.admin, db_user, db_pwd)

self.client = self._connect(
host, port, username=db_user, password=db_pwd,
Expand All @@ -334,10 +347,13 @@ def _init_client(self):
# May not have this if OperationFailure was raised earlier.
self.cmd_line = self.client.admin.command('getCmdLineOpts')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does getCmdLineOpts actually work on serverless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works but doesn't give us any useful info:

self.client.admin.command('getCmdLineOpts')
{'argv': [], 'parsed': {}, 'ok': 1}


self.server_status = self.client.admin.command('serverStatus')
if self.storage_engine == "mmapv1":
# MMAPv1 does not support retryWrites=True.
self.default_client_options['retryWrites'] = False
if self.serverless:
self.server_status = {}
else:
self.server_status = self.client.admin.command('serverStatus')
if self.storage_engine == "mmapv1":
# MMAPv1 does not support retryWrites=True.
self.default_client_options['retryWrites'] = False

ismaster = self.ismaster
self.sessions_enabled = 'logicalSessionTimeoutMinutes' in ismaster
Expand Down Expand Up @@ -374,33 +390,41 @@ def _init_client(self):
self.nodes = set([(host, port)])
self.w = len(ismaster.get("hosts", [])) or 1
self.version = Version.from_client(self.client)
self.server_parameters = self.client.admin.command(
'getParameter', '*')

if 'enableTestCommands=1' in self.cmd_line['argv']:
if TEST_SERVERLESS:
self.test_commands_enabled = True
elif 'parsed' in self.cmd_line:
params = self.cmd_line['parsed'].get('setParameter', [])
if 'enableTestCommands=1' in params:
self.has_ipv6 = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serverless doesn't support ipv6?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure... It seems we only use this in one test (TestClient.test_ipv6) - do we want to run that test class against serverless?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I don't think we need to run that test on serverless. A maybe useful test would be to manually resolve the serverless host to ipv6 and then attempt to connect. Up to you. I don't think it's needed. Should be something that's tested on the cloud team's side.

else:
self.server_parameters = self.client.admin.command(
'getParameter', '*')
if 'enableTestCommands=1' in self.cmd_line['argv']:
self.test_commands_enabled = True
else:
params = self.cmd_line['parsed'].get('setParameter', {})
if params.get('enableTestCommands') == '1':
elif 'parsed' in self.cmd_line:
params = self.cmd_line['parsed'].get('setParameter', [])
if 'enableTestCommands=1' in params:
self.test_commands_enabled = True
else:
params = self.cmd_line['parsed'].get('setParameter', {})
if params.get('enableTestCommands') == '1':
self.test_commands_enabled = True
self.has_ipv6 = self._server_started_with_ipv6()

self.is_mongos = (self.ismaster.get('msg') == 'isdbgrid')
self.has_ipv6 = self._server_started_with_ipv6()
if self.is_mongos:
# Check for another mongos on the next port.
address = self.client.address
next_address = address[0], address[1] + 1
self.mongoses.append(address)
mongos_client = self._connect(*next_address,
**self.default_client_options)
if mongos_client:
ismaster = mongos_client.admin.command('ismaster')
if ismaster.get('msg') == 'isdbgrid':
self.mongoses.append(next_address)
if self.serverless:
self.mongoses.append(self.client.address)
self.mongoses.extend(additional_serverless_mongoses)
else:
# Check for another mongos on the next port.
address = self.client.address
next_address = address[0], address[1] + 1
self.mongoses.append(address)
mongos_client = self._connect(
*next_address, **self.default_client_options)
if mongos_client:
ismaster = mongos_client.admin.command('ismaster')
if ismaster.get('msg') == 'isdbgrid':
self.mongoses.append(next_address)

def init(self):
with self.conn_lock:
Expand Down Expand Up @@ -891,6 +915,9 @@ def setUpClass(cls):
if (client_context.load_balancer and
not getattr(cls, 'RUN_ON_LOAD_BALANCER', False)):
raise SkipTest('this test does not support load balancers')
if (client_context.serverless and
not getattr(cls, 'RUN_ON_SERVERLESS', False)):
raise SkipTest('this test does not support serverless')
cls.client = client_context.client
cls.db = cls.client.pymongo_test
if client_context.auth_enabled:
Expand Down
5 changes: 3 additions & 2 deletions test/crud/unified/aggregate-let.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "aggregate-let",
"schemaVersion": "1.0",
"schemaVersion": "1.4",
"createEntities": [
{
"client": {
Expand Down Expand Up @@ -310,7 +310,8 @@
"description": "Aggregate to collection with let option",
"runOnRequirements": [
{
"minServerVersion": "5.0"
"minServerVersion": "5.0",
"serverless": "forbid"
}
],
"operations": [
Expand Down
5 changes: 3 additions & 2 deletions test/crud/unified/aggregate-out-readConcern.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"description": "aggregate-out-readConcern",
"schemaVersion": "1.1",
"schemaVersion": "1.4",
"runOnRequirements": [
{
"minServerVersion": "4.1.0",
"topologies": [
"replicaset",
"sharded"
]
],
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/read/aggregate-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "Aggregate with collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/read/aggregate-out.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
],
"minServerVersion": "2.6",
"serverless": "forbid",
"tests": [
{
"description": "Aggregate with $out",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/read/count-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "Count documents with collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/read/distinct-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "Distinct with a collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/read/find-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "Find with a collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/write/bulkWrite-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "BulkWrite with delete operations and collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/write/deleteMany-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "DeleteMany when many documents match with collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/write/deleteOne-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "DeleteOne when many documents matches with collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/write/findOneAndDelete-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "FindOneAndDelete when one document matches with collation",
Expand Down
1 change: 1 addition & 0 deletions test/crud/v1/write/findOneAndReplace-collation.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
],
"minServerVersion": "3.4",
"serverless": "forbid",
"tests": [
{
"description": "FindOneAndReplace when one document matches with collation returning the document after modification",
Expand Down
Loading