infrahub-server 1.2.11__py3-none-any.whl → 1.3.0__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.
Files changed (211) hide show
  1. infrahub/actions/constants.py +130 -0
  2. infrahub/actions/gather.py +114 -0
  3. infrahub/actions/models.py +243 -0
  4. infrahub/actions/parsers.py +104 -0
  5. infrahub/actions/schema.py +393 -0
  6. infrahub/actions/tasks.py +119 -0
  7. infrahub/actions/triggers.py +21 -0
  8. infrahub/branch/__init__.py +0 -0
  9. infrahub/branch/tasks.py +29 -0
  10. infrahub/branch/triggers.py +22 -0
  11. infrahub/cli/db.py +3 -4
  12. infrahub/computed_attribute/gather.py +3 -1
  13. infrahub/computed_attribute/tasks.py +23 -29
  14. infrahub/core/account.py +24 -47
  15. infrahub/core/attribute.py +13 -15
  16. infrahub/core/constants/__init__.py +10 -0
  17. infrahub/core/constants/database.py +1 -0
  18. infrahub/core/constants/infrahubkind.py +9 -0
  19. infrahub/core/constraint/node/runner.py +3 -1
  20. infrahub/core/convert_object_type/__init__.py +0 -0
  21. infrahub/core/convert_object_type/conversion.py +124 -0
  22. infrahub/core/convert_object_type/schema_mapping.py +56 -0
  23. infrahub/core/diff/coordinator.py +8 -1
  24. infrahub/core/diff/query/all_conflicts.py +1 -5
  25. infrahub/core/diff/query/artifact.py +10 -20
  26. infrahub/core/diff/query/delete_query.py +8 -4
  27. infrahub/core/diff/query/diff_get.py +3 -6
  28. infrahub/core/diff/query/field_specifiers.py +1 -1
  29. infrahub/core/diff/query/field_summary.py +2 -4
  30. infrahub/core/diff/query/merge.py +72 -125
  31. infrahub/core/diff/query/save.py +83 -68
  32. infrahub/core/diff/query/summary_counts_enricher.py +34 -54
  33. infrahub/core/diff/query/time_range_query.py +0 -1
  34. infrahub/core/diff/repository/repository.py +4 -0
  35. infrahub/core/graph/__init__.py +1 -1
  36. infrahub/core/manager.py +14 -11
  37. infrahub/core/migrations/graph/__init__.py +6 -0
  38. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
  39. infrahub/core/migrations/graph/m012_convert_account_generic.py +1 -1
  40. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -6
  41. infrahub/core/migrations/graph/m015_diff_format_update.py +1 -2
  42. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -2
  43. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
  44. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
  45. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
  46. infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +2 -2
  47. infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
  48. infrahub/core/migrations/graph/m028_delete_diffs.py +1 -2
  49. infrahub/core/migrations/graph/m029_duplicates_cleanup.py +662 -0
  50. infrahub/core/migrations/graph/m030_illegal_edges.py +82 -0
  51. infrahub/core/migrations/query/attribute_add.py +14 -11
  52. infrahub/core/migrations/query/attribute_rename.py +6 -11
  53. infrahub/core/migrations/query/delete_element_in_schema.py +19 -17
  54. infrahub/core/migrations/query/node_duplicate.py +19 -21
  55. infrahub/core/migrations/query/relationship_duplicate.py +19 -18
  56. infrahub/core/migrations/schema/node_attribute_remove.py +4 -8
  57. infrahub/core/migrations/schema/node_remove.py +19 -20
  58. infrahub/core/models.py +29 -2
  59. infrahub/core/node/__init__.py +131 -28
  60. infrahub/core/node/base.py +1 -1
  61. infrahub/core/node/create.py +211 -0
  62. infrahub/core/node/resource_manager/number_pool.py +31 -5
  63. infrahub/core/node/standard.py +6 -1
  64. infrahub/core/path.py +15 -1
  65. infrahub/core/protocols.py +57 -0
  66. infrahub/core/protocols_base.py +3 -0
  67. infrahub/core/query/__init__.py +2 -2
  68. infrahub/core/query/delete.py +3 -3
  69. infrahub/core/query/diff.py +19 -32
  70. infrahub/core/query/ipam.py +10 -20
  71. infrahub/core/query/node.py +29 -47
  72. infrahub/core/query/relationship.py +55 -34
  73. infrahub/core/query/resource_manager.py +1 -2
  74. infrahub/core/query/standard_node.py +19 -5
  75. infrahub/core/query/subquery.py +2 -4
  76. infrahub/core/relationship/constraints/count.py +10 -9
  77. infrahub/core/relationship/constraints/interface.py +2 -1
  78. infrahub/core/relationship/constraints/peer_kind.py +2 -1
  79. infrahub/core/relationship/constraints/peer_parent.py +56 -0
  80. infrahub/core/relationship/constraints/peer_relatives.py +72 -0
  81. infrahub/core/relationship/constraints/profiles_kind.py +1 -1
  82. infrahub/core/relationship/model.py +4 -1
  83. infrahub/core/schema/__init__.py +2 -1
  84. infrahub/core/schema/attribute_parameters.py +160 -0
  85. infrahub/core/schema/attribute_schema.py +130 -7
  86. infrahub/core/schema/basenode_schema.py +27 -3
  87. infrahub/core/schema/definitions/core/__init__.py +29 -1
  88. infrahub/core/schema/definitions/core/group.py +45 -0
  89. infrahub/core/schema/definitions/core/resource_pool.py +9 -0
  90. infrahub/core/schema/definitions/internal.py +43 -5
  91. infrahub/core/schema/generated/attribute_schema.py +16 -3
  92. infrahub/core/schema/generated/relationship_schema.py +11 -1
  93. infrahub/core/schema/manager.py +7 -2
  94. infrahub/core/schema/schema_branch.py +109 -12
  95. infrahub/core/validators/__init__.py +15 -2
  96. infrahub/core/validators/attribute/choices.py +1 -3
  97. infrahub/core/validators/attribute/enum.py +1 -3
  98. infrahub/core/validators/attribute/kind.py +1 -3
  99. infrahub/core/validators/attribute/length.py +13 -7
  100. infrahub/core/validators/attribute/min_max.py +118 -0
  101. infrahub/core/validators/attribute/number_pool.py +106 -0
  102. infrahub/core/validators/attribute/optional.py +1 -4
  103. infrahub/core/validators/attribute/regex.py +5 -6
  104. infrahub/core/validators/attribute/unique.py +1 -3
  105. infrahub/core/validators/determiner.py +18 -2
  106. infrahub/core/validators/enum.py +12 -0
  107. infrahub/core/validators/node/hierarchy.py +3 -6
  108. infrahub/core/validators/query.py +1 -3
  109. infrahub/core/validators/relationship/count.py +6 -12
  110. infrahub/core/validators/relationship/optional.py +2 -4
  111. infrahub/core/validators/relationship/peer.py +177 -12
  112. infrahub/core/validators/tasks.py +1 -1
  113. infrahub/core/validators/uniqueness/query.py +5 -9
  114. infrahub/database/__init__.py +12 -4
  115. infrahub/database/validation.py +100 -0
  116. infrahub/dependencies/builder/constraint/grouped/node_runner.py +4 -0
  117. infrahub/dependencies/builder/constraint/relationship_manager/peer_parent.py +8 -0
  118. infrahub/dependencies/builder/constraint/relationship_manager/peer_relatives.py +8 -0
  119. infrahub/dependencies/builder/constraint/schema/aggregated.py +2 -0
  120. infrahub/dependencies/builder/constraint/schema/relationship_peer.py +8 -0
  121. infrahub/dependencies/builder/diff/deserializer.py +1 -1
  122. infrahub/dependencies/registry.py +4 -0
  123. infrahub/events/group_action.py +1 -0
  124. infrahub/events/models.py +1 -1
  125. infrahub/git/base.py +5 -3
  126. infrahub/git/integrator.py +96 -5
  127. infrahub/git/tasks.py +1 -0
  128. infrahub/graphql/analyzer.py +139 -18
  129. infrahub/graphql/manager.py +4 -0
  130. infrahub/graphql/mutations/action.py +164 -0
  131. infrahub/graphql/mutations/convert_object_type.py +71 -0
  132. infrahub/graphql/mutations/main.py +25 -176
  133. infrahub/graphql/mutations/proposed_change.py +20 -17
  134. infrahub/graphql/mutations/relationship.py +32 -0
  135. infrahub/graphql/mutations/resource_manager.py +63 -7
  136. infrahub/graphql/queries/convert_object_type_mapping.py +34 -0
  137. infrahub/graphql/queries/resource_manager.py +7 -1
  138. infrahub/graphql/resolvers/many_relationship.py +1 -1
  139. infrahub/graphql/resolvers/resolver.py +2 -2
  140. infrahub/graphql/resolvers/single_relationship.py +1 -1
  141. infrahub/graphql/schema.py +6 -0
  142. infrahub/menu/menu.py +34 -2
  143. infrahub/message_bus/messages/__init__.py +0 -10
  144. infrahub/message_bus/operations/__init__.py +0 -8
  145. infrahub/message_bus/operations/refresh/registry.py +4 -7
  146. infrahub/patch/queries/delete_duplicated_edges.py +45 -39
  147. infrahub/pools/models.py +14 -0
  148. infrahub/pools/number.py +5 -3
  149. infrahub/pools/registration.py +22 -0
  150. infrahub/pools/tasks.py +126 -0
  151. infrahub/prefect_server/models.py +1 -19
  152. infrahub/proposed_change/models.py +68 -3
  153. infrahub/proposed_change/tasks.py +911 -34
  154. infrahub/schema/__init__.py +0 -0
  155. infrahub/schema/tasks.py +27 -0
  156. infrahub/schema/triggers.py +23 -0
  157. infrahub/task_manager/models.py +10 -6
  158. infrahub/trigger/catalogue.py +6 -0
  159. infrahub/trigger/models.py +23 -6
  160. infrahub/trigger/setup.py +26 -2
  161. infrahub/trigger/tasks.py +4 -2
  162. infrahub/types.py +6 -0
  163. infrahub/webhook/tasks.py +6 -9
  164. infrahub/workflows/catalogue.py +103 -1
  165. infrahub_sdk/client.py +43 -10
  166. infrahub_sdk/ctl/generator.py +4 -4
  167. infrahub_sdk/ctl/repository.py +1 -1
  168. infrahub_sdk/node/__init__.py +39 -0
  169. infrahub_sdk/node/attribute.py +122 -0
  170. infrahub_sdk/node/constants.py +21 -0
  171. infrahub_sdk/{node.py → node/node.py} +158 -803
  172. infrahub_sdk/node/parsers.py +15 -0
  173. infrahub_sdk/node/property.py +24 -0
  174. infrahub_sdk/node/related_node.py +266 -0
  175. infrahub_sdk/node/relationship.py +302 -0
  176. infrahub_sdk/protocols.py +112 -0
  177. infrahub_sdk/protocols_base.py +34 -2
  178. infrahub_sdk/pytest_plugin/items/python_transform.py +2 -1
  179. infrahub_sdk/query_groups.py +17 -5
  180. infrahub_sdk/schema/main.py +1 -0
  181. infrahub_sdk/schema/repository.py +16 -0
  182. infrahub_sdk/spec/object.py +1 -1
  183. infrahub_sdk/store.py +1 -1
  184. infrahub_sdk/testing/schemas/car_person.py +1 -0
  185. infrahub_sdk/utils.py +7 -20
  186. infrahub_sdk/yaml.py +6 -5
  187. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/METADATA +5 -5
  188. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/RECORD +197 -168
  189. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/WHEEL +1 -1
  190. infrahub_testcontainers/container.py +239 -65
  191. infrahub_testcontainers/docker-compose-cluster.test.yml +321 -0
  192. infrahub_testcontainers/docker-compose.test.yml +2 -1
  193. infrahub_testcontainers/helpers.py +23 -3
  194. infrahub_testcontainers/plugin.py +9 -0
  195. infrahub/message_bus/messages/check_generator_run.py +0 -26
  196. infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
  197. infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
  198. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
  199. infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
  200. infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
  201. infrahub/message_bus/operations/check/__init__.py +0 -3
  202. infrahub/message_bus/operations/check/generator.py +0 -156
  203. infrahub/message_bus/operations/finalize/__init__.py +0 -3
  204. infrahub/message_bus/operations/finalize/validator.py +0 -133
  205. infrahub/message_bus/operations/requests/__init__.py +0 -9
  206. infrahub/message_bus/operations/requests/generator_definition.py +0 -140
  207. infrahub/message_bus/operations/requests/proposed_change.py +0 -629
  208. infrahub/patch/queries/consolidate_duplicated_nodes.py +0 -109
  209. /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
  210. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/LICENSE.txt +0 -0
  211. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/entry_points.txt +0 -0
