Skip to content

Commit e96d0f3

Browse files
committed
Show logs also if container cannot start
1 parent 481d359 commit e96d0f3

File tree

2 files changed

+49
-43
lines changed

2 files changed

+49
-43
lines changed

graphdatascience/tests/integrationV2/procedure_surface/conftest.py

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,25 @@ def start_session(
8181
if not inside_ci():
8282
session_container = session_container.with_network(network).with_network_aliases("gds-session")
8383
with session_container as session_container:
84-
wait_for_logs(session_container, "Running GDS tasks: 0", timeout=20)
85-
yield GdsSessionConnectionInfo(
86-
host=session_container.get_container_host_ip(),
87-
arrow_port=session_container.get_exposed_port(8491),
88-
bolt_port=-1, # not used in tests
89-
)
90-
stdout, stderr = session_container.get_logs()
84+
try:
85+
wait_for_logs(session_container, "Running GDS tasks: 0", timeout=20)
86+
yield GdsSessionConnectionInfo(
87+
host=session_container.get_container_host_ip(),
88+
arrow_port=session_container.get_exposed_port(8491),
89+
bolt_port=-1, # not used in tests
90+
)
91+
finally:
92+
stdout, stderr = session_container.get_logs()
9193

92-
if stderr:
93-
print(f"Error logs from session container:\n{stderr}")
94+
if stderr:
95+
print(f"Error logs from session container:\n{stderr}")
9496

95-
if inside_ci():
96-
print(f"Session container logs:\n{stdout}")
97+
if inside_ci():
98+
print(f"Session container logs:\n{stdout}")
9799

98-
out_file = logs_dir / "session_container.log"
99-
with open(out_file, "w") as f:
100-
f.write(stdout.decode("utf-8"))
100+
out_file = logs_dir / "session_container.log"
101+
with open(out_file, "w") as f:
102+
f.write(stdout.decode("utf-8"))
101103

102104

103105
def create_arrow_client(session_uri: GdsSessionConnectionInfo) -> AuthenticatedArrowClient:
@@ -133,23 +135,25 @@ def start_database(logs_dir: Path, network: Network) -> Generator[DbmsConnection
133135
.with_volume_mapping(db_logs_dir, "/logs", mode="rw")
134136
)
135137
with db_container as db_container:
136-
wait_for_logs(db_container, "Started.")
137-
yield DbmsConnectionInfo(
138-
uri=f"{db_container.get_container_host_ip()}:{db_container.get_exposed_port(7687)}",
139-
username="neo4j",
140-
password="password",
141-
)
142-
stdout, stderr = db_container.get_logs()
143-
144-
if stderr:
145-
print(f"Error logs from database container:\n{stderr}")
146-
147-
if inside_ci():
148-
print(f"Database container logs:\n{stdout}")
149-
150-
out_file = db_logs_dir / "stdout.log"
151-
with open(out_file, "w") as f:
152-
f.write(stdout.decode("utf-8"))
138+
try:
139+
wait_for_logs(db_container, "Started.")
140+
yield DbmsConnectionInfo(
141+
uri=f"{db_container.get_container_host_ip()}:{db_container.get_exposed_port(7687)}",
142+
username="neo4j",
143+
password="password",
144+
)
145+
finally:
146+
stdout, stderr = db_container.get_logs()
147+
148+
if stderr:
149+
print(f"Error logs from database container:\n{stderr}")
150+
151+
if inside_ci():
152+
print(f"Database container logs:\n{stdout}")
153+
154+
out_file = db_logs_dir / "stdout.log"
155+
with open(out_file, "w") as f:
156+
f.write(stdout.decode("utf-8"))
153157

154158

155159
def create_db_query_runner(neo4j_connection: DbmsConnectionInfo) -> Generator[Neo4jQueryRunner, None, None]:

graphdatascience/tests/integrationV2/procedure_surface/cypher/conftest.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,20 @@ def gds_plugin_container(
5757
neo4j_container.with_env("NEO4J_gds_enterprise_license__file", "/licenses/license_key")
5858

5959
with neo4j_container as neo4j_db:
60-
wait_for_logs(neo4j_db, "Started.")
61-
yield neo4j_db
62-
stdout, stderr = neo4j_db.get_logs()
63-
if stderr:
64-
print(f"Error logs from Neo4j container:\n{stderr}")
65-
66-
if inside_ci():
67-
print(f"Neo4j container logs:\n{stdout}")
68-
69-
out_file = db_logs_dir / "stdout.log"
70-
with open(out_file, "w") as f:
71-
f.write(stdout.decode("utf-8"))
60+
try:
61+
wait_for_logs(neo4j_db, "Started.")
62+
yield neo4j_db
63+
finally:
64+
stdout, stderr = neo4j_db.get_logs()
65+
if stderr:
66+
print(f"Error logs from Neo4j container:\n{stderr}")
67+
68+
if inside_ci():
69+
print(f"Neo4j container logs:\n{stdout}")
70+
71+
out_file = db_logs_dir / "stdout.log"
72+
with open(out_file, "w") as f:
73+
f.write(stdout.decode("utf-8"))
7274

7375

7476
@pytest.fixture(scope="package")

0 commit comments

Comments
 (0)