infrahub-testcontainers 1.2.4__tar.gz → 1.2.6__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.4 → infrahub_testcontainers-1.2.6}/PKG-INFO +1 -1
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/container.py +52 -2
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/docker-compose.test.yml +27 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/models.py +2 -2
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/performance_test.py +5 -5
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/plugin.py +1 -1
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/pyproject.toml +2 -2
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/README.md +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/__init__.py +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/constants.py +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/haproxy.cfg +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/helpers.py +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/host.py +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/measurements.py +0 -0
- {infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/prometheus.yml +0 -0
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/container.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import shutil
|
|
3
|
+
import time
|
|
3
4
|
import uuid
|
|
4
5
|
from dataclasses import dataclass, field
|
|
5
6
|
from functools import cached_property
|
|
@@ -265,9 +266,58 @@ class InfrahubDockerCompose(DockerCompose):
|
|
|
265
266
|
)
|
|
266
267
|
|
|
267
268
|
self.exec_in_container(
|
|
268
|
-
command=["
|
|
269
|
+
command=["chown", "-R", "neo4j:neo4j", "/data"],
|
|
269
270
|
service_name=service_name,
|
|
270
271
|
)
|
|
271
272
|
|
|
273
|
+
(restore_output, _, _) = self.exec_in_container(
|
|
274
|
+
command=[
|
|
275
|
+
"cypher-shell",
|
|
276
|
+
"--format",
|
|
277
|
+
"plain",
|
|
278
|
+
"-d",
|
|
279
|
+
"system",
|
|
280
|
+
"-u",
|
|
281
|
+
"neo4j",
|
|
282
|
+
"-p",
|
|
283
|
+
"admin",
|
|
284
|
+
"START DATABASE neo4j;",
|
|
285
|
+
],
|
|
286
|
+
service_name=service_name,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
for _ in range(3):
|
|
290
|
+
(stdout, _, _) = self.exec_in_container(
|
|
291
|
+
command=[
|
|
292
|
+
"cypher-shell",
|
|
293
|
+
"--format",
|
|
294
|
+
"plain",
|
|
295
|
+
"-d",
|
|
296
|
+
"system",
|
|
297
|
+
"-u",
|
|
298
|
+
"neo4j",
|
|
299
|
+
"-p",
|
|
300
|
+
"admin",
|
|
301
|
+
"SHOW DATABASES WHERE name = 'neo4j' AND currentStatus = 'online';",
|
|
302
|
+
],
|
|
303
|
+
service_name=service_name,
|
|
304
|
+
)
|
|
305
|
+
if stdout:
|
|
306
|
+
break
|
|
307
|
+
time.sleep(5)
|
|
308
|
+
else:
|
|
309
|
+
(debug_logs, _, _) = self.exec_in_container(
|
|
310
|
+
command=["cat", "logs/debug.log"],
|
|
311
|
+
service_name=service_name,
|
|
312
|
+
)
|
|
313
|
+
raise Exception(f"Failed to restore database:\n{restore_output}\nDebug logs:\n{debug_logs}")
|
|
314
|
+
|
|
315
|
+
old_services = self.services
|
|
316
|
+
self.services = ["infrahub-server", "task-worker"]
|
|
272
317
|
self.stop(down=False)
|
|
273
|
-
|
|
318
|
+
try:
|
|
319
|
+
self.start()
|
|
320
|
+
except Exception as exc:
|
|
321
|
+
stdout, stderr = self.get_logs()
|
|
322
|
+
raise Exception(f"Failed to start docker compose:\nStdout:\n{stdout}\nStderr:\n{stderr}") from exc
|
|
323
|
+
self.services = old_services
|
|
@@ -45,6 +45,11 @@ services:
|
|
|
45
45
|
- ${INFRAHUB_TESTING_SERVER_PORT:-0}:8000
|
|
46
46
|
|
|
47
47
|
database:
|
|
48
|
+
deploy:
|
|
49
|
+
resources:
|
|
50
|
+
limits:
|
|
51
|
+
cpus: ${INFRAHUB_TESTING_DB_CPU_LIMIT:-0.0}
|
|
52
|
+
memory: ${INFRAHUB_TESTING_DB_MEMORY_LIMIT:-0}
|
|
48
53
|
image: ${NEO4J_DOCKER_IMAGE:-neo4j:5.20.0-community}
|
|
49
54
|
restart: unless-stopped
|
|
50
55
|
environment:
|
|
@@ -52,6 +57,8 @@ services:
|
|
|
52
57
|
NEO4J_dbms_security_procedures_unrestricted: "apoc.*"
|
|
53
58
|
NEO4J_dbms_security_auth__minimum__password__length: 4
|
|
54
59
|
NEO4J_ACCEPT_LICENSE_AGREEMENT: "yes"
|
|
60
|
+
NEO4J_dbms_memory_heap_initial__size: ${INFRAHUB_TESTING_DB_HEAP_INITIAL_SIZE}
|
|
61
|
+
NEO4J_dbms_memory_heap_max__size: ${INFRAHUB_TESTING_DB_HEAP_MAX_SIZE}
|
|
55
62
|
volumes:
|
|
56
63
|
- "database_data:/data"
|
|
57
64
|
- "database_logs:/logs"
|
|
@@ -116,6 +123,13 @@ services:
|
|
|
116
123
|
INFRAHUB_INITIAL_AGENT_TOKEN: ${INFRAHUB_TESTING_INITIAL_AGENT_TOKEN}
|
|
117
124
|
INFRAHUB_SECURITY_SECRET_KEY: ${INFRAHUB_TESTING_SECURITY_SECRET_KEY}
|
|
118
125
|
PREFECT_API_URL: ${INFRAHUB_TESTING_PREFECT_API}
|
|
126
|
+
# Tracing
|
|
127
|
+
INFRAHUB_TRACE_ENABLE: ${INFRAHUB_TRACE_ENABLE:-false}
|
|
128
|
+
INFRAHUB_TRACE_EXPORTER_ENDPOINT:
|
|
129
|
+
INFRAHUB_TRACE_EXPORTER_PROTOCOL: ${INFRAHUB_TRACE_EXPORTER_PROTOCOL:-grpc}
|
|
130
|
+
INFRAHUB_TRACE_EXPORTER_TYPE: ${INFRAHUB_TRACE_EXPORTER_TYPE:-console}
|
|
131
|
+
INFRAHUB_TRACE_INSECURE: ${INFRAHUB_TRACE_INSECURE:-true}
|
|
132
|
+
OTEL_RESOURCE_ATTRIBUTES:
|
|
119
133
|
depends_on:
|
|
120
134
|
database:
|
|
121
135
|
condition: service_healthy
|
|
@@ -155,6 +169,13 @@ services:
|
|
|
155
169
|
INFRAHUB_WORKFLOW_ADDRESS: ${INFRAHUB_TESTING_WORKFLOW_ADDRESS}
|
|
156
170
|
INFRAHUB_TIMEOUT: ${INFRAHUB_TESTING_TIMEOUT}
|
|
157
171
|
PREFECT_API_URL: ${INFRAHUB_TESTING_PREFECT_API}
|
|
172
|
+
# Tracing
|
|
173
|
+
INFRAHUB_TRACE_ENABLE: ${INFRAHUB_TRACE_ENABLE:-false}
|
|
174
|
+
INFRAHUB_TRACE_EXPORTER_ENDPOINT:
|
|
175
|
+
INFRAHUB_TRACE_EXPORTER_PROTOCOL: ${INFRAHUB_TRACE_EXPORTER_PROTOCOL:-grpc}
|
|
176
|
+
INFRAHUB_TRACE_EXPORTER_TYPE: ${INFRAHUB_TRACE_EXPORTER_TYPE:-console}
|
|
177
|
+
INFRAHUB_TRACE_INSECURE: ${INFRAHUB_TRACE_INSECURE:-true}
|
|
178
|
+
OTEL_RESOURCE_ATTRIBUTES:
|
|
158
179
|
depends_on:
|
|
159
180
|
- infrahub-server
|
|
160
181
|
volumes:
|
|
@@ -187,6 +208,12 @@ services:
|
|
|
187
208
|
- "--promscrape.config=/etc/prometheus/prometheus.yml"
|
|
188
209
|
ports:
|
|
189
210
|
- ${INFRAHUB_TESTING_SCRAPER_PORT:-0}:8428
|
|
211
|
+
healthcheck:
|
|
212
|
+
test: wget -qO- http://127.0.0.1:8428/-/healthy
|
|
213
|
+
start_period: 10s
|
|
214
|
+
interval: 5s
|
|
215
|
+
timeout: 5s
|
|
216
|
+
retries: 10
|
|
190
217
|
|
|
191
218
|
volumes:
|
|
192
219
|
database_data:
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/models.py
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from datetime import
|
|
1
|
+
from datetime import datetime, timezone
|
|
2
2
|
from enum import Enum
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
@@ -27,7 +27,7 @@ class InfrahubResultContext(BaseModel):
|
|
|
27
27
|
|
|
28
28
|
class InfrahubActiveMeasurementItem(BaseModel):
|
|
29
29
|
definition: MeasurementDefinition
|
|
30
|
-
start_time: datetime = datetime.now(
|
|
30
|
+
start_time: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
31
31
|
context: dict[str, Any] = Field(default_factory=dict)
|
|
32
32
|
|
|
33
33
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import json
|
|
3
|
-
from datetime import
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
4
|
from types import TracebackType
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ class InfrahubPerformanceTest:
|
|
|
35
35
|
self.env_vars = {}
|
|
36
36
|
self.project_name = ""
|
|
37
37
|
self.test_info = {}
|
|
38
|
-
self.start_time = datetime.now(
|
|
38
|
+
self.start_time = datetime.now(timezone.utc)
|
|
39
39
|
self.end_time: datetime | None = None
|
|
40
40
|
self.results_url = results_url
|
|
41
41
|
self.scraper_endpoint = ""
|
|
@@ -57,7 +57,7 @@ class InfrahubPerformanceTest:
|
|
|
57
57
|
|
|
58
58
|
def finalize(self, session: pytest.Session) -> None:
|
|
59
59
|
if self.initialized:
|
|
60
|
-
self.end_time = datetime.now(
|
|
60
|
+
self.end_time = datetime.now(timezone.utc)
|
|
61
61
|
self.extract_test_session_information(session)
|
|
62
62
|
self.send_results()
|
|
63
63
|
|
|
@@ -100,7 +100,7 @@ class InfrahubPerformanceTest:
|
|
|
100
100
|
return self
|
|
101
101
|
|
|
102
102
|
def fetch_metrics(self) -> None:
|
|
103
|
-
with httpx.Client() as client:
|
|
103
|
+
with httpx.Client(timeout=30.0) as client:
|
|
104
104
|
# Get Infrahub metrics
|
|
105
105
|
response = client.post(
|
|
106
106
|
url=self.scraper_endpoint,
|
|
@@ -129,7 +129,7 @@ class InfrahubPerformanceTest:
|
|
|
129
129
|
if not exc_type and self.active_measurements:
|
|
130
130
|
self.add_measurement(
|
|
131
131
|
definition=self.active_measurements.definition,
|
|
132
|
-
value=(datetime.now(
|
|
132
|
+
value=(datetime.now(timezone.utc) - self.active_measurements.start_time).total_seconds() * 1000,
|
|
133
133
|
context=self.active_measurements.context,
|
|
134
134
|
)
|
|
135
135
|
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/plugin.py
RENAMED
|
@@ -125,7 +125,7 @@ def pytest_terminal_summary(
|
|
|
125
125
|
performance_test = terminalreporter._session.infrahub_performance_test
|
|
126
126
|
|
|
127
127
|
report = [
|
|
128
|
-
f"{measurement.name}: {measurement.value} {measurement.unit.value}"
|
|
128
|
+
f"{measurement.name} ({measurement.context}): {measurement.value} {measurement.unit.value}"
|
|
129
129
|
for measurement in performance_test.measurements
|
|
130
130
|
]
|
|
131
131
|
terminalreporter.write("\n" + "\n".join(report) + "\n")
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "infrahub-testcontainers"
|
|
3
|
-
version = "1.2.
|
|
3
|
+
version = "1.2.6"
|
|
4
4
|
requires-python = ">=3.9"
|
|
5
5
|
|
|
6
6
|
[tool.poetry]
|
|
7
7
|
name = "infrahub-testcontainers"
|
|
8
|
-
version = "1.2.
|
|
8
|
+
version = "1.2.6"
|
|
9
9
|
description = "Testcontainers instance for Infrahub to easily build integration tests"
|
|
10
10
|
authors = ["OpsMill <info@opsmill.com>"]
|
|
11
11
|
readme = "README.md"
|
|
File without changes
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/__init__.py
RENAMED
|
File without changes
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/constants.py
RENAMED
|
File without changes
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/haproxy.cfg
RENAMED
|
File without changes
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/helpers.py
RENAMED
|
File without changes
|
{infrahub_testcontainers-1.2.4 → infrahub_testcontainers-1.2.6}/infrahub_testcontainers/host.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|