@@ -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:5.20.0-community}
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"
@@ -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
- directory = Path(str(tmpdir_factory.getbasetemp().strpath))
42
- return directory
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(directory=tmp_directory, version=infrahub_version)
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/")
@@ -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,26 +0,0 @@
1
- from pydantic import Field
2
-
3
- from infrahub.context import InfrahubContext
4
- from infrahub.generators.models import ProposedChangeGeneratorDefinition
5
- from infrahub.message_bus import InfrahubMessage
6
-
7
-
8
- class CheckGeneratorRun(InfrahubMessage):
9
- """A check that runs a generator."""
10
-
11
- generator_definition: ProposedChangeGeneratorDefinition = Field(..., description="The Generator definition")
12
- generator_instance: str | None = Field(
13
- default=None, description="The id of the generator instance if it previously existed"
14
- )
15
- commit: str = Field(..., description="The commit to target")
16
- repository_id: str = Field(..., description="The unique ID of the Repository")
17
- repository_name: str = Field(..., description="The name of the Repository")
18
- repository_kind: str = Field(..., description="The kind of the Repository")
19
- branch_name: str = Field(..., description="The branch where the check is run")
20
- target_id: str = Field(..., description="The ID of the target object for this generator")
21
- target_name: str = Field(..., description="Name of the generator target")
22
- query: str = Field(..., description="The name of the query to use when collecting data")
23
- variables: dict = Field(..., description="Input variables when running the generator")
24
- validator_id: str = Field(..., description="The ID of the validator")
25
- proposed_change: str | None = Field(None, description="The unique ID of the Proposed Change")
26
- context: InfrahubContext = Field(..., description="The Infrahub context")
@@ -1,15 +0,0 @@
1
- from pydantic import Field
2
-
3
- from infrahub.context import InfrahubContext
4
- from infrahub.message_bus import InfrahubMessage
5
-
6
-
7
- class FinalizeValidatorExecution(InfrahubMessage):
8
- """Update the status of a validator after all checks have been completed."""
9
-
10
- validator_id: str = Field(..., description="The id of the validator associated with this check")
11
- validator_execution_id: str = Field(..., description="The id of current execution of the associated validator")
12
- start_time: str = Field(..., description="Start time when the message was first created")
13
- validator_type: str = Field(..., description="The type of validator to complete")
14
- context: InfrahubContext = Field(..., description="The Infrahub context")
15
- proposed_change: str = Field(..., description="The ID of the proposed change")
@@ -1,16 +0,0 @@
1
- from pydantic import ConfigDict, Field
2
-
3
- from infrahub.message_bus import InfrahubMessage
4
- from infrahub.message_bus.types import ProposedChangeBranchDiff
5
-
6
-
7
- class BaseProposedChangeWithDiffMessage(InfrahubMessage):
8
- """Sent trigger the refresh of artifacts that are impacted by the proposed change."""
9
-
10
- model_config = ConfigDict(arbitrary_types_allowed=True)
11
-
12
- proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
13
- source_branch: str = Field(..., description="The source branch of the proposed change")
14
- source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
15
- destination_branch: str = Field(..., description="The destination branch of the proposed change")
16
- branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
@@ -1,11 +0,0 @@
1
- from pydantic import Field
2
-
3
- from infrahub.context import InfrahubContext
4
-
5
- from .base_with_diff import BaseProposedChangeWithDiffMessage
6
-
7
-
8
- class RequestProposedChangeRefreshArtifacts(BaseProposedChangeWithDiffMessage):
9
- """Sent trigger the refresh of artifacts that are impacted by the proposed change."""
10
-
11
- context: InfrahubContext = Field(..., description="The context of the task")
@@ -1,20 +0,0 @@
1
- from pydantic import ConfigDict, Field
2
-
3
- from infrahub.context import InfrahubContext
4
- from infrahub.generators.models import ProposedChangeGeneratorDefinition
5
- from infrahub.message_bus import InfrahubMessage
6
- from infrahub.message_bus.types import ProposedChangeBranchDiff
7
-
8
-
9
- class RequestGeneratorDefinitionCheck(InfrahubMessage):
10
- """Sent to trigger Generators to run for a proposed change."""
11
-
12
- model_config = ConfigDict(arbitrary_types_allowed=True)
13
-
14
- generator_definition: ProposedChangeGeneratorDefinition = Field(..., description="The Generator Definition")
15
- branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
16
- proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
17
- source_branch: str = Field(..., description="The source branch")
18
- source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
19
- destination_branch: str = Field(..., description="The target branch")
20
- context: InfrahubContext = Field(..., description="The Infrahub context")
@@ -1,23 +0,0 @@
1
- import uuid
2
-
3
- from pydantic import Field
4
-
5
- from infrahub.context import InfrahubContext
6
- from infrahub.core.constants import CheckType
7
- from infrahub.message_bus import InfrahubMessage
8
-
9
-
10
- class RequestProposedChangePipeline(InfrahubMessage):
11
- """Sent request the start of a pipeline connected to a proposed change."""
12
-
13
- proposed_change: str = Field(..., description="The unique ID of the proposed change")
14
- source_branch: str = Field(..., description="The source branch of the proposed change")
15
- source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
16
- destination_branch: str = Field(..., description="The destination branch of the proposed change")
17
- check_type: CheckType = Field(
18
- default=CheckType.ALL, description="Can be used to restrict the pipeline to a specific type of job"
19
- )
20
- context: InfrahubContext = Field(..., description="The context of the task")
21
- pipeline_id: uuid.UUID = Field(
22
- default_factory=uuid.uuid4, description="The unique ID of the execution of this pipeline"
23
- )
@@ -1,3 +0,0 @@
1
- from . import generator
2
-
3
- __all__ = ["generator"]