Skip to content

PYTHON-3088 [v3.13] Update load balancer tests to support dedicated load balancer port #870

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

Merged
merged 14 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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
7 changes: 6 additions & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ functions:
DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS} \
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
LOAD_BALANCER=${LOAD_BALANCER} \
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
- command: expansions.update
Expand Down Expand Up @@ -423,6 +424,7 @@ functions:
fi
if [ -n "${test_loadbalancer}" ]; then
export TEST_LOADBALANCER=1
export LOAD_BALANCER=1
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}"
fi
Expand Down Expand Up @@ -1798,7 +1800,10 @@ tasks:
- func: "bootstrap mongo-orchestration"
vars:
TOPOLOGY: "sharded_cluster"
LOAD_BALANCER: true
- func: "run load-balancer"
vars:
LOAD_BALANCER: true
Copy link
Member

Choose a reason for hiding this comment

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

I don't think vars/LOAD_BALANCER is needed for "run load-balancer".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@ShaneHarvey ShaneHarvey Feb 16, 2022

Choose a reason for hiding this comment

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

LOAD_BALANCER is not needed for "run tests" either is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ticket states

Drivers must set the LOAD_BALANCER environment variable to "true" in their load balancer test runs and pass the environment variable when invoking run-orchestration.sh.

Which I interpreted as requiring us to set it to true for the test run as well.

Copy link
Member

Choose a reason for hiding this comment

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

LOAD_BALANCER is only needed for run-orchestration.sh. Let's remove it here. Note we can also remove the export LOAD_BALANCER=1 line above.

- func: "run tests"
# }}}
- name: "coverage-report"
Expand Down Expand Up @@ -2986,7 +2991,7 @@ buildvariants:
- matrix_name: "load-balancer"
matrix_spec:
platform: awslinux
mongodb-version: ["5.0", "latest"]
mongodb-version: ["rapid", "latest"]
auth-ssl: "*"
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy", "pypy3.5", "pypy3.7"]
loadbalancer: "*"
Expand Down
12 changes: 0 additions & 12 deletions pymongo/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ def _set_keepalive_times(sock):
# main thread, to avoid the deadlock. See PYTHON-607.
u"foo".encode("idna")

# Remove after PYTHON-2712
_MOCK_SERVICE_ID = False


def _raise_connection_failure(address, error, msg_prefix=None):
"""Convert a socket.error to ConnectionFailure and raise it."""
Expand Down Expand Up @@ -619,12 +616,6 @@ def _hello(self, cluster_time, topology_version, heartbeat_frequency, all_creden
cmd["speculativeAuthenticate"] = auth_ctx.speculate_command()

doc = self.command("admin", cmd, publish_events=False, exhaust_allowed=awaitable)
# PYTHON-2712 will remove this topologyVersion fallback logic.
if self.opts.load_balanced and _MOCK_SERVICE_ID:
process_id = doc.get("topologyVersion", {}).get("processId")
doc.setdefault("serviceId", process_id)
if not self.opts.load_balanced:
doc.pop("serviceId", None)
hello = IsMaster(doc, awaitable=awaitable)
self.is_writable = hello.is_writable
self.max_wire_version = hello.max_wire_version
Expand Down Expand Up @@ -661,9 +652,6 @@ def _next_reply(self):
unpacked_docs = reply.unpack_response()
response_doc = unpacked_docs[0]
helpers._check_command_response(response_doc, self.max_wire_version)
# Remove after PYTHON-2712.
if not self.opts.load_balanced:
response_doc.pop("serviceId", None)
return response_doc

def command(
Expand Down
6 changes: 1 addition & 5 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@
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:
# Remove after PYTHON-2712
from pymongo import pool

pool._MOCK_SERVICE_ID = True
res = parse_uri(SINGLE_MONGOS_LB_URI)
res = parse_uri(SINGLE_MONGOS_LB_URI or "")
host, port = res["nodelist"][0]
db_user = res["username"] or db_user
db_pwd = res["password"] or db_pwd
Expand Down