Skip to content

PYTHON-5321 Remove Serverless testing #2359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3060,16 +3060,6 @@ tasks:
- sharded_cluster-auth-ssl
- sync

# Serverless tests
- name: test-serverless
commands:
- func: run tests
vars:
TEST_NAME: serverless
AUTH: auth
SSL: ssl
tags: [serverless]

# Standard tests
- name: test-standard-v4.0-python3.9-sync-noauth-nossl-standalone
commands:
Expand Down
20 changes: 0 additions & 20 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -586,26 +586,6 @@ buildvariants:
- rhel87-small
tags: [coverage_tag]

# Serverless tests
- name: serverless-rhel8-python3.9
tasks:
- name: .serverless
display_name: Serverless RHEL8 Python3.9
run_on:
- rhel87-small
batchtime: 10080
expansions:
PYTHON_BINARY: /opt/python/3.9/bin/python3
- name: serverless-rhel8-python3.13
tasks:
- name: .serverless
display_name: Serverless RHEL8 Python3.13
run_on:
- rhel87-small
batchtime: 10080
expansions:
PYTHON_BINARY: /opt/python/3.13/bin/python3

# Stable api tests
- name: stable-api-require-v1-rhel8-auth
tasks:
Expand Down
25 changes: 0 additions & 25 deletions .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,6 @@ def create_disable_test_commands_variants():
return [create_variant(tasks, display_name, host=host, python=python, expansions=expansions)]


def create_serverless_variants():
host = DEFAULT_HOST
batchtime = BATCHTIME_WEEK
tasks = [".serverless"]
base_name = "Serverless"
return [
create_variant(
tasks,
get_variant_name(base_name, host, python=python),
host=host,
python=python,
batchtime=batchtime,
)
for python in MIN_MAX_PYTHON
]


def create_oidc_auth_variants():
variants = []
for host_name in ["ubuntu22", "macos", "win64"]:
Expand Down Expand Up @@ -968,14 +951,6 @@ def create_free_threading_tasks():
return [EvgTask(name=task_name, tags=tags, commands=[server_func, test_func])]


def create_serverless_tasks():
vars = dict(TEST_NAME="serverless", AUTH="auth", SSL="ssl")
test_func = FunctionCall(func="run tests", vars=vars)
tags = ["serverless"]
task_name = "test-serverless"
return [EvgTask(name=task_name, tags=tags, commands=[test_func])]


##############
# Functions
##############
Expand Down
8 changes: 0 additions & 8 deletions .evergreen/scripts/setup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,6 @@ def handle_test_env() -> None:
config = read_env(f"{DRIVERS_TOOLS}/.evergreen/atlas_data_lake/secrets-export.sh")
DB_USER = config["ADL_USERNAME"]
DB_PASSWORD = config["ADL_PASSWORD"]
elif test_name == "serverless":
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/serverless/setup.sh")
config = read_env(f"{DRIVERS_TOOLS}/.evergreen/serverless/secrets-export.sh")
DB_USER = config["SERVERLESS_ATLAS_USER"]
DB_PASSWORD = config["SERVERLESS_ATLAS_PASSWORD"]
write_env("MONGODB_URI", config["SERVERLESS_URI"])
write_env("SINGLE_MONGOS_LB_URI", config["SERVERLESS_URI"])
write_env("MULTI_MONGOS_LB_URI", config["SERVERLESS_URI"])
elif test_name == "auth_oidc":
DB_USER = config["OIDC_ADMIN_USER"]
DB_PASSWORD = config["OIDC_ADMIN_PWD"]
Expand Down
4 changes: 0 additions & 4 deletions .evergreen/scripts/teardown_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
elif TEST_NAME == "ocsp":
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/ocsp/teardown.sh")

# Tear down serverless if applicable.
elif TEST_NAME == "serverless":
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/serverless/teardown.sh")

# Tear down atlas cluster if applicable.
if TEST_NAME in ["aws_lambda", "search_index"]:
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh")
Expand Down
2 changes: 0 additions & 2 deletions .evergreen/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class Distro:
"mockupdb": "mockupdb",
"ocsp": "ocsp",
"perf": "perf",
"serverless": "",
}

# Tests that require a sub test suite.
Expand All @@ -60,7 +59,6 @@ class Distro:
"aws_lambda",
"data_lake",
"mockupdb",
"serverless",
"ocsp",
]

