infrahub-testcontainers 1.5.0b0__tar.gz → 1.5.0b2__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.5.0b0 → infrahub_testcontainers-1.5.0b2}/PKG-INFO +2 -2
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/container.py +115 -3
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/docker-compose-cluster.test.yml +6 -1
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/docker-compose.test.yml +6 -1
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/pyproject.toml +3 -3
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/README.md +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/__init__.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/constants.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/haproxy.cfg +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/helpers.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/host.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/measurements.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/models.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/performance_test.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/plugin.py +0 -0
- {infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/prometheus.yml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: infrahub-testcontainers
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.0b2
|
|
4
4
|
Summary: Testcontainers instance for Infrahub to easily build integration tests
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: OpsMill
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
|
18
|
-
Requires-Dist: prefect-client (==3.4.
|
|
18
|
+
Requires-Dist: prefect-client (==3.4.23)
|
|
19
19
|
Requires-Dist: psutil
|
|
20
20
|
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
|
|
21
21
|
Requires-Dist: pytest
|
|
@@ -29,7 +29,7 @@ INFRAHUB_SERVICES: dict[str, ContainerService] = {
|
|
|
29
29
|
|
|
30
30
|
PROJECT_ENV_VARIABLES: dict[str, str] = {
|
|
31
31
|
"MESSAGE_QUEUE_DOCKER_IMAGE": "rabbitmq:3.13.7-management",
|
|
32
|
-
"CACHE_DOCKER_IMAGE": "redis:7.2.
|
|
32
|
+
"CACHE_DOCKER_IMAGE": "redis:7.2.11",
|
|
33
33
|
"INFRAHUB_TESTING_DOCKER_IMAGE": "registry.opsmill.io/opsmill/infrahub",
|
|
34
34
|
"INFRAHUB_TESTING_DOCKER_ENTRYPOINT": f"gunicorn --config backend/infrahub/serve/gunicorn_config.py -w {os.environ.get('INFRAHUB_TESTING_WEB_CONCURRENCY', 4)} --logger-class infrahub.serve.log.GunicornLogger infrahub.server:app", # noqa: E501
|
|
35
35
|
"INFRAHUB_TESTING_IMAGE_VERSION": infrahub_version,
|
|
@@ -152,6 +152,8 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
152
152
|
"INFRAHUB_TESTING_TASKMGR_BACKGROUND_SVC_REPLICAS": "1",
|
|
153
153
|
"PREFECT_MESSAGING_BROKER": "prefect_redis.messaging",
|
|
154
154
|
"PREFECT_MESSAGING_CACHE": "prefect_redis.messaging",
|
|
155
|
+
"PREFECT_SERVER_EVENTS_CAUSAL_ORDERING": "prefect_redis.ordering",
|
|
156
|
+
"PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE": "prefect_redis.lease_storage",
|
|
155
157
|
"PREFECT__SERVER_WEBSERVER_ONLY": "true",
|
|
156
158
|
"PREFECT_API_DATABASE_MIGRATE_ON_START": "false",
|
|
157
159
|
"PREFECT_API_BLOCKS_REGISTER_ON_START": "false",
|
|
@@ -237,7 +239,9 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
237
239
|
for service_name, service_data in INFRAHUB_SERVICES.items()
|
|
238
240
|
}
|
|
239
241
|
|
|
240
|
-
def database_create_backup(
|
|
242
|
+
def database_create_backup(
|
|
243
|
+
self, backup_name: str = "neo4j_database.backup", dest_dir: Path | None = None, compress: bool = False
|
|
244
|
+
) -> None:
|
|
241
245
|
assert self.use_neo4j_enterprise
|
|
242
246
|
|
|
243
247
|
self.exec_in_container(
|
|
@@ -245,7 +249,7 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
245
249
|
"neo4j-admin",
|
|
246
250
|
"database",
|
|
247
251
|
"backup",
|
|
248
|
-
"--compress=false",
|
|
252
|
+
f"--compress={'true' if compress else 'false'}",
|
|
249
253
|
"--to-path",
|
|
250
254
|
str(self.internal_backup_dir),
|
|
251
255
|
],
|
|
@@ -513,3 +517,111 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
513
517
|
)
|
|
514
518
|
self.start()
|
|
515
519
|
print("Database restored successfully")
|
|
520
|
+
|
|
521
|
+
def task_manager_create_backup(self, backup_name: str = "prefect.dump", dest_dir: Path | None = None) -> Path:
|
|
522
|
+
"""Create a backup of the task manager PostgreSQL database using ``pg_dump``.
|
|
523
|
+
|
|
524
|
+
Args:
|
|
525
|
+
backup_name: Name of the archive file to create. Defaults to ``prefect.dump``.
|
|
526
|
+
dest_dir: Optional host directory where the backup should be copied after it is
|
|
527
|
+
produced. When omitted, the backup remains in ``external_backup_dir``.
|
|
528
|
+
|
|
529
|
+
Returns:
|
|
530
|
+
Path to the backup archive on the host filesystem.
|
|
531
|
+
|
|
532
|
+
Raises:
|
|
533
|
+
FileNotFoundError: If the pg_dump command completes but no archive is produced.
|
|
534
|
+
"""
|
|
535
|
+
|
|
536
|
+
service_name = "task-manager-db"
|
|
537
|
+
|
|
538
|
+
try:
|
|
539
|
+
self.get_container(service_name=service_name)
|
|
540
|
+
except ContainerIsNotRunning:
|
|
541
|
+
self.start_container(service_name=service_name)
|
|
542
|
+
|
|
543
|
+
self.external_backup_dir.mkdir(parents=True, exist_ok=True)
|
|
544
|
+
|
|
545
|
+
internal_backup_path = self.internal_backup_dir / backup_name
|
|
546
|
+
dump_command = [
|
|
547
|
+
"pg_dump",
|
|
548
|
+
"--format=custom",
|
|
549
|
+
"--blobs",
|
|
550
|
+
"--no-owner",
|
|
551
|
+
"--no-privileges",
|
|
552
|
+
"--dbname=postgresql://postgres:postgres@localhost:5432/prefect",
|
|
553
|
+
f"--file={internal_backup_path}",
|
|
554
|
+
]
|
|
555
|
+
self.exec_in_container(command=dump_command, service_name=service_name)
|
|
556
|
+
|
|
557
|
+
source_path = self.external_backup_dir / backup_name
|
|
558
|
+
if not source_path.exists():
|
|
559
|
+
raise FileNotFoundError(f"Backup file {source_path} was not created")
|
|
560
|
+
|
|
561
|
+
final_path = source_path
|
|
562
|
+
if dest_dir:
|
|
563
|
+
dest_dir.mkdir(parents=True, exist_ok=True)
|
|
564
|
+
if dest_dir.resolve() != self.external_backup_dir.resolve():
|
|
565
|
+
final_path = dest_dir / backup_name
|
|
566
|
+
shutil.copy(source_path, final_path)
|
|
567
|
+
|
|
568
|
+
return final_path
|
|
569
|
+
|
|
570
|
+
def task_manager_restore_backup(self, backup_file: Path) -> None:
|
|
571
|
+
"""Restore the task manager PostgreSQL database from a ``pg_restore`` archive.
|
|
572
|
+
|
|
573
|
+
Args:
|
|
574
|
+
backup_file: Path to the backup archive on the host filesystem.
|
|
575
|
+
|
|
576
|
+
Raises:
|
|
577
|
+
FileNotFoundError: If the provided backup archive does not exist.
|
|
578
|
+
"""
|
|
579
|
+
|
|
580
|
+
if not backup_file.exists():
|
|
581
|
+
raise FileNotFoundError(f"Backup file {backup_file} does not exist")
|
|
582
|
+
|
|
583
|
+
service_name = "task-manager-db"
|
|
584
|
+
|
|
585
|
+
try:
|
|
586
|
+
self.get_container(service_name=service_name)
|
|
587
|
+
except ContainerIsNotRunning:
|
|
588
|
+
self.start_container(service_name=service_name)
|
|
589
|
+
|
|
590
|
+
self.external_backup_dir.mkdir(parents=True, exist_ok=True)
|
|
591
|
+
target_path = self.external_backup_dir / backup_file.name
|
|
592
|
+
shutil.copy(backup_file, target_path)
|
|
593
|
+
|
|
594
|
+
admin_dsn = "postgresql://postgres:postgres@localhost:5432/postgres"
|
|
595
|
+
prefect_dsn = "postgresql://postgres:postgres@localhost:5432/prefect"
|
|
596
|
+
internal_backup_path = self.internal_backup_dir / backup_file.name
|
|
597
|
+
|
|
598
|
+
terminate_sessions_command = [
|
|
599
|
+
"psql",
|
|
600
|
+
f"--dbname={admin_dsn}",
|
|
601
|
+
"--command",
|
|
602
|
+
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'prefect';",
|
|
603
|
+
]
|
|
604
|
+
drop_database_command = [
|
|
605
|
+
"psql",
|
|
606
|
+
f"--dbname={admin_dsn}",
|
|
607
|
+
"--command",
|
|
608
|
+
"DROP DATABASE IF EXISTS prefect WITH (FORCE);",
|
|
609
|
+
]
|
|
610
|
+
create_database_command = [
|
|
611
|
+
"psql",
|
|
612
|
+
f"--dbname={admin_dsn}",
|
|
613
|
+
"--command",
|
|
614
|
+
"CREATE DATABASE prefect OWNER postgres;",
|
|
615
|
+
]
|
|
616
|
+
restore_command = [
|
|
617
|
+
"pg_restore",
|
|
618
|
+
"--no-owner",
|
|
619
|
+
"--role=postgres",
|
|
620
|
+
f"--dbname={prefect_dsn}",
|
|
621
|
+
str(internal_backup_path),
|
|
622
|
+
]
|
|
623
|
+
|
|
624
|
+
self.exec_in_container(command=terminate_sessions_command, service_name=service_name)
|
|
625
|
+
self.exec_in_container(command=drop_database_command, service_name=service_name)
|
|
626
|
+
self.exec_in_container(command=create_database_command, service_name=service_name)
|
|
627
|
+
self.exec_in_container(command=restore_command, service_name=service_name)
|
|
@@ -37,7 +37,7 @@ services:
|
|
|
37
37
|
- ${INFRAHUB_TESTING_MESSAGE_QUEUE_PORT:-0}:15692
|
|
38
38
|
|
|
39
39
|
cache:
|
|
40
|
-
image: ${CACHE_DOCKER_IMAGE:-redis:7.2.
|
|
40
|
+
image: ${CACHE_DOCKER_IMAGE:-redis:7.2.11}
|
|
41
41
|
restart: unless-stopped
|
|
42
42
|
healthcheck:
|
|
43
43
|
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
|
|
@@ -184,6 +184,8 @@ services:
|
|
|
184
184
|
|
|
185
185
|
PREFECT_MESSAGING_BROKER:
|
|
186
186
|
PREFECT_MESSAGING_CACHE:
|
|
187
|
+
PREFECT_SERVER_EVENTS_CAUSAL_ORDERING:
|
|
188
|
+
PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE:
|
|
187
189
|
PREFECT__SERVER_WEBSERVER_ONLY:
|
|
188
190
|
PREFECT_API_DATABASE_MIGRATE_ON_START:
|
|
189
191
|
PREFECT_API_BLOCKS_REGISTER_ON_START:
|
|
@@ -225,6 +227,8 @@ services:
|
|
|
225
227
|
INFRAHUB_CACHE_ADDRESS: ${INFRAHUB_TESTING_CACHE_ADDRESS}
|
|
226
228
|
PREFECT_MESSAGING_BROKER: prefect_redis.messaging
|
|
227
229
|
PREFECT_MESSAGING_CACHE: prefect_redis.messaging
|
|
230
|
+
PREFECT_SERVER_EVENTS_CAUSAL_ORDERING: prefect_redis.ordering
|
|
231
|
+
PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE: prefect_redis.lease_storage
|
|
228
232
|
PREFECT_REDIS_MESSAGING_HOST: "${INFRAHUB_TESTING_CACHE_ADDRESS:-cache}"
|
|
229
233
|
PREFECT_REDIS_MESSAGING_DB: "1"
|
|
230
234
|
PREFECT_REDIS_MESSAGING_CONSUMER_MIN_IDLE_TIME: "30"
|
|
@@ -244,6 +248,7 @@ services:
|
|
|
244
248
|
- POSTGRES_DB=prefect
|
|
245
249
|
volumes:
|
|
246
250
|
- workflow_db:/var/lib/postgresql/data
|
|
251
|
+
- "./${INFRAHUB_TESTING_LOCAL_DB_BACKUP_DIRECTORY}:${INFRAHUB_TESTING_INTERNAL_DB_BACKUP_DIRECTORY}"
|
|
247
252
|
healthcheck:
|
|
248
253
|
test: ["CMD-SHELL", "pg_isready"]
|
|
249
254
|
interval: 10s
|
|
@@ -20,7 +20,7 @@ services:
|
|
|
20
20
|
- ${INFRAHUB_TESTING_MESSAGE_QUEUE_PORT:-0}:15692
|
|
21
21
|
|
|
22
22
|
cache:
|
|
23
|
-
image: ${CACHE_DOCKER_IMAGE:-redis:7.2.
|
|
23
|
+
image: ${CACHE_DOCKER_IMAGE:-redis:7.2.11}
|
|
24
24
|
restart: unless-stopped
|
|
25
25
|
healthcheck:
|
|
26
26
|
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
|
|
@@ -95,6 +95,8 @@ services:
|
|
|
95
95
|
|
|
96
96
|
PREFECT_MESSAGING_BROKER:
|
|
97
97
|
PREFECT_MESSAGING_CACHE:
|
|
98
|
+
PREFECT_SERVER_EVENTS_CAUSAL_ORDERING:
|
|
99
|
+
PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE:
|
|
98
100
|
PREFECT__SERVER_WEBSERVER_ONLY:
|
|
99
101
|
PREFECT_API_DATABASE_MIGRATE_ON_START:
|
|
100
102
|
PREFECT_API_BLOCKS_REGISTER_ON_START:
|
|
@@ -136,6 +138,8 @@ services:
|
|
|
136
138
|
INFRAHUB_CACHE_ADDRESS: ${INFRAHUB_TESTING_CACHE_ADDRESS}
|
|
137
139
|
PREFECT_MESSAGING_BROKER: prefect_redis.messaging
|
|
138
140
|
PREFECT_MESSAGING_CACHE: prefect_redis.messaging
|
|
141
|
+
PREFECT_SERVER_EVENTS_CAUSAL_ORDERING: prefect_redis.ordering
|
|
142
|
+
PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE: prefect_redis.lease_storage
|
|
139
143
|
PREFECT_REDIS_MESSAGING_HOST: "${INFRAHUB_TESTING_CACHE_ADDRESS:-cache}"
|
|
140
144
|
PREFECT_REDIS_MESSAGING_DB: "1"
|
|
141
145
|
PREFECT_REDIS_MESSAGING_CONSUMER_MIN_IDLE_TIME: "30"
|
|
@@ -155,6 +159,7 @@ services:
|
|
|
155
159
|
- POSTGRES_DB=prefect
|
|
156
160
|
volumes:
|
|
157
161
|
- workflow_db:/var/lib/postgresql/data
|
|
162
|
+
- "./${INFRAHUB_TESTING_LOCAL_DB_BACKUP_DIRECTORY}:${INFRAHUB_TESTING_INTERNAL_DB_BACKUP_DIRECTORY}"
|
|
158
163
|
healthcheck:
|
|
159
164
|
test: ["CMD-SHELL", "pg_isready"]
|
|
160
165
|
interval: 10s
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "infrahub-testcontainers"
|
|
3
|
-
version = "1.5.
|
|
3
|
+
version = "1.5.0b2"
|
|
4
4
|
requires-python = ">=3.9"
|
|
5
5
|
|
|
6
6
|
[tool.poetry]
|
|
7
7
|
name = "infrahub-testcontainers"
|
|
8
|
-
version = "1.5.
|
|
8
|
+
version = "1.5.0b2"
|
|
9
9
|
description = "Testcontainers instance for Infrahub to easily build integration tests"
|
|
10
10
|
authors = ["OpsMill <info@opsmill.com>"]
|
|
11
11
|
readme = "README.md"
|
|
@@ -39,7 +39,7 @@ psutil = "*"
|
|
|
39
39
|
pytest = "*"
|
|
40
40
|
httpx = "^0.28.1"
|
|
41
41
|
pydantic = "^2.10.6"
|
|
42
|
-
prefect-client = "3.4.
|
|
42
|
+
prefect-client = "3.4.23"
|
|
43
43
|
|
|
44
44
|
[tool.poetry.group.dev.dependencies]
|
|
45
45
|
rich = "^13.9.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{infrahub_testcontainers-1.5.0b0 → infrahub_testcontainers-1.5.0b2}/infrahub_testcontainers/host.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|