test: stabilize log probe in test_pool_acquisition_timeout
There's two lines of log output, and their order is not deterministic.
This commit is contained in:
@@ -42,6 +42,18 @@ class PostgrestProcess:
|
|||||||
process: object
|
process: object
|
||||||
session: object
|
session: object
|
||||||
|
|
||||||
|
def read_stdout(self, nlines=1):
|
||||||
|
"Wait for line(s) on standard output."
|
||||||
|
output = []
|
||||||
|
for _ in range(10):
|
||||||
|
l = self.process.stdout.readline()
|
||||||
|
if l:
|
||||||
|
output.append(l.decode())
|
||||||
|
if len(output) >= nlines:
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def run(
|
def run(
|
||||||
|
|||||||
+5
-16
@@ -416,14 +416,8 @@ def test_invalid_role_claim_key_notify_reload(defaultenv):
|
|||||||
with run(env=env) as postgrest:
|
with run(env=env) as postgrest:
|
||||||
postgrest.session.post("/rpc/invalid_role_claim_key_reload")
|
postgrest.session.post("/rpc/invalid_role_claim_key_reload")
|
||||||
|
|
||||||
output = None
|
output = postgrest.read_stdout()
|
||||||
for _ in range(10):
|
assert "failed to parse role-claim-key value" in output[0]
|
||||||
output = postgrest.process.stdout.readline()
|
|
||||||
if output:
|
|
||||||
break
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
assert "failed to parse role-claim-key value" in output.decode()
|
|
||||||
|
|
||||||
response = postgrest.session.post("/rpc/reset_invalid_role_claim_key")
|
response = postgrest.session.post("/rpc/reset_invalid_role_claim_key")
|
||||||
assert response.status_code == 204
|
assert response.status_code == 204
|
||||||
@@ -572,14 +566,9 @@ def test_pool_acquisition_timeout(defaultenv, metapostgrest):
|
|||||||
assert data["message"] == "Timed out acquiring connection from connection pool."
|
assert data["message"] == "Timed out acquiring connection from connection pool."
|
||||||
|
|
||||||
# ensure the message appears on the logs as well
|
# ensure the message appears on the logs as well
|
||||||
output = None
|
output = sorted(postgrest.read_stdout(nlines=2))
|
||||||
for _ in range(10):
|
assert " 504 " in output[0]
|
||||||
output = postgrest.process.stdout.readline()
|
assert "Timed out acquiring connection from connection pool." in output[1]
|
||||||
if output:
|
|
||||||
break
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
assert "Timed out acquiring connection from connection pool." in output.decode()
|
|
||||||
|
|
||||||
|
|
||||||
def test_change_statement_timeout_held_connection(defaultenv, metapostgrest):
|
def test_change_statement_timeout_held_connection(defaultenv, metapostgrest):
|
||||||
|
|||||||
Reference in New Issue
Block a user