Skip to content

chore: debug test flake in windows python 3.9 #466

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

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5033fb0
chore: debug test flake in windows python 3.9
rhatgadkar-goog Jul 11, 2025
e342882
add -s pytest flag for stdout output
rhatgadkar-goog Jul 11, 2025
b1ab75d
add more logging for cases before close() is called
rhatgadkar-goog Jul 11, 2025
5b0f22e
check if new pytest-asyncio version is causing the flake
rhatgadkar-goog Jul 15, 2025
c14c175
Merge branch 'main' into debug-win-py39-test-flake
rhatgadkar-goog Jul 15, 2025
59dd94f
check if previous cryptography version does not cause flake
rhatgadkar-goog Jul 15, 2025
54acc4a
Add pytest timeout to add timeout to tests
rhatgadkar-goog Jul 15, 2025
70ccd03
fix adding of pytest timeout
rhatgadkar-goog Jul 15, 2025
110e554
increase timeout to 30 sec
rhatgadkar-goog Jul 15, 2025
7ca3d7f
set timeout to 2min
rhatgadkar-goog Jul 15, 2025
fa81e12
add timestamps to log statements
rhatgadkar-goog Jul 15, 2025
b700bf8
remove pytest-timeout
rhatgadkar-goog Jul 18, 2025
369fc6a
remove print statements in test_Connector_close_called_multiple_times
rhatgadkar-goog Jul 18, 2025
ef6c848
delete all print statements
rhatgadkar-goog Jul 18, 2025
bd62f17
comment out test_connect
rhatgadkar-goog Jul 18, 2025
42fe6dc
change proxy_server to not run in test session scope
rhatgadkar-goog Jul 18, 2025
8ecbd77
revert this change: https://github.com/GoogleCloudPlatform/alloydb-py…
rhatgadkar-goog Jul 18, 2025
deae4df
Revert "revert this change: https://github.com/GoogleCloudPlatform/al…
rhatgadkar-goog Jul 18, 2025
37213a6
remove loop in start_proxy_server and have pytest return a generator
rhatgadkar-goog Jul 19, 2025
7c55851
don't return generator in pytest
rhatgadkar-goog Jul 19, 2025
7acc0aa
Put listen() inside loop
rhatgadkar-goog Jul 19, 2025
92d040b
Put in server socket
rhatgadkar-goog Jul 19, 2025
e8ad387
yield thread
rhatgadkar-goog Jul 19, 2025
bc67f67
add logs in proxy_server function
rhatgadkar-goog Jul 22, 2025
973b567
add more debug logs in start_proxy_server
rhatgadkar-goog Jul 22, 2025
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
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def default(session, path):
"--include=*/google/cloud/alloydbconnector/*.py",
"-m",
"pytest",
"-s",
"-v",
path,
*session.posargs,
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import socket
import ssl
from threading import Thread
from typing import Generator

from aiofiles.tempfile import TemporaryDirectory
from mocks import FakeAlloyDBClient
Expand Down Expand Up @@ -64,19 +65,23 @@ async def start_proxy_server(instance: FakeInstance) -> None:
context.load_cert_chain(cert_chain_filename, key_filename)
# bind socket to AlloyDB proxy server port on localhost
sock.bind((ip_address, port))
# listen for incoming connections
sock.listen(5)

with context.wrap_socket(sock, server_side=True) as ssock:
while True:
# listen for incoming connections
print(f"RISHABH DEBUG: listening for connection")
ssock.listen(5)
print(f"RISHABH DEBUG: accepting a connection")
conn, _ = ssock.accept()
print(f"RISHABH DEBUG: doing metadata exchange")
metadata_exchange(conn)
conn.sendall(instance.name.encode("utf-8"))
conn.close()
print(f"RISHABH DEBUG: finished processing a connection")


@pytest.fixture(scope="session")
def proxy_server(fake_instance: FakeInstance) -> None:
def proxy_server(fake_instance: FakeInstance) -> Generator:
"""Run local proxy server capable of performing metadata exchange"""
thread = Thread(
target=asyncio.run,
Expand All @@ -88,4 +93,4 @@ def proxy_server(fake_instance: FakeInstance) -> None:
daemon=True,
)
thread.start()
thread.join(DELAY) # add a delay to allow the proxy server to start
yield thread
Loading