infrahub-server 1.2.11__py3-none-any.whl → 1.2.12__py3-none-any.whl

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.
@@ -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"
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import subprocess # noqa: S404
3
+ import warnings
3
4
  from pathlib import Path
4
5
 
5
6
  import pytest
@@ -59,6 +60,10 @@ class TestInfrahubDocker:
59
60
  def default_branch(self) -> str:
60
61
  return "main"
61
62
 
63
+ @pytest.fixture(scope="class")
64
+ def deployment_type(self, request: pytest.FixtureRequest) -> str | None:
65
+ return request.config.getoption(name="infrahub_deployment_type", default=None)
66
+
62
67
  @pytest.fixture(scope="class")
63
68
  def infrahub_compose(
64
69
  self,
@@ -66,12 +71,21 @@ class TestInfrahubDocker:
66
71
  remote_repos_dir: Path, # initialize repository before running docker compose to fix permissions issues # noqa: ARG002
67
72
  remote_backups_dir: Path, # noqa: ARG002
68
73
  infrahub_version: str,
74
+ deployment_type: str | None,
69
75
  ) -> InfrahubDockerCompose:
70
- return InfrahubDockerCompose.init(directory=tmp_directory, version=infrahub_version)
76
+ return InfrahubDockerCompose.init(
77
+ directory=tmp_directory, version=infrahub_version, deployment_type=deployment_type
78
+ )
71
79
 
72
80
  @pytest.fixture(scope="class")
73
81
  def infrahub_app(self, request: pytest.FixtureRequest, infrahub_compose: InfrahubDockerCompose) -> dict[str, int]:
82
+ tests_failed_before_class = request.session.testsfailed
83
+
74
84
  def cleanup() -> None:
85
+ tests_failed_during_class = request.session.testsfailed - tests_failed_before_class
86
+ if tests_failed_during_class > 0:
87
+ stdout, stderr = infrahub_compose.get_logs("infrahub-server", "task-worker")
88
+ warnings.warn(f"Container logs:\nStdout:\n{stdout}\nStderr:\n{stderr}", stacklevel=2)
75
89
  infrahub_compose.stop()
76
90
 
77
91
  request.addfinalizer(cleanup)
@@ -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,109 +0,0 @@
1
- from ..models import EdgeToAdd, EdgeToDelete, PatchPlan, VertexToDelete
2
- from .base import PatchQuery
3
-
4
-
5
- class ConsolidateDuplicatedNodesPatchQuery(PatchQuery):
6
- """
7
- Find any groups of nodes with the same labels and properties, move all the edges to one of the duplicated nodes,
8
- then delete the other duplicated nodes
9
- """
10
-
11
- @property
12
- def name(self) -> str:
13
- return "consolidate-duplicated-nodes"
14
-
15
- async def plan(self) -> PatchPlan:
16
- query = """
17
- //------------
18
- // Find nodes with the same labels and UUID
19
- //------------
20
- MATCH (n:Node)
21
- WITH n.uuid AS node_uuid, count(*) as num_nodes_with_uuid
22
- WHERE num_nodes_with_uuid > 1
23
- WITH DISTINCT node_uuid
24
- MATCH (n:Node {uuid: node_uuid})
25
- CALL {
26
- WITH n
27
- WITH labels(n) AS n_labels
28
- UNWIND n_labels AS n_label
29
- WITH n_label
30
- ORDER BY n_label ASC
31
- RETURN collect(n_label) AS sorted_labels
32
- }
33
- WITH n.uuid AS n_uuid, sorted_labels, collect(n) AS duplicate_nodes
34
- WHERE size(duplicate_nodes) > 1
35
- WITH n_uuid, head(duplicate_nodes) AS node_to_keep, tail(duplicate_nodes) AS nodes_to_delete
36
- UNWIND nodes_to_delete AS node_to_delete
37
- //------------
38
- // Find the edges that we need to move to the selected node_to_keep
39
- //------------
40
- CALL {
41
- WITH node_to_keep, node_to_delete
42
- MATCH (node_to_delete)-[edge_to_delete]->(peer)
43
- RETURN {
44
- from_id: %(id_func_name)s(node_to_keep),
45
- to_id: %(id_func_name)s(peer),
46
- edge_type: type(edge_to_delete),
47
- after_props: properties(edge_to_delete)
48
- } AS edge_to_create
49
- UNION
50
- WITH node_to_keep, node_to_delete
51
- MATCH (node_to_delete)<-[edge_to_delete]-(peer)
52
- RETURN {
53
- from_id: %(id_func_name)s(peer),
54
- to_id: %(id_func_name)s(node_to_keep),
55
- edge_type: type(edge_to_delete),
56
- after_props: properties(edge_to_delete)
57
- } AS edge_to_create
58
- }
59
- WITH node_to_delete, collect(edge_to_create) AS edges_to_create
60
- //------------
61
- // Find the edges that we need to remove from the duplicated nodes
62
- //------------
63
- CALL {
64
- WITH node_to_delete
65
- MATCH (node_to_delete)-[e]->(peer)
66
- RETURN {
67
- db_id: %(id_func_name)s(e),
68
- from_id: %(id_func_name)s(node_to_delete),
69
- to_id: %(id_func_name)s(peer),
70
- edge_type: type(e),
71
- before_props: properties(e)
72
- } AS edge_to_delete
73
- UNION
74
- WITH node_to_delete
75
- MATCH (node_to_delete)<-[e]-(peer)
76
- RETURN {
77
- db_id: %(id_func_name)s(e),
78
- from_id: %(id_func_name)s(peer),
79
- to_id: %(id_func_name)s(node_to_delete),
80
- edge_type: type(e),
81
- before_props: properties(e)
82
- } AS edge_to_delete
83
- }
84
- WITH node_to_delete, edges_to_create, collect(edge_to_delete) AS edges_to_delete
85
- RETURN
86
- {db_id: %(id_func_name)s(node_to_delete), labels: labels(node_to_delete), before_props: properties(node_to_delete)} AS vertex_to_delete,
87
- edges_to_create,
88
- edges_to_delete
89
- """ % {"id_func_name": self.db.get_id_function_name()}
90
- results = await self.db.execute_query(query=query)
91
- vertices_to_delete: list[VertexToDelete] = []
92
- edges_to_delete: list[EdgeToDelete] = []
93
- edges_to_add: list[EdgeToAdd] = []
94
- for result in results:
95
- serial_vertex_to_delete = result.get("vertex_to_delete")
96
- if serial_vertex_to_delete:
97
- vertex_to_delete = VertexToDelete(**serial_vertex_to_delete)
98
- vertices_to_delete.append(vertex_to_delete)
99
- for serial_edge_to_delete in result.get("edges_to_delete"):
100
- edge_to_delete = EdgeToDelete(**serial_edge_to_delete)
101
- edges_to_delete.append(edge_to_delete)
102
- for serial_edge_to_create in result.get("edges_to_create"):
103
- edges_to_add.append(EdgeToAdd(**serial_edge_to_create))
104
- return PatchPlan(
105
- name=self.name,
106
- vertices_to_delete=vertices_to_delete,
107
- edges_to_add=edges_to_add,
108
- edges_to_delete=edges_to_delete,
109
- )