-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # backend/infrahub/core/query/node.py
- Loading branch information
Showing
16 changed files
with
192 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
# Corresponds to infrahub.graphql.manager.OrderInput | ||
class OrderModel(BaseModel): | ||
disable: bool | None = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import inspect | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from infrahub.core import registry | ||
from infrahub.core.query.node import NodeGetListQuery | ||
from infrahub.database.constants import Neo4jRuntime | ||
from infrahub.log import get_logger | ||
from tests.helpers.constants import NEO4J_ENTERPRISE_IMAGE | ||
from tests.helpers.query_benchmark.benchmark_config import BenchmarkConfig | ||
from tests.helpers.query_benchmark.car_person_generators import ( | ||
CarGenerator, | ||
) | ||
from tests.helpers.query_benchmark.data_generator import load_data_and_profile | ||
from tests.query_benchmark.conftest import RESULTS_FOLDER | ||
from tests.query_benchmark.utils import start_db_and_create_default_branch | ||
|
||
log = get_logger() | ||
|
||
|
||
@pytest.mark.timeout(36000) # 10 hours | ||
@pytest.mark.parametrize( | ||
"benchmark_config, ordering", | ||
[ | ||
( | ||
BenchmarkConfig( | ||
neo4j_runtime=Neo4jRuntime.PARALLEL, neo4j_image=NEO4J_ENTERPRISE_IMAGE, load_db_indexes=False | ||
), | ||
False, | ||
), | ||
( | ||
BenchmarkConfig( | ||
neo4j_runtime=Neo4jRuntime.PARALLEL, neo4j_image=NEO4J_ENTERPRISE_IMAGE, load_db_indexes=False | ||
), | ||
True, | ||
), | ||
], | ||
) | ||
async def test_node_get_list_ordering( | ||
benchmark_config, car_person_schema_root, graph_generator, increase_query_size_limit, ordering | ||
): | ||
# Initialization | ||
db_profiling_queries, default_branch = await start_db_and_create_default_branch( | ||
neo4j_image=benchmark_config.neo4j_image, | ||
load_indexes=benchmark_config.load_db_indexes, | ||
) | ||
registry.schema.register_schema(schema=car_person_schema_root, branch=default_branch.name) | ||
|
||
# Build function to profile | ||
async def init_and_execute(): | ||
car_node_schema = registry.get_node_schema(name="TestCar", branch=default_branch.name) | ||
query = await NodeGetListQuery.init( | ||
db=db_profiling_queries, | ||
schema=car_node_schema, | ||
branch=default_branch, | ||
ordering=ordering, | ||
) | ||
res = await query.execute(db=db_profiling_queries) | ||
print(f"{len(res.get_node_ids())=}") | ||
return res | ||
|
||
nb_cars = 10_000 | ||
cars_generator = CarGenerator(db=db_profiling_queries) | ||
test_name = inspect.currentframe().f_code.co_name | ||
module_name = Path(__file__).stem | ||
graph_output_location = RESULTS_FOLDER / module_name / test_name | ||
|
||
test_label = str(benchmark_config) + "_ordering_" + str(ordering) | ||
|
||
await load_data_and_profile( | ||
data_generator=cars_generator, | ||
func_call=init_and_execute, | ||
profile_frequency=1_000, | ||
nb_elements=nb_cars, | ||
graphs_output_location=graph_output_location, | ||
test_label=test_label, | ||
graph_generator=graph_generator, | ||
) |
Oops, something went wrong.