From b3569508c8edcc1aa2b1126481ab60d9133f0189 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Thu, 16 Jan 2025 13:33:21 +0100 Subject: [PATCH] Nightly tests adjust run test_memory_leak in test move high_link to nightly (#6701) - `aiida_computer_ssh` fixture set safe_interval -> 1.0s - The `test_memary_leak` test for SSH timeout because the long intervals of 4 steps. - https://github.com/aiidateam/aiida-core/pull/6701/commits/25ccef9608b7e2dffe0635bffa6388f6934dea82 test whether move high_link to nightly will decrease coverage, as suggested in https://github.com/aiidateam/aiida-core/issues/6526 I make safe_interval short for pytest ssh computer fixture, so it can used for running memory leak test not just in nightly. --- src/aiida/tools/pytest_fixtures/orm.py | 1 + tests/engine/test_memory_leaks.py | 1 - tests/tools/archive/orm/test_links.py | 29 +++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/aiida/tools/pytest_fixtures/orm.py b/src/aiida/tools/pytest_fixtures/orm.py index 0ed7ea18d7..52fd0eb322 100644 --- a/src/aiida/tools/pytest_fixtures/orm.py +++ b/src/aiida/tools/pytest_fixtures/orm.py @@ -183,6 +183,7 @@ def factory(label: str | None = None, configure: bool = True) -> 'Computer': computer.configure( key_filename=str(ssh_key), key_policy='AutoAddPolicy', + safe_interval=1.0, ) return computer diff --git a/tests/engine/test_memory_leaks.py b/tests/engine/test_memory_leaks.py index e59ff98366..6972b9e0db 100644 --- a/tests/engine/test_memory_leaks.py +++ b/tests/engine/test_memory_leaks.py @@ -65,7 +65,6 @@ def test_leak_local_calcjob(aiida_code_installed): @pytest.mark.skipif(sys.version_info >= (3, 12), reason='Garbage collecting hangs on Python 3.12') -@pytest.mark.nightly @pytest.mark.usefixtures('aiida_profile', 'check_memory_leaks') def test_leak_ssh_calcjob(aiida_computer_ssh): """Test whether running a CalcJob over SSH leaks memory. diff --git a/tests/tools/archive/orm/test_links.py b/tests/tools/archive/orm/test_links.py index ee7392f7b2..5ddecc26d5 100644 --- a/tests/tools/archive/orm/test_links.py +++ b/tests/tools/archive/orm/test_links.py @@ -8,6 +8,8 @@ ########################################################################### """orm links tests for the export and import routines""" +import pytest + from aiida import orm from aiida.common.links import LinkType from aiida.orm.entities import EntityTypes @@ -15,7 +17,7 @@ from tests.tools.archive.utils import get_all_node_links -def test_links_to_unknown_nodes(tmp_path, aiida_profile): +def test_links_to_unknown_nodes(tmp_path, aiida_profile_clean): """Test importing of nodes, that have links to unknown nodes.""" # store a node node = orm.Data() @@ -46,7 +48,7 @@ def test_links_to_unknown_nodes(tmp_path, aiida_profile): with ArchiveFormatSqlZip().open(filename, 'r') as archive: assert archive.querybuilder().append(entity_type='link').count() == 1 - aiida_profile.reset_storage() + aiida_profile_clean.reset_storage() # since the query builder only looks for links between known nodes, # this should not import the erroneous link @@ -262,7 +264,8 @@ def test_complex_workflow_graph_links(aiida_profile_clean, tmp_path, aiida_local assert set(export_set) == set(import_set) -def test_complex_workflow_graph_export_sets(aiida_profile, tmp_path, aiida_localhost_factory): +@pytest.mark.nightly +def test_complex_workflow_graph_export_sets(aiida_profile_clean, tmp_path, aiida_localhost_factory): """Test ex-/import of individual nodes in complex graph""" for export_conf in range(0, 9): _, (export_node, export_target) = construct_complex_graph(aiida_localhost_factory, export_conf) @@ -272,7 +275,7 @@ def test_complex_workflow_graph_export_sets(aiida_profile, tmp_path, aiida_local create_archive([export_node], filename=export_file, overwrite=True) export_node_str = str(export_node) - aiida_profile.reset_storage() + aiida_profile_clean.reset_storage() import_archive(export_file) @@ -296,7 +299,8 @@ def test_complex_workflow_graph_export_sets(aiida_profile, tmp_path, aiida_local ) -def test_high_level_workflow_links(aiida_profile, tmp_path, aiida_localhost_factory): +@pytest.mark.nightly +def test_high_level_workflow_links(aiida_profile_clean, tmp_path, aiida_localhost_factory): """This test checks that all the needed links are correctly exported and imported. INPUT_CALC, INPUT_WORK, CALL_CALC, CALL_WORK, CREATE, and RETURN links connecting Data nodes and high-level Calculation and Workflow nodes: @@ -318,7 +322,7 @@ def test_high_level_workflow_links(aiida_profile, tmp_path, aiida_localhost_fact for calcs in high_level_calc_nodes: for works in high_level_work_nodes: - aiida_profile.reset_storage() + aiida_profile_clean.reset_storage() graph_nodes, _ = construct_complex_graph(aiida_localhost_factory, calc_nodes=calcs, work_nodes=works) @@ -350,7 +354,7 @@ def test_high_level_workflow_links(aiida_profile, tmp_path, aiida_localhost_fact export_file = tmp_path.joinpath('export.aiida') create_archive(graph_nodes, filename=export_file, overwrite=True) - aiida_profile.reset_storage() + aiida_profile_clean.reset_storage() import_archive(export_file) import_links = get_all_node_links() @@ -450,7 +454,8 @@ def link_flags_export_helper(name, all_nodes, tmp_path, nodes_to_export, flags, return ret -def test_link_flags(aiida_profile, tmp_path, aiida_localhost_factory): +@pytest.mark.nightly +def test_link_flags(aiida_profile_clean, tmp_path, aiida_localhost_factory): """Verify all link follow flags are working as intended. Graph (from ``construct_complex_graph()``):: @@ -584,10 +589,10 @@ def test_link_flags(aiida_profile, tmp_path, aiida_localhost_factory): ), ) - link_flags_import_helper(input_links_forward, aiida_profile.reset_storage) - link_flags_import_helper(create_return_links_backward, aiida_profile.reset_storage) - link_flags_import_helper(call_links_backward_calc1, aiida_profile.reset_storage) - link_flags_import_helper(call_links_backward_work2, aiida_profile.reset_storage) + link_flags_import_helper(input_links_forward, aiida_profile_clean.reset_storage) + link_flags_import_helper(create_return_links_backward, aiida_profile_clean.reset_storage) + link_flags_import_helper(call_links_backward_calc1, aiida_profile_clean.reset_storage) + link_flags_import_helper(call_links_backward_work2, aiida_profile_clean.reset_storage) def test_double_return_links_for_workflows(tmp_path, aiida_profile_clean):