Skip to content

Commit

Permalink
Nightly tests adjust run test_memory_leak in test move high_link to n…
Browse files Browse the repository at this point in the history
…ightly (#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.
- 25ccef9 test whether move high_link to nightly will decrease coverage, as suggested in #6526

I make safe_interval short for pytest ssh computer fixture, so it can used for running memory leak test not just in nightly.
  • Loading branch information
unkcpz authored Jan 16, 2025
1 parent 7a460c0 commit b356950
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/aiida/tools/pytest_fixtures/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/engine/test_memory_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 17 additions & 12 deletions tests/tools/archive/orm/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
###########################################################################
"""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
from aiida.tools.archive import ArchiveFormatSqlZip, create_archive, import_archive
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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()``)::
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b356950

Please sign in to comment.