infrahub-testcontainers 1.2.11__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/PKG-INFO +5 -4
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/container.py +239 -65
- infrahub_testcontainers-1.3.0/infrahub_testcontainers/docker-compose-cluster.test.yml +321 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/docker-compose.test.yml +2 -1
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/helpers.py +23 -3
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/plugin.py +9 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/pyproject.toml +7 -5
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/README.md +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/__init__.py +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/constants.py +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/haproxy.cfg +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/host.py +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/measurements.py +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/models.py +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/performance_test.py +0 -0
- {infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/prometheus.yml +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: infrahub-testcontainers
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Testcontainers instance for Infrahub to easily build integration tests
|
|
5
|
-
Home-page: https://opsmill.com
|
|
6
5
|
License: Apache-2.0
|
|
7
6
|
Author: OpsMill
|
|
8
7
|
Author-email: info@opsmill.com
|
|
9
|
-
Requires-Python: >=3.9
|
|
8
|
+
Requires-Python: >=3.9
|
|
10
9
|
Classifier: Intended Audience :: Developers
|
|
11
10
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
11
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -16,10 +15,12 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
17
|
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
|
18
|
+
Requires-Dist: prefect-client (==3.4.1)
|
|
19
19
|
Requires-Dist: psutil
|
|
20
20
|
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
|
|
21
21
|
Requires-Dist: pytest
|
|
22
22
|
Requires-Dist: testcontainers (>=4.8,<4.9)
|
|
23
|
+
Project-URL: Homepage, https://opsmill.com
|
|
23
24
|
Project-URL: Repository, https://github.com/opsmill/infrahub
|
|
24
25
|
Description-Content-Type: text/markdown
|
|
25
26
|
|
|
@@ -28,7 +28,6 @@ INFRAHUB_SERVICES: dict[str, ContainerService] = {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
PROJECT_ENV_VARIABLES: dict[str, str] = {
|
|
31
|
-
"NEO4J_DOCKER_IMAGE": "neo4j:5.20.0-community",
|
|
32
31
|
"MESSAGE_QUEUE_DOCKER_IMAGE": "rabbitmq:3.13.7-management",
|
|
33
32
|
"CACHE_DOCKER_IMAGE": "redis:7.2.4",
|
|
34
33
|
"INFRAHUB_TESTING_DOCKER_IMAGE": "registry.opsmill.io/opsmill/infrahub",
|
|
@@ -67,9 +66,12 @@ PROJECT_ENV_VARIABLES: dict[str, str] = {
|
|
|
67
66
|
class InfrahubDockerCompose(DockerCompose):
|
|
68
67
|
project_name: str | None = None
|
|
69
68
|
env_vars: dict[str, str] = field(default_factory=dict)
|
|
69
|
+
deployment_type: str | None = None
|
|
70
70
|
|
|
71
71
|
@classmethod
|
|
72
|
-
def init(
|
|
72
|
+
def init(
|
|
73
|
+
cls, directory: Path | None = None, version: str | None = None, deployment_type: str | None = None
|
|
74
|
+
) -> Self:
|
|
73
75
|
if not directory:
|
|
74
76
|
directory = Path.cwd()
|
|
75
77
|
|
|
@@ -80,7 +82,7 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
80
82
|
if version == "local" and infrahub_image_version:
|
|
81
83
|
version = infrahub_image_version
|
|
82
84
|
|
|
83
|
-
compose = cls(project_name=cls.generate_project_name(), context=directory)
|
|
85
|
+
compose = cls(project_name=cls.generate_project_name(), context=directory, deployment_type=deployment_type)
|
|
84
86
|
compose.create_docker_file(directory=directory)
|
|
85
87
|
compose.create_env_file(directory=directory, version=version)
|
|
86
88
|
|
|
@@ -112,7 +114,10 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
112
114
|
|
|
113
115
|
def create_docker_file(self, directory: Path) -> Path:
|
|
114
116
|
current_directory = Path(__file__).resolve().parent
|
|
115
|
-
|
|
117
|
+
compose_file_name = (
|
|
118
|
+
"docker-compose-cluster.test.yml" if self.deployment_type == "cluster" else "docker-compose.test.yml"
|
|
119
|
+
)
|
|
120
|
+
compose_file = current_directory / compose_file_name
|
|
116
121
|
|
|
117
122
|
test_compose_file = directory / "docker-compose.yml"
|
|
118
123
|
test_compose_file.write_bytes(compose_file.read_bytes())
|
|
@@ -161,7 +166,7 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
161
166
|
cmd.extend(self.services)
|
|
162
167
|
self._run_command(cmd=cmd)
|
|
163
168
|
|
|
164
|
-
def start_container(self, service_name: str) -> None:
|
|
169
|
+
def start_container(self, service_name: str | list[str]) -> None:
|
|
165
170
|
"""
|
|
166
171
|
Starts a specific service of the docker compose environment.
|
|
167
172
|
|
|
@@ -171,7 +176,11 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
171
176
|
|
|
172
177
|
# pull means running a separate command before starting
|
|
173
178
|
if self.pull:
|
|
174
|
-
pull_cmd = [*base_cmd, "pull"
|
|
179
|
+
pull_cmd = [*base_cmd, "pull"]
|
|
180
|
+
if isinstance(service_name, list):
|
|
181
|
+
pull_cmd.extend(service_name)
|
|
182
|
+
else:
|
|
183
|
+
pull_cmd.append(service_name)
|
|
175
184
|
self._run_command(cmd=pull_cmd)
|
|
176
185
|
|
|
177
186
|
up_cmd = [*base_cmd, "up"]
|
|
@@ -186,7 +195,10 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
186
195
|
# we run in detached mode instead of blocking
|
|
187
196
|
up_cmd.append("--detach")
|
|
188
197
|
|
|
189
|
-
|
|
198
|
+
if isinstance(service_name, list):
|
|
199
|
+
up_cmd.extend(service_name)
|
|
200
|
+
else:
|
|
201
|
+
up_cmd.append(service_name)
|
|
190
202
|
self._run_command(cmd=up_cmd)
|
|
191
203
|
|
|
192
204
|
# TODO would be good to the support for project_name upstream
|
|
@@ -234,7 +246,7 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
234
246
|
dest_dir / backup_name,
|
|
235
247
|
)
|
|
236
248
|
|
|
237
|
-
def database_restore_backup(self, backup_file: Path) -> None:
|
|
249
|
+
def database_restore_backup(self, backup_file: Path) -> None: # noqa: PLR0915
|
|
238
250
|
assert self.use_neo4j_enterprise
|
|
239
251
|
|
|
240
252
|
shutil.copy(
|
|
@@ -243,52 +255,35 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
243
255
|
)
|
|
244
256
|
service_name = "database"
|
|
245
257
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
self.exec_in_container(
|
|
253
|
-
command=["cypher-shell", "-u", "neo4j", "-p", "admin", "STOP DATABASE neo4j;"],
|
|
254
|
-
service_name=service_name,
|
|
255
|
-
)
|
|
258
|
+
if self.deployment_type != "cluster": # noqa: PLR1702
|
|
259
|
+
try:
|
|
260
|
+
self.get_container(service_name=service_name)
|
|
261
|
+
except ContainerIsNotRunning:
|
|
262
|
+
self.start_container(service_name=service_name)
|
|
256
263
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
"restore",
|
|
262
|
-
"--overwrite-destination",
|
|
263
|
-
"--from-path",
|
|
264
|
-
str(self.internal_backup_dir / backup_file.name),
|
|
265
|
-
],
|
|
266
|
-
service_name=service_name,
|
|
267
|
-
)
|
|
264
|
+
self.exec_in_container(
|
|
265
|
+
command=["cypher-shell", "-u", "neo4j", "-p", "admin", "STOP DATABASE neo4j;"],
|
|
266
|
+
service_name=service_name,
|
|
267
|
+
)
|
|
268
268
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
269
|
+
self.exec_in_container(
|
|
270
|
+
command=[
|
|
271
|
+
"neo4j-admin",
|
|
272
|
+
"database",
|
|
273
|
+
"restore",
|
|
274
|
+
"--overwrite-destination",
|
|
275
|
+
"--from-path",
|
|
276
|
+
str(self.internal_backup_dir / backup_file.name),
|
|
277
|
+
],
|
|
278
|
+
service_name=service_name,
|
|
279
|
+
)
|
|
273
280
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
"plain",
|
|
279
|
-
"-d",
|
|
280
|
-
"system",
|
|
281
|
-
"-u",
|
|
282
|
-
"neo4j",
|
|
283
|
-
"-p",
|
|
284
|
-
"admin",
|
|
285
|
-
"START DATABASE neo4j;",
|
|
286
|
-
],
|
|
287
|
-
service_name=service_name,
|
|
288
|
-
)
|
|
281
|
+
self.exec_in_container(
|
|
282
|
+
command=["chown", "-R", "neo4j:neo4j", "/data"],
|
|
283
|
+
service_name=service_name,
|
|
284
|
+
)
|
|
289
285
|
|
|
290
|
-
|
|
291
|
-
(stdout, _, _) = self.exec_in_container(
|
|
286
|
+
(restore_output, _, _) = self.exec_in_container(
|
|
292
287
|
command=[
|
|
293
288
|
"cypher-shell",
|
|
294
289
|
"--format",
|
|
@@ -299,26 +294,205 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
299
294
|
"neo4j",
|
|
300
295
|
"-p",
|
|
301
296
|
"admin",
|
|
302
|
-
"
|
|
297
|
+
"START DATABASE neo4j;",
|
|
303
298
|
],
|
|
304
299
|
service_name=service_name,
|
|
305
300
|
)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
301
|
+
|
|
302
|
+
for _ in range(3):
|
|
303
|
+
(stdout, _, _) = self.exec_in_container(
|
|
304
|
+
command=[
|
|
305
|
+
"cypher-shell",
|
|
306
|
+
"--format",
|
|
307
|
+
"plain",
|
|
308
|
+
"-d",
|
|
309
|
+
"system",
|
|
310
|
+
"-u",
|
|
311
|
+
"neo4j",
|
|
312
|
+
"-p",
|
|
313
|
+
"admin",
|
|
314
|
+
"SHOW DATABASES WHERE name = 'neo4j' AND currentStatus = 'online';",
|
|
315
|
+
],
|
|
316
|
+
service_name=service_name,
|
|
317
|
+
)
|
|
318
|
+
if stdout:
|
|
319
|
+
break
|
|
320
|
+
time.sleep(5)
|
|
321
|
+
else:
|
|
322
|
+
(debug_logs, _, _) = self.exec_in_container(
|
|
323
|
+
command=["cat", "logs/debug.log"],
|
|
324
|
+
service_name=service_name,
|
|
325
|
+
)
|
|
326
|
+
raise Exception(f"Failed to restore database:\n{restore_output}\nDebug logs:\n{debug_logs}")
|
|
327
|
+
|
|
328
|
+
old_services = self.services
|
|
329
|
+
self.services = ["infrahub-server", "task-worker"]
|
|
330
|
+
self.stop(down=False)
|
|
331
|
+
try:
|
|
332
|
+
self.start()
|
|
333
|
+
except Exception as exc:
|
|
334
|
+
stdout, stderr = self.get_logs()
|
|
335
|
+
raise Exception(f"Failed to start docker compose:\nStdout:\n{stdout}\nStderr:\n{stderr}") from exc
|
|
336
|
+
self.services = old_services
|
|
309
337
|
else:
|
|
310
|
-
(
|
|
311
|
-
|
|
338
|
+
print("Cluster mode detected")
|
|
339
|
+
try:
|
|
340
|
+
self.get_container(service_name=service_name)
|
|
341
|
+
self.get_container(service_name="database-core2")
|
|
342
|
+
self.get_container(service_name="database-core3")
|
|
343
|
+
except ContainerIsNotRunning:
|
|
344
|
+
self.start_container("database", "database-core2", "database-core3")
|
|
345
|
+
|
|
346
|
+
# Waiting for cluster to stabilize...
|
|
347
|
+
time.sleep(10)
|
|
348
|
+
|
|
349
|
+
self.exec_in_container(
|
|
350
|
+
command=["cypher-shell", "-u", "neo4j", "-p", "admin", "DROP DATABASE neo4j;"],
|
|
351
|
+
service_name=service_name,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
self.exec_in_container(
|
|
355
|
+
command=["rm", "-rf", "/data/databases/neo4j"],
|
|
356
|
+
service_name=service_name,
|
|
357
|
+
)
|
|
358
|
+
self.exec_in_container(
|
|
359
|
+
command=["rm", "-rf", "/data/transactions/neo4j"],
|
|
360
|
+
service_name=service_name,
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
self.exec_in_container(
|
|
364
|
+
command=[
|
|
365
|
+
"neo4j-admin",
|
|
366
|
+
"database",
|
|
367
|
+
"restore",
|
|
368
|
+
"--from-path",
|
|
369
|
+
str(self.internal_backup_dir / backup_file.name),
|
|
370
|
+
"neo4j",
|
|
371
|
+
],
|
|
312
372
|
service_name=service_name,
|
|
313
373
|
)
|
|
314
|
-
raise Exception(f"Failed to restore database:\n{restore_output}\nDebug logs:\n{debug_logs}")
|
|
315
374
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
375
|
+
cmd = self.compose_command_property[:]
|
|
376
|
+
cmd += ["restart", "database"]
|
|
377
|
+
self._run_command(cmd=cmd)
|
|
378
|
+
|
|
379
|
+
main_node = service_name
|
|
380
|
+
cluster_nodes = ["database", "database-core2", "database-core3"]
|
|
381
|
+
|
|
382
|
+
for attempt in range(3):
|
|
383
|
+
try:
|
|
384
|
+
(stdout, _, _) = self.exec_in_container(
|
|
385
|
+
command=[
|
|
386
|
+
"cypher-shell",
|
|
387
|
+
"--format",
|
|
388
|
+
"plain",
|
|
389
|
+
"-d",
|
|
390
|
+
"system",
|
|
391
|
+
"-u",
|
|
392
|
+
"neo4j",
|
|
393
|
+
"-p",
|
|
394
|
+
"admin",
|
|
395
|
+
"SHOW DATABASES YIELD name, address, currentStatus WHERE name = 'system' RETURN address, currentStatus",
|
|
396
|
+
],
|
|
397
|
+
service_name=main_node,
|
|
398
|
+
)
|
|
399
|
+
except Exception:
|
|
400
|
+
time.sleep(10)
|
|
401
|
+
continue
|
|
402
|
+
|
|
403
|
+
raw_output = stdout
|
|
404
|
+
nodes_status = dict.fromkeys(cluster_nodes, False)
|
|
405
|
+
online_count = 0
|
|
406
|
+
total_entries = 0
|
|
407
|
+
|
|
408
|
+
try:
|
|
409
|
+
for line_raw in stdout.splitlines():
|
|
410
|
+
line = line_raw.strip()
|
|
411
|
+
if not line or line.startswith("address"):
|
|
412
|
+
continue
|
|
413
|
+
|
|
414
|
+
total_entries += 1
|
|
415
|
+
if "online" in line:
|
|
416
|
+
online_count += 1
|
|
417
|
+
for node in cluster_nodes:
|
|
418
|
+
node_pattern = f'"{node}:'
|
|
419
|
+
if node_pattern in line:
|
|
420
|
+
nodes_status[node] = True
|
|
421
|
+
break
|
|
422
|
+
if all(nodes_status.values()) and online_count == len(cluster_nodes):
|
|
423
|
+
break
|
|
424
|
+
except Exception as e:
|
|
425
|
+
print(f"Error parsing database status on attempt {attempt + 1}: {e}")
|
|
426
|
+
|
|
427
|
+
print(f"Waiting for all nodes to be online. Current status: {nodes_status}")
|
|
428
|
+
time.sleep(5)
|
|
429
|
+
else:
|
|
430
|
+
debug_logs = {}
|
|
431
|
+
for node in cluster_nodes:
|
|
432
|
+
try:
|
|
433
|
+
(logs, _, _) = self.exec_in_container(
|
|
434
|
+
command=["cat", "logs/debug.log"],
|
|
435
|
+
service_name=node,
|
|
436
|
+
)
|
|
437
|
+
debug_logs[node] = logs
|
|
438
|
+
except Exception as e:
|
|
439
|
+
debug_logs[node] = f"Could not retrieve logs: {str(e)}"
|
|
440
|
+
|
|
441
|
+
debug_info = f"Raw output from SHOW DATABASES command:\n{raw_output}\n\n"
|
|
442
|
+
debug_info += f"Final node status: {nodes_status}\n\n"
|
|
443
|
+
|
|
444
|
+
status_str = ", ".join(
|
|
445
|
+
[f"{node}: {'online' if status else 'offline'}" for node, status in nodes_status.items()]
|
|
446
|
+
)
|
|
447
|
+
logs_str = debug_info + "\n\n".join(
|
|
448
|
+
[f"--- {node} logs ---\n{logs}" for node, logs in debug_logs.items()]
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
raise Exception(
|
|
452
|
+
f"Failed to restore database cluster. Node status: {status_str}\nDebug logs:\n{logs_str}"
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
server_id = None
|
|
456
|
+
try:
|
|
457
|
+
stdout, _, _ = self.exec_in_container(
|
|
458
|
+
command=[
|
|
459
|
+
"cypher-shell",
|
|
460
|
+
"--format",
|
|
461
|
+
"plain",
|
|
462
|
+
"-d",
|
|
463
|
+
"system",
|
|
464
|
+
"-u",
|
|
465
|
+
"neo4j",
|
|
466
|
+
"-p",
|
|
467
|
+
"admin",
|
|
468
|
+
'SHOW SERVERS YIELD name, address WHERE address = "database:7687" RETURN name;',
|
|
469
|
+
],
|
|
470
|
+
service_name=service_name,
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
lines = stdout.splitlines()
|
|
474
|
+
for line_raw in lines:
|
|
475
|
+
line = line_raw.strip()
|
|
476
|
+
if not line or line == "name" or line.startswith("+"):
|
|
477
|
+
continue
|
|
478
|
+
server_id = line.strip('"')
|
|
479
|
+
break
|
|
480
|
+
except Exception as e:
|
|
481
|
+
print(f"Error retrieving server ID with direct query: {e}")
|
|
482
|
+
|
|
483
|
+
if server_id:
|
|
484
|
+
self.exec_in_container(
|
|
485
|
+
command=[
|
|
486
|
+
"cypher-shell",
|
|
487
|
+
"-d",
|
|
488
|
+
"system",
|
|
489
|
+
"-u",
|
|
490
|
+
"neo4j",
|
|
491
|
+
"-p",
|
|
492
|
+
"admin",
|
|
493
|
+
f"CREATE DATABASE neo4j TOPOLOGY 3 PRIMARIES OPTIONS {{ existingData: 'use', existingDataSeedInstance: '{server_id}' }};",
|
|
494
|
+
],
|
|
495
|
+
service_name=service_name,
|
|
496
|
+
)
|
|
320
497
|
self.start()
|
|
321
|
-
|
|
322
|
-
stdout, stderr = self.get_logs()
|
|
323
|
-
raise Exception(f"Failed to start docker compose:\nStdout:\n{stdout}\nStderr:\n{stderr}") from exc
|
|
324
|
-
self.services = old_services
|
|
498
|
+
print("Database restored successfully")
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
---
|
|
2
|
+
# yamllint disable rule:line-length
|
|
3
|
+
# The following environment variables are part of the Infrahub configuration options.
|
|
4
|
+
# For detailed information on these configuration options, please refer to the Infrahub documentation:
|
|
5
|
+
# https://docs.infrahub.app/reference/configuration
|
|
6
|
+
x-neo4j-config-common: &neo4j-config-common
|
|
7
|
+
NEO4J_AUTH: neo4j/admin
|
|
8
|
+
NEO4J_dbms_security_procedures_unrestricted: apoc.*
|
|
9
|
+
NEO4J_dbms_security_auth__minimum__password__length: 4
|
|
10
|
+
NEO4J_ACCEPT_LICENSE_AGREEMENT: 'yes'
|
|
11
|
+
NEO4J_server_backup_enabled: true
|
|
12
|
+
NEO4J_metrics_prometheus_enabled: true
|
|
13
|
+
NEO4J_server_metrics_filter: '*'
|
|
14
|
+
NEO4J_server_cluster_system__database__mode: PRIMARY
|
|
15
|
+
NEO4J_initial_server_mode__constraint: PRIMARY
|
|
16
|
+
NEO4J_dbms_cluster_discovery_endpoints: database:5000,database-core2:5000,database-core3:5000
|
|
17
|
+
NEO4J_initial_dbms_default__primaries__count: 3
|
|
18
|
+
NEO4J_dbms_memory_heap_initial__size: ${INFRAHUB_TESTING_DB_HEAP_INITIAL_SIZE}
|
|
19
|
+
NEO4J_dbms_memory_heap_max__size: ${INFRAHUB_TESTING_DB_HEAP_MAX_SIZE}
|
|
20
|
+
NEO4J_server_memory_pagecache_size: ${INFRAHUB_TESTING_DB_PAGECACHE_SIZE}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
services:
|
|
24
|
+
message-queue:
|
|
25
|
+
image: ${MESSAGE_QUEUE_DOCKER_IMAGE:-rabbitmq:3.13.7-management}
|
|
26
|
+
restart: unless-stopped
|
|
27
|
+
environment:
|
|
28
|
+
RABBITMQ_DEFAULT_USER: infrahub
|
|
29
|
+
RABBITMQ_DEFAULT_PASS: infrahub
|
|
30
|
+
healthcheck:
|
|
31
|
+
test: rabbitmq-diagnostics -q check_port_connectivity
|
|
32
|
+
interval: 5s
|
|
33
|
+
timeout: 30s
|
|
34
|
+
retries: 10
|
|
35
|
+
start_period: 3s
|
|
36
|
+
ports:
|
|
37
|
+
- ${INFRAHUB_TESTING_MESSAGE_QUEUE_PORT:-0}:15692
|
|
38
|
+
|
|
39
|
+
cache:
|
|
40
|
+
image: ${CACHE_DOCKER_IMAGE:-redis:7.2.4}
|
|
41
|
+
restart: unless-stopped
|
|
42
|
+
healthcheck:
|
|
43
|
+
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
|
|
44
|
+
interval: 5s
|
|
45
|
+
timeout: 5s
|
|
46
|
+
retries: 3
|
|
47
|
+
|
|
48
|
+
infrahub-server-lb:
|
|
49
|
+
image: haproxy:3.1-alpine
|
|
50
|
+
volumes:
|
|
51
|
+
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
|
|
52
|
+
depends_on:
|
|
53
|
+
infrahub-server:
|
|
54
|
+
condition: service_started
|
|
55
|
+
healthcheck:
|
|
56
|
+
test: wget -O /dev/null http://127.0.0.1:8000/api/config || exit 1
|
|
57
|
+
interval: 5s
|
|
58
|
+
timeout: 5s
|
|
59
|
+
retries: 20
|
|
60
|
+
start_period: 10s
|
|
61
|
+
ports:
|
|
62
|
+
- ${INFRAHUB_TESTING_SERVER_PORT:-0}:8000
|
|
63
|
+
|
|
64
|
+
database:
|
|
65
|
+
deploy:
|
|
66
|
+
resources:
|
|
67
|
+
limits:
|
|
68
|
+
cpus: ${INFRAHUB_TESTING_DB_CPU_LIMIT}
|
|
69
|
+
memory: ${INFRAHUB_TESTING_DB_MEMORY_LIMIT}
|
|
70
|
+
image: "${DATABASE_DOCKER_IMAGE:-neo4j:5.20.0-enterprise}"
|
|
71
|
+
restart: unless-stopped
|
|
72
|
+
environment:
|
|
73
|
+
<<: *neo4j-config-common
|
|
74
|
+
NEO4J_metrics_prometheus_endpoint: 0.0.0.0:2004
|
|
75
|
+
NEO4J_server_backup_listen__address: 0.0.0.0:6362
|
|
76
|
+
NEO4J_server_discovery_advertised__address: database:5000
|
|
77
|
+
NEO4J_server_cluster_advertised__address: database:6000
|
|
78
|
+
NEO4J_server_cluster_raft_advertised__address: database:7000
|
|
79
|
+
NEO4J_server_bolt_advertised__address: database:7687
|
|
80
|
+
NEO4J_server_http_advertised__address: database:7474
|
|
81
|
+
NEO4J_server_https_advertised__address: database:7473
|
|
82
|
+
volumes:
|
|
83
|
+
- "database_data:/data"
|
|
84
|
+
- "database_logs:/logs"
|
|
85
|
+
- "./${INFRAHUB_TESTING_LOCAL_DB_BACKUP_DIRECTORY}:${INFRAHUB_TESTING_INTERNAL_DB_BACKUP_DIRECTORY}"
|
|
86
|
+
healthcheck:
|
|
87
|
+
test: wget http://localhost:7474 || exit 1
|
|
88
|
+
interval: 2s
|
|
89
|
+
timeout: 10s
|
|
90
|
+
retries: 20
|
|
91
|
+
start_period: 3s
|
|
92
|
+
ports:
|
|
93
|
+
- ${INFRAHUB_TESTING_DATABASE_PORT:-0}:6362
|
|
94
|
+
- ${INFRAHUB_TESTING_DATABASE_UI_PORT:-0}:7474
|
|
95
|
+
|
|
96
|
+
database-core2:
|
|
97
|
+
deploy:
|
|
98
|
+
resources:
|
|
99
|
+
limits:
|
|
100
|
+
cpus: ${INFRAHUB_TESTING_DB_CPU_LIMIT}
|
|
101
|
+
memory: ${INFRAHUB_TESTING_DB_MEMORY_LIMIT}
|
|
102
|
+
image: "${DATABASE_DOCKER_IMAGE:-neo4j:5.20.0-enterprise}"
|
|
103
|
+
environment:
|
|
104
|
+
<<: *neo4j-config-common
|
|
105
|
+
NEO4J_metrics_prometheus_endpoint: 0.0.0.0:2005
|
|
106
|
+
NEO4J_server_backup_listen__address: 0.0.0.0:6363
|
|
107
|
+
NEO4J_server_discovery_advertised__address: database-core2:5000
|
|
108
|
+
NEO4J_server_cluster_advertised__address: database-core2:6000
|
|
109
|
+
NEO4J_server_cluster_raft_advertised__address: database-core2:7000
|
|
110
|
+
NEO4J_server_bolt_advertised__address: database-core2:7687
|
|
111
|
+
NEO4J_server_http_advertised__address: database-core2:7474
|
|
112
|
+
NEO4J_server_https_advertised__address: database-core2:7473
|
|
113
|
+
volumes:
|
|
114
|
+
- "./plugins:/plugins"
|
|
115
|
+
- "database_data_core2:/data"
|
|
116
|
+
- "database_logs_core2:/logs"
|
|
117
|
+
healthcheck:
|
|
118
|
+
test: wget http://localhost:7474 || exit 1
|
|
119
|
+
interval: 5s
|
|
120
|
+
timeout: 10s
|
|
121
|
+
retries: 40
|
|
122
|
+
start_period: 30s
|
|
123
|
+
labels:
|
|
124
|
+
infrahub_role: "database"
|
|
125
|
+
com.github.run_id: "${GITHUB_RUN_ID:-unknown}"
|
|
126
|
+
com.github.job: "${JOB_NAME:-unknown}"
|
|
127
|
+
ports:
|
|
128
|
+
- "${INFRAHUB_TESTING_DATABASE_PORT:-0}:6363"
|
|
129
|
+
|
|
130
|
+
database-core3:
|
|
131
|
+
deploy:
|
|
132
|
+
resources:
|
|
133
|
+
limits:
|
|
134
|
+
cpus: ${INFRAHUB_TESTING_DB_CPU_LIMIT}
|
|
135
|
+
memory: ${INFRAHUB_TESTING_DB_MEMORY_LIMIT}
|
|
136
|
+
image: "${DATABASE_DOCKER_IMAGE:-neo4j:5.20.0-enterprise}"
|
|
137
|
+
environment:
|
|
138
|
+
<<: *neo4j-config-common
|
|
139
|
+
NEO4J_metrics_prometheus_endpoint: 0.0.0.0:2006
|
|
140
|
+
NEO4J_server_backup_listen__address: 0.0.0.0:6364
|
|
141
|
+
NEO4J_server_discovery_advertised__address: database-core3:5000
|
|
142
|
+
NEO4J_server_cluster_advertised__address: database-core3:6000
|
|
143
|
+
NEO4J_server_cluster_raft_advertised__address: database-core3:7000
|
|
144
|
+
NEO4J_server_bolt_advertised__address: database-core3:7687
|
|
145
|
+
NEO4J_server_http_advertised__address: database-core3:7474
|
|
146
|
+
NEO4J_server_https_advertised__address: database-core3:7473
|
|
147
|
+
volumes:
|
|
148
|
+
- "./plugins:/plugins"
|
|
149
|
+
- "database_data_core3:/data"
|
|
150
|
+
- "database_logs_core3:/logs"
|
|
151
|
+
healthcheck:
|
|
152
|
+
test: wget http://localhost:7474 || exit 1
|
|
153
|
+
interval: 5s
|
|
154
|
+
timeout: 10s
|
|
155
|
+
retries: 40
|
|
156
|
+
start_period: 30s
|
|
157
|
+
labels:
|
|
158
|
+
infrahub_role: "database"
|
|
159
|
+
com.github.run_id: "${GITHUB_RUN_ID:-unknown}"
|
|
160
|
+
com.github.job: "${JOB_NAME:-unknown}"
|
|
161
|
+
ports:
|
|
162
|
+
- "${INFRAHUB_TESTING_DATABASE_PORT:-0}:6364"
|
|
163
|
+
|
|
164
|
+
task-manager:
|
|
165
|
+
image: "${INFRAHUB_TESTING_DOCKER_IMAGE}:${INFRAHUB_TESTING_IMAGE_VERSION}"
|
|
166
|
+
command: uvicorn --host 0.0.0.0 --port 4200 --factory infrahub.prefect_server.app:create_infrahub_prefect
|
|
167
|
+
depends_on:
|
|
168
|
+
task-manager-db:
|
|
169
|
+
condition: service_healthy
|
|
170
|
+
environment:
|
|
171
|
+
PREFECT_UI_ENABLED: "${INFRAHUB_TESTING_PREFECT_UI_ENABLED}" # enabling UI requires permissions, run container as root to enable UI
|
|
172
|
+
PREFECT_API_DATABASE_CONNECTION_URL: postgresql+asyncpg://postgres:postgres@task-manager-db:5432/prefect
|
|
173
|
+
healthcheck:
|
|
174
|
+
test: /usr/local/bin/httpx http://localhost:4200/api/health || exit 1
|
|
175
|
+
interval: 5s
|
|
176
|
+
timeout: 5s
|
|
177
|
+
retries: 20
|
|
178
|
+
start_period: 10s
|
|
179
|
+
ports:
|
|
180
|
+
- ${INFRAHUB_TESTING_TASK_MANAGER_PORT:-0}:4200
|
|
181
|
+
|
|
182
|
+
task-manager-db:
|
|
183
|
+
image: "${POSTGRES_DOCKER_IMAGE:-postgres:16-alpine}"
|
|
184
|
+
environment:
|
|
185
|
+
- POSTGRES_USER=postgres
|
|
186
|
+
- POSTGRES_PASSWORD=postgres
|
|
187
|
+
- POSTGRES_DB=prefect
|
|
188
|
+
volumes:
|
|
189
|
+
- workflow_db:/var/lib/postgresql/data
|
|
190
|
+
healthcheck:
|
|
191
|
+
test: ["CMD-SHELL", "pg_isready"]
|
|
192
|
+
interval: 10s
|
|
193
|
+
timeout: 5s
|
|
194
|
+
retries: 5
|
|
195
|
+
|
|
196
|
+
infrahub-server:
|
|
197
|
+
deploy:
|
|
198
|
+
mode: replicated
|
|
199
|
+
replicas: ${INFRAHUB_TESTING_API_SERVER_COUNT}
|
|
200
|
+
image: "${INFRAHUB_TESTING_DOCKER_IMAGE}:${INFRAHUB_TESTING_IMAGE_VERSION}"
|
|
201
|
+
command: ${INFRAHUB_TESTING_DOCKER_ENTRYPOINT}
|
|
202
|
+
environment:
|
|
203
|
+
INFRAHUB_PRODUCTION: ${INFRAHUB_TESTING_PRODUCTION}
|
|
204
|
+
INFRAHUB_LOG_LEVEL: ${INFRAHUB_TESTING_LOG_LEVEL:-INFO}
|
|
205
|
+
INFRAHUB_BROKER_ADDRESS: ${INFRAHUB_TESTING_BROKER_ADDRESS}
|
|
206
|
+
INFRAHUB_CACHE_ADDRESS: ${INFRAHUB_TESTING_CACHE_ADDRESS}
|
|
207
|
+
INFRAHUB_DB_ADDRESS: ${INFRAHUB_TESTING_DB_ADDRESS}
|
|
208
|
+
INFRAHUB_DB_PROTOCOL: ${INFRAHUB_TESTING_DB_PROTOCOL:-neo4j}
|
|
209
|
+
INFRAHUB_WORKFLOW_ADDRESS: ${INFRAHUB_TESTING_WORKFLOW_ADDRESS}
|
|
210
|
+
INFRAHUB_WORKFLOW_DEFAULT_WORKER_TYPE: ${INFRAHUB_TESTING_WORKFLOW_DEFAULT_WORKER_TYPE}
|
|
211
|
+
INFRAHUB_INITIAL_ADMIN_TOKEN: ${INFRAHUB_TESTING_INITIAL_ADMIN_TOKEN}
|
|
212
|
+
INFRAHUB_INITIAL_AGENT_TOKEN: ${INFRAHUB_TESTING_INITIAL_AGENT_TOKEN}
|
|
213
|
+
INFRAHUB_SECURITY_SECRET_KEY: ${INFRAHUB_TESTING_SECURITY_SECRET_KEY}
|
|
214
|
+
PREFECT_API_URL: ${INFRAHUB_TESTING_PREFECT_API}
|
|
215
|
+
# Tracing
|
|
216
|
+
INFRAHUB_TRACE_ENABLE: ${INFRAHUB_TRACE_ENABLE:-false}
|
|
217
|
+
INFRAHUB_TRACE_EXPORTER_ENDPOINT:
|
|
218
|
+
INFRAHUB_TRACE_EXPORTER_PROTOCOL: ${INFRAHUB_TRACE_EXPORTER_PROTOCOL:-grpc}
|
|
219
|
+
INFRAHUB_TRACE_EXPORTER_TYPE: ${INFRAHUB_TRACE_EXPORTER_TYPE:-console}
|
|
220
|
+
INFRAHUB_TRACE_INSECURE: ${INFRAHUB_TRACE_INSECURE:-true}
|
|
221
|
+
OTEL_RESOURCE_ATTRIBUTES:
|
|
222
|
+
depends_on:
|
|
223
|
+
database:
|
|
224
|
+
condition: service_healthy
|
|
225
|
+
database-core2:
|
|
226
|
+
condition: service_healthy
|
|
227
|
+
database-core3:
|
|
228
|
+
condition: service_healthy
|
|
229
|
+
message-queue:
|
|
230
|
+
condition: service_healthy
|
|
231
|
+
cache:
|
|
232
|
+
condition: service_healthy
|
|
233
|
+
task-manager:
|
|
234
|
+
condition: service_healthy
|
|
235
|
+
volumes:
|
|
236
|
+
- "storage_data:/opt/infrahub/storage"
|
|
237
|
+
tty: true
|
|
238
|
+
healthcheck:
|
|
239
|
+
test: curl -s -f -o /dev/null http://localhost:8000/api/config || exit 1
|
|
240
|
+
interval: 5s
|
|
241
|
+
timeout: 5s
|
|
242
|
+
retries: 20
|
|
243
|
+
start_period: 10s
|
|
244
|
+
|
|
245
|
+
task-worker:
|
|
246
|
+
deploy:
|
|
247
|
+
mode: replicated
|
|
248
|
+
replicas: ${INFRAHUB_TESTING_TASK_WORKER_COUNT}
|
|
249
|
+
image: "${INFRAHUB_TESTING_DOCKER_IMAGE}:${INFRAHUB_TESTING_IMAGE_VERSION}"
|
|
250
|
+
command: prefect worker start --type ${INFRAHUB_TESTING_WORKFLOW_DEFAULT_WORKER_TYPE} --pool infrahub-worker --with-healthcheck
|
|
251
|
+
environment:
|
|
252
|
+
INFRAHUB_PRODUCTION: ${INFRAHUB_TESTING_PRODUCTION}
|
|
253
|
+
INFRAHUB_LOG_LEVEL: ${INFRAHUB_TESTING_LOG_LEVEL}
|
|
254
|
+
INFRAHUB_GIT_REPOSITORIES_DIRECTORY: ${INFRAHUB_TESTING_GIT_REPOSITORIES_DIRECTORY}
|
|
255
|
+
INFRAHUB_API_TOKEN: ${INFRAHUB_TESTING_INITIAL_AGENT_TOKEN}
|
|
256
|
+
INFRAHUB_SECURITY_SECRET_KEY: ${INFRAHUB_TESTING_SECURITY_SECRET_KEY}
|
|
257
|
+
INFRAHUB_ADDRESS: ${INFRAHUB_TESTING_ADDRESS}
|
|
258
|
+
INFRAHUB_INTERNAL_ADDRESS: ${INFRAHUB_TESTING_INTERNAL_ADDRESS}
|
|
259
|
+
INFRAHUB_BROKER_ADDRESS: ${INFRAHUB_TESTING_BROKER_ADDRESS}
|
|
260
|
+
INFRAHUB_CACHE_ADDRESS: ${INFRAHUB_TESTING_CACHE_ADDRESS}
|
|
261
|
+
INFRAHUB_DB_ADDRESS: ${INFRAHUB_TESTING_DB_ADDRESS:-database}
|
|
262
|
+
INFRAHUB_DB_PROTOCOL: ${INFRAHUB_TESTING_DB_PROTOCOL:-neo4j}
|
|
263
|
+
INFRAHUB_WORKFLOW_ADDRESS: ${INFRAHUB_TESTING_WORKFLOW_ADDRESS}
|
|
264
|
+
INFRAHUB_TIMEOUT: ${INFRAHUB_TESTING_TIMEOUT}
|
|
265
|
+
PREFECT_API_URL: ${INFRAHUB_TESTING_PREFECT_API}
|
|
266
|
+
# Tracing
|
|
267
|
+
INFRAHUB_TRACE_ENABLE: ${INFRAHUB_TRACE_ENABLE:-false}
|
|
268
|
+
INFRAHUB_TRACE_EXPORTER_ENDPOINT:
|
|
269
|
+
INFRAHUB_TRACE_EXPORTER_PROTOCOL: ${INFRAHUB_TRACE_EXPORTER_PROTOCOL:-grpc}
|
|
270
|
+
INFRAHUB_TRACE_EXPORTER_TYPE: ${INFRAHUB_TRACE_EXPORTER_TYPE:-console}
|
|
271
|
+
INFRAHUB_TRACE_INSECURE: ${INFRAHUB_TRACE_INSECURE:-true}
|
|
272
|
+
OTEL_RESOURCE_ATTRIBUTES:
|
|
273
|
+
depends_on:
|
|
274
|
+
- infrahub-server
|
|
275
|
+
volumes:
|
|
276
|
+
- "./${INFRAHUB_TESTING_LOCAL_REMOTE_GIT_DIRECTORY}:${INFRAHUB_TESTING_INTERNAL_REMOTE_GIT_DIRECTORY}"
|
|
277
|
+
tty: true
|
|
278
|
+
|
|
279
|
+
cadvisor:
|
|
280
|
+
image: "${CADVISOR_DOCKER_IMAGE:-gcr.io/cadvisor/cadvisor:v0.51.0}"
|
|
281
|
+
command:
|
|
282
|
+
- -disable_root_cgroup_stats=true
|
|
283
|
+
- -docker_only=true
|
|
284
|
+
- -store_container_labels=false
|
|
285
|
+
- -whitelisted_container_labels=com.docker.compose.project
|
|
286
|
+
privileged: true
|
|
287
|
+
volumes:
|
|
288
|
+
- /:/rootfs:ro
|
|
289
|
+
- /var/run:/var/run:ro
|
|
290
|
+
- /sys:/sys:ro
|
|
291
|
+
- /var/lib/docker:/var/lib/docker:ro
|
|
292
|
+
- /dev/disk/:/dev/disk:ro
|
|
293
|
+
ports:
|
|
294
|
+
- "${INFRAHUB_TESTING_CADVISOR_PORT:-0}:8080"
|
|
295
|
+
|
|
296
|
+
scraper:
|
|
297
|
+
image: "${SCRAPER_DOCKER_IMAGE:-victoriametrics/victoria-metrics:v1.110.0}"
|
|
298
|
+
volumes:
|
|
299
|
+
- vmdata:/victoria-metrics-data
|
|
300
|
+
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
301
|
+
command:
|
|
302
|
+
- "--promscrape.config=/etc/prometheus/prometheus.yml"
|
|
303
|
+
ports:
|
|
304
|
+
- ${INFRAHUB_TESTING_SCRAPER_PORT:-0}:8428
|
|
305
|
+
healthcheck:
|
|
306
|
+
test: wget -qO- http://127.0.0.1:8428/-/healthy
|
|
307
|
+
start_period: 10s
|
|
308
|
+
interval: 5s
|
|
309
|
+
timeout: 5s
|
|
310
|
+
retries: 10
|
|
311
|
+
|
|
312
|
+
volumes:
|
|
313
|
+
database_data:
|
|
314
|
+
database_logs:
|
|
315
|
+
database_data_core2:
|
|
316
|
+
database_logs_core2:
|
|
317
|
+
database_data_core3:
|
|
318
|
+
database_logs_core3:
|
|
319
|
+
storage_data:
|
|
320
|
+
workflow_db:
|
|
321
|
+
vmdata:
|
|
@@ -50,7 +50,7 @@ services:
|
|
|
50
50
|
limits:
|
|
51
51
|
cpus: ${INFRAHUB_TESTING_DB_CPU_LIMIT:-0.0}
|
|
52
52
|
memory: ${INFRAHUB_TESTING_DB_MEMORY_LIMIT:-0}
|
|
53
|
-
image: ${NEO4J_DOCKER_IMAGE:-neo4j:
|
|
53
|
+
image: ${NEO4J_DOCKER_IMAGE:-neo4j:2025.03.0-community}
|
|
54
54
|
restart: unless-stopped
|
|
55
55
|
environment:
|
|
56
56
|
NEO4J_AUTH: neo4j/admin
|
|
@@ -59,6 +59,7 @@ services:
|
|
|
59
59
|
NEO4J_ACCEPT_LICENSE_AGREEMENT: "yes"
|
|
60
60
|
NEO4J_server_memory_heap_initial__size: ${INFRAHUB_TESTING_DB_HEAP_INITIAL_SIZE}
|
|
61
61
|
NEO4J_server_memory_heap_max__size: ${INFRAHUB_TESTING_DB_HEAP_MAX_SIZE}
|
|
62
|
+
NEO4J_server_memory_pagecache_size: ${INFRAHUB_TESTING_DB_PAGECACHE_SIZE}
|
|
62
63
|
volumes:
|
|
63
64
|
- "database_data:/data"
|
|
64
65
|
- "database_logs:/logs"
|
{infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/helpers.py
RENAMED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import subprocess # noqa: S404
|
|
3
|
+
import uuid
|
|
4
|
+
import warnings
|
|
3
5
|
from pathlib import Path
|
|
4
6
|
|
|
5
7
|
import pytest
|
|
8
|
+
from prefect.client.orchestration import PrefectClient
|
|
6
9
|
|
|
7
10
|
from infrahub_testcontainers import __version__ as infrahub_version
|
|
8
11
|
|
|
@@ -38,8 +41,8 @@ class TestInfrahubDocker:
|
|
|
38
41
|
|
|
39
42
|
@pytest.fixture(scope="class")
|
|
40
43
|
def tmp_directory(self, tmpdir_factory: pytest.TempdirFactory) -> Path:
|
|
41
|
-
|
|
42
|
-
return
|
|
44
|
+
name = f"{self.__class__.__name__.lower()}_{uuid.uuid4().hex}"
|
|
45
|
+
return Path(str(tmpdir_factory.mktemp(name)))
|
|
43
46
|
|
|
44
47
|
@pytest.fixture(scope="class")
|
|
45
48
|
def remote_repos_dir(self, tmp_directory: Path) -> Path:
|
|
@@ -59,6 +62,10 @@ class TestInfrahubDocker:
|
|
|
59
62
|
def default_branch(self) -> str:
|
|
60
63
|
return "main"
|
|
61
64
|
|
|
65
|
+
@pytest.fixture(scope="class")
|
|
66
|
+
def deployment_type(self, request: pytest.FixtureRequest) -> str | None:
|
|
67
|
+
return request.config.getoption(name="infrahub_deployment_type", default=None)
|
|
68
|
+
|
|
62
69
|
@pytest.fixture(scope="class")
|
|
63
70
|
def infrahub_compose(
|
|
64
71
|
self,
|
|
@@ -66,12 +73,21 @@ class TestInfrahubDocker:
|
|
|
66
73
|
remote_repos_dir: Path, # initialize repository before running docker compose to fix permissions issues # noqa: ARG002
|
|
67
74
|
remote_backups_dir: Path, # noqa: ARG002
|
|
68
75
|
infrahub_version: str,
|
|
76
|
+
deployment_type: str | None,
|
|
69
77
|
) -> InfrahubDockerCompose:
|
|
70
|
-
return InfrahubDockerCompose.init(
|
|
78
|
+
return InfrahubDockerCompose.init(
|
|
79
|
+
directory=tmp_directory, version=infrahub_version, deployment_type=deployment_type
|
|
80
|
+
)
|
|
71
81
|
|
|
72
82
|
@pytest.fixture(scope="class")
|
|
73
83
|
def infrahub_app(self, request: pytest.FixtureRequest, infrahub_compose: InfrahubDockerCompose) -> dict[str, int]:
|
|
84
|
+
tests_failed_before_class = request.session.testsfailed
|
|
85
|
+
|
|
74
86
|
def cleanup() -> None:
|
|
87
|
+
tests_failed_during_class = request.session.testsfailed - tests_failed_before_class
|
|
88
|
+
if tests_failed_during_class > 0:
|
|
89
|
+
stdout, stderr = infrahub_compose.get_logs("infrahub-server", "task-worker")
|
|
90
|
+
warnings.warn(f"Container logs:\nStdout:\n{stdout}\nStderr:\n{stderr}", stacklevel=2)
|
|
75
91
|
infrahub_compose.stop()
|
|
76
92
|
|
|
77
93
|
request.addfinalizer(cleanup)
|
|
@@ -91,3 +107,7 @@ class TestInfrahubDocker:
|
|
|
91
107
|
@pytest.fixture(scope="class")
|
|
92
108
|
def task_manager_port(self, infrahub_app: dict[str, int]) -> int:
|
|
93
109
|
return infrahub_app["task-manager"]
|
|
110
|
+
|
|
111
|
+
@pytest.fixture(scope="class")
|
|
112
|
+
def prefect_client(self, task_manager_port: int) -> PrefectClient:
|
|
113
|
+
return PrefectClient(api=f"http://localhost:{task_manager_port}/api/")
|
{infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/plugin.py
RENAMED
|
@@ -13,6 +13,15 @@ if TYPE_CHECKING:
|
|
|
13
13
|
def pytest_addoption(parser: pytest.Parser) -> None:
|
|
14
14
|
group = parser.getgroup("infrahub-performance-test")
|
|
15
15
|
|
|
16
|
+
group.addoption(
|
|
17
|
+
"--deployment-type",
|
|
18
|
+
action="store",
|
|
19
|
+
dest="infrahub_deployment_type",
|
|
20
|
+
default=None,
|
|
21
|
+
metavar="INFRAHUB_DEPLOYMENT_TYPE",
|
|
22
|
+
help="Type of deployment to use (default: None, options: cluster)",
|
|
23
|
+
)
|
|
24
|
+
|
|
16
25
|
group.addoption(
|
|
17
26
|
"--performance-result-address",
|
|
18
27
|
action="store",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "infrahub-testcontainers"
|
|
3
|
-
version =
|
|
3
|
+
version = "1.3.0"
|
|
4
4
|
requires-python = ">=3.9"
|
|
5
5
|
|
|
6
6
|
[tool.poetry]
|
|
7
7
|
name = "infrahub-testcontainers"
|
|
8
|
-
version =
|
|
8
|
+
version = "1.3.0"
|
|
9
9
|
description = "Testcontainers instance for Infrahub to easily build integration tests"
|
|
10
10
|
authors = ["OpsMill <info@opsmill.com>"]
|
|
11
11
|
readme = "README.md"
|
|
@@ -23,21 +23,23 @@ classifiers = [
|
|
|
23
23
|
"Programming Language :: Python :: 3.13",
|
|
24
24
|
]
|
|
25
25
|
|
|
26
|
-
include = ["infrahub_testcontainers/docker-compose.test.yml", "infrahub_testcontainers/haproxy.cfg", "infrahub_testcontainers/prometheus.yml"]
|
|
26
|
+
include = ["infrahub_testcontainers/docker-compose.test.yml", "infrahub_testcontainers/docker-compose-cluster.test.yml", "infrahub_testcontainers/haproxy.cfg", "infrahub_testcontainers/prometheus.yml"]
|
|
27
|
+
|
|
27
28
|
|
|
28
29
|
[tool.setuptools.package-data]
|
|
29
|
-
infrahub_testcontainers = ["docker-compose.test.yml", "haproxy.cfg", "prometheus.yml"]
|
|
30
|
+
infrahub_testcontainers = ["docker-compose.test.yml", "docker-compose-cluster.test.yml", "haproxy.cfg", "prometheus.yml"]
|
|
30
31
|
|
|
31
32
|
[tool.poetry.plugins."pytest11"]
|
|
32
33
|
"pytest-infrahub-performance-test" = "infrahub_testcontainers.plugin"
|
|
33
34
|
|
|
34
35
|
[tool.poetry.dependencies]
|
|
35
|
-
python = "^3.9"
|
|
36
|
+
python = "^3.9, < 3.14"
|
|
36
37
|
testcontainers = "~4.8"
|
|
37
38
|
psutil = "*"
|
|
38
39
|
pytest = "*"
|
|
39
40
|
httpx = "^0.28.1"
|
|
40
41
|
pydantic = "^2.10.6"
|
|
42
|
+
prefect-client = "3.4.1"
|
|
41
43
|
|
|
42
44
|
[tool.poetry.group.dev.dependencies]
|
|
43
45
|
rich = "^13.9.4"
|
|
File without changes
|
{infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/haproxy.cfg
RENAMED
|
File without changes
|
{infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/host.py
RENAMED
|
File without changes
|
|
File without changes
|
{infrahub_testcontainers-1.2.11 → infrahub_testcontainers-1.3.0}/infrahub_testcontainers/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|