Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 45 additions & 26 deletions integtest/hdf5_compression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import integrationtest.data_file_checks as data_file_checks
import integrationtest.log_file_checks as log_file_checks
import integrationtest.data_classes as data_classes
import integrationtest.resource_validation as resource_validation

pytest_plugins = "integrationtest.integrationtest_drunc"

Expand Down Expand Up @@ -57,24 +58,6 @@
# "default": {"min_size_bytes": 80000, "max_size_bytes": 120000} }
}

#wibeth_frag_params = {
# "fragment_type_description": "WIBEth",
# "fragment_type": "WIBEth",
# "expected_fragment_count": (number_of_data_producers * number_of_readout_apps),
# "min_size_bytes": 7272,
# "max_size_bytes": 194472,
#}
#wibeth_tpset_params = {
# "fragment_type_description": "TP Stream",
# "fragment_type": "Trigger_Primitive",
# "expected_fragment_count": number_of_readout_apps * 3,
# "frag_counts_by_record_ordinal": {"first": {"min_count": 1, "max_count": number_of_readout_apps * 3},
# "default": {"min_count": number_of_readout_apps * 3, "max_count": number_of_readout_apps * 3} },
# "min_size_bytes": 0, # not checked
# "max_size_bytes": 0, # not checked
# "debug_mask": 0x0,
#}

# sizes: 128 is for one TC with zero TAs inside it (72+56)
# 208 is for one TC with one TA inside it (72+56+80)
# 264 is for two TCs with one TA in one of them (72+56+80+56)
Expand Down Expand Up @@ -123,6 +106,17 @@
],
}

# Determine if the conditions are right for these tests
resval = resource_validation.ResourceValidator()
resval.require_cpu_count(15) # total number of data sources (6RU+3TP) plus several more for everything else
resval.require_free_memory_gb(10) # the maximum amount that we observe being used ('free -h')
resval.require_total_memory_gb(20) # double what we need; trying to be kind to others
actual_output_path = "/tmp"
resval.require_free_disk_space_gb(actual_output_path, 5) # what we actually use (3) plus margin
resval.require_total_disk_space_gb(actual_output_path, 10) # factor of two to reserve some for others
resval_debug_string = resval.get_debug_string()
print(f"{resval_debug_string}")

# The next three variable declarations *must* be present as globals in the test
# file. They're read by the "fixtures" in conftest.py to determine how
# to run the config generation and nanorc
Expand Down Expand Up @@ -217,7 +211,7 @@
)
conf_dict.config_substitutions.append(
data_classes.attribute_substitution(
obj_class="LatencyBuffer", updates={"size": 5592000}
obj_class="LatencyBuffer", updates={"size": 200000}
)
)
# 03-Jun-2025, KAB
Expand All @@ -238,19 +232,28 @@
}

# The commands to run in nanorc, as a list
nanorc_command_list = (
"boot conf wait 5".split()
+ "start --run-number 101 wait 1 enable-triggers wait 100".split()
+ "disable-triggers wait 2 drain-dataflow wait 2 stop-trigger-sources stop ".split()
+ "start --run-number 102 wait 1 enable-triggers wait 100".split()
+ "disable-triggers wait 2 drain-dataflow wait 2 stop-trigger-sources stop ".split()
+ " scrap terminate".split()
if resval.this_computer_has_sufficient_resources:
nanorc_command_list = (
"boot conf wait 5".split()
+ "start --run-number 101 wait 1 enable-triggers wait 100".split()
+ "disable-triggers wait 2 drain-dataflow wait 2 stop-trigger-sources stop ".split()
+ "start --run-number 102 wait 1 enable-triggers wait 100".split()
+ "disable-triggers wait 2 drain-dataflow wait 2 stop-trigger-sources stop ".split()
+ " scrap terminate".split()
)
else:
nanorc_command_list = ["wait", "1"]

# The tests themselves


def test_nanorc_success(run_nanorc):
if not resval.this_computer_has_sufficient_resources:
resval_report_string = resval.get_insufficient_resources_report()
print(f"{resval_report_string}")
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

current_test = os.environ.get("PYTEST_CURRENT_TEST")
match_obj = re.search(r".*\[(.+)-run_nanorc0\].*", current_test)
if match_obj:
Expand All @@ -264,6 +267,10 @@ def test_nanorc_success(run_nanorc):


def test_log_files(run_nanorc):
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

if check_for_logfile_errors:
# Check that there are no warnings or errors in the log files
assert log_file_checks.logs_are_error_free(
Expand All @@ -272,6 +279,10 @@ def test_log_files(run_nanorc):


def test_data_files(run_nanorc):
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

fragment_check_list = [triggercandidate_frag_params, hsi_frag_params, daphne_frag_params]
fragment_check_list.append(daphne_triggerprimitive_frag_params)
fragment_check_list.append(triggeractivity_frag_params)
Expand Down Expand Up @@ -299,6 +310,10 @@ def test_data_files(run_nanorc):


def test_tpstream_files(run_nanorc):
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

tpstream_files = run_nanorc.tpset_files
fragment_check_list = [daphne_tpset_params]

Expand All @@ -320,6 +335,10 @@ def test_tpstream_files(run_nanorc):


def test_cleanup(run_nanorc):
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

pathlist_string = ""
filelist_string = ""
for data_file in run_nanorc.data_files:
Expand Down
67 changes: 30 additions & 37 deletions integtest/insufficient_disk_space_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest
import os
import re
import shutil
import urllib.request

import integrationtest.data_file_checks as data_file_checks
import integrationtest.log_file_checks as log_file_checks
import integrationtest.data_classes as data_classes
import integrationtest.resource_validation as resource_validation

pytest_plugins = "integrationtest.integrationtest_drunc"

Expand Down Expand Up @@ -67,20 +67,16 @@
}

# Determine if the conditions are right for these tests
sufficient_disk_space = True
resval = resource_validation.ResourceValidator()
resval.require_cpu_count(45) # total number of data sources plus 50% more for everything else
resval.require_free_memory_gb(35) # the maximum amount that we observe being used ('free -h')
resval.require_total_memory_gb(70) # double what we need; trying to be kind to others
actual_output_path = output_path_parameter
if output_path_parameter == ".":
actual_output_path = "/tmp"
disk_space = shutil.disk_usage(actual_output_path)
total_disk_space_gb = disk_space.total / (1024 * 1024 * 1024)
free_disk_space_gb = disk_space.free / (1024 * 1024 * 1024)
print(
f"DEBUG: Space on disk for output path \"{actual_output_path}\": total = {total_disk_space_gb} GB and free = {free_disk_space_gb} GB."
)
if (
free_disk_space_gb < minimum_free_disk_space_gb
):
sufficient_disk_space = False
resval.require_free_disk_space_gb(actual_output_path, minimum_free_disk_space_gb)
resval_debug_string = resval.get_debug_string()
print(f"{resval_debug_string}")

# We simulate a nearly-full output disk by setting the free-space-safety-factor
# that the data writer uses to a custom value, based on the free space on disk.
Expand All @@ -89,7 +85,7 @@
# the disk is full when there is still ~< 10 GB of free space. And, having a
# 1 GB size for the TRs means that we will write approximately
# desired_free_disk_space_gb TriggerRecords before appearing to run out of space.
free_space_safety_factor = int(free_disk_space_gb - desired_size_of_output_disk_gb)
free_space_safety_factor = int(resval.free_disk_space_gb - desired_size_of_output_disk_gb)

# The next three variable declarations *must* be present as globals in the test
# file. They're read by the "fixtures" in conftest.py to determine how
Expand Down Expand Up @@ -137,12 +133,17 @@
obj_class="DFOConf", updates={"busy_threshold": 1, "free_threshold": 0}
)
)
conf_dict.config_substitutions.append(
data_classes.attribute_substitution(
obj_class="LatencyBuffer", updates={"size": 200000}
)
)

confgen_arguments = {
"Base_System": conf_dict,
}
# The commands to run in nanorc, as a list
if sufficient_disk_space:
if resval.this_computer_has_sufficient_resources:
nanorc_command_list = (
"boot conf wait 5".split()
+ "start --run-number 101 wait 1 enable-triggers wait ".split()
Expand All @@ -157,16 +158,17 @@
+ " scrap terminate".split()
)
else:
nanorc_command_list = ["boot", "terminate"]
nanorc_command_list = ["wait", "1"]

# The tests themselves


def test_nanorc_success(run_nanorc):
if not sufficient_disk_space:
pytest.skip(
f"The raw data output path ({actual_output_path}) does not have enough space to run this test."
)
if not resval.this_computer_has_sufficient_resources:
resval_report_string = resval.get_insufficient_resources_report()
print(f"{resval_report_string}")
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

current_test = os.environ.get("PYTEST_CURRENT_TEST")
match_obj = re.search(r".*\[(.+)-run_nanorc0\].*", current_test)
Expand All @@ -181,10 +183,9 @@ def test_nanorc_success(run_nanorc):


def test_log_files(run_nanorc):
if not sufficient_disk_space:
pytest.skip(
f"The raw data output path ({actual_output_path}) does not have enough space to run this test."
)
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

if check_for_logfile_errors:
# Check that there are no warnings or errors in the log files
Expand All @@ -198,16 +199,9 @@ def test_log_files(run_nanorc):


def test_data_files(run_nanorc):
if not sufficient_disk_space:
print(
f"The raw data output path ({actual_output_path}) does not have enough space to run this test."
)
print(
f" (Free space is {free_disk_space_gb} GB and require space is {minimum_free_disk_space_gb} GB.)"
)
pytest.skip(
f"The raw data output path ({actual_output_path}) does not have enough space to run this test."
)
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

local_expected_event_count = expected_event_count
local_event_count_tolerance = expected_event_count_tolerance
Expand Down Expand Up @@ -242,10 +236,9 @@ def test_data_files(run_nanorc):


def test_cleanup(run_nanorc):
if not sufficient_disk_space:
pytest.skip(
f"The raw data output path ({actual_output_path}) does not have enough space to run this test."
)
if not resval.this_computer_has_sufficient_resources:
resval_summary_string = resval.get_insufficient_resources_summary()
pytest.skip(f"{resval_summary_string}")

pathlist_string = ""
filelist_string = ""
Expand Down
Loading