Expand Down
101 changes: 38 additions & 63 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
MONGODB_API_VERSION,
MULTI_MONGOS_LB_URI,
TEST_LOADBALANCER,
TEST_SERVERLESS,
TLS_OPTIONS,
SystemCertsPatcher,
client_knobs,
Expand Down Expand Up @@ -123,9 +122,8 @@ def __init__(self):
self.conn_lock = threading.Lock()
self.is_data_lake = False
self.load_balancer = TEST_LOADBALANCER
self.serverless = TEST_SERVERLESS
self._fips_enabled = None
if self.load_balancer or self.serverless:
if self.load_balancer:
self.default_client_options["loadBalanced"] = True
if COMPRESSORS:
self.default_client_options["compressors"] = COMPRESSORS
Expand Down Expand Up @@ -167,7 +165,7 @@ def uri(self):
@property
def hello(self):
if not self._hello:
if self.serverless or self.load_balancer:
if self.load_balancer:
self._hello = self.client.admin.command(HelloCompat.CMD)
else:
self._hello = self.client.admin.command(HelloCompat.LEGACY_CMD)
Expand Down Expand Up @@ -222,24 +220,21 @@ def _init_client(self):
if self.client:
self.connected = True

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

if self.auth_enabled:
if not self.serverless and not IS_SRV:
if not IS_SRV:
# See if db_user already exists.
if not self._check_user_provided():
_create_user(self.client.admin, db_user, db_pwd)
Expand All @@ -259,13 +254,10 @@ def _init_client(self):
# May not have this if OperationFailure was raised earlier.
self.cmd_line = self.client.admin.command("getCmdLineOpts")

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
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

hello = self.hello
self.sessions_enabled = "logicalSessionTimeoutMinutes" in hello
Expand Down Expand Up @@ -302,42 +294,33 @@ def _init_client(self):
self.w = len(hello.get("hosts", [])) or 1
self.version = Version.from_client(self.client)

if self.serverless:
self.server_parameters = {
"requireApiVersion": False,
"enableTestCommands": True,
}
self.server_parameters = self.client.admin.command("getParameter", "*")
assert self.cmd_line is not None
if self.server_parameters["enableTestCommands"]:
self.test_commands_enabled = True
self.has_ipv6 = False
else:
self.server_parameters = self.client.admin.command("getParameter", "*")
assert self.cmd_line is not None
if self.server_parameters["enableTestCommands"]:
elif "parsed" in self.cmd_line:
params = self.cmd_line["parsed"].get("setParameter", [])
if "enableTestCommands=1" in params:
self.test_commands_enabled = True
elif "parsed" in self.cmd_line:
params = self.cmd_line["parsed"].get("setParameter", [])
if "enableTestCommands=1" in params:
else:
params = self.cmd_line["parsed"].get("setParameter", {})
if params.get("enableTestCommands") == "1":
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.has_ipv6 = self._server_started_with_ipv6()

self.is_mongos = (self.hello).get("msg") == "isdbgrid"
if self.is_mongos:
address = self.client.address
self.mongoses.append(address)
if not self.serverless:
# Check for another mongos on the next port.
assert address is not None
next_address = address[0], address[1] + 1
mongos_client = self._connect(*next_address, **self.default_client_options)
if mongos_client:
hello = mongos_client.admin.command(HelloCompat.LEGACY_CMD)
if hello.get("msg") == "isdbgrid":
self.mongoses.append(next_address)
mongos_client.close()
# Check for another mongos on the next port.
assert address is not None
next_address = address[0], address[1] + 1
mongos_client = self._connect(*next_address, **self.default_client_options)
if mongos_client:
hello = mongos_client.admin.command(HelloCompat.LEGACY_CMD)
if hello.get("msg") == "isdbgrid":
self.mongoses.append(next_address)
mongos_client.close()

def init(self):
with self.conn_lock:
Expand Down Expand Up @@ -666,15 +649,9 @@ def require_no_load_balancer(self, func):
lambda: not self.load_balancer, "Must not be connected to a load balancer", func=func
)

def require_no_serverless(self, func):
"""Run a test only if the client is not connected to serverless."""
return self._require(
lambda: not self.serverless, "Must not be connected to serverless", func=func
)

def require_change_streams(self, func):
"""Run a test only if the server supports change streams."""
return self.require_no_mmap(self.require_no_standalone(self.require_no_serverless(func)))
return self.require_no_mmap(self.require_no_standalone(func))

def is_topology_type(self, topologies):
unknown = set(topologies) - {
Expand Down Expand Up @@ -1195,8 +1172,6 @@ class IntegrationTest(PyMongoTestCase):
def setUp(self) -> None:
if client_context.load_balancer and not getattr(self, "RUN_ON_LOAD_BALANCER", False):
raise SkipTest("this test does not support load balancers")
if client_context.serverless and not getattr(self, "RUN_ON_SERVERLESS", False):
raise SkipTest("this test does not support serverless")
self.client = client_context.client
self.db = self.client.pymongo_test
if client_context.auth_enabled:
Expand Down
Loading
Loading