-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmultiple_data_writers_test.py
More file actions
156 lines (135 loc) · 6.07 KB
/
Copy pathmultiple_data_writers_test.py
File metadata and controls
156 lines (135 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import pytest
import os
import re
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
import integrationtest.utility_functions as utility_functions
from integrationtest.get_pytest_tmpdir import get_pytest_tmpdir
from integrationtest.verbosity_helper import IntegtestVerbosityLevels
import functools
print = functools.partial(print, flush=True) # always flush print() output
pytest_plugins = "integrationtest.integrationtest_drunc"
# Values that help determine the running conditions
number_of_data_producers = 2
number_of_readout_apps = 3
# Default values for validation parameters
check_for_logfile_errors = True
wibeth_frag_params = {
"fragment_type_description": "WIBEth",
"fragment_type": "WIBEth",
"expected_fragment_count": (number_of_data_producers * number_of_readout_apps),
"min_size_bytes": 187272,
"max_size_bytes": 194472,
}
# 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)
triggercandidate_frag_params = {
"fragment_type_description": "Trigger Candidate",
"fragment_type": "Trigger_Candidate",
"expected_fragment_count": 1,
"min_size_bytes": 128,
"max_size_bytes": 128,
}
triggeractivity_frag_params = {
"fragment_type_description": "Trigger Activity",
"fragment_type": "Trigger_Activity",
"expected_fragment_count": 0,
"min_size_bytes": 72,
"max_size_bytes": 632,
}
triggerprimitive_frag_params = {
"fragment_type_description": "Trigger Primitive",
"fragment_type": "Trigger_Primitive",
"expected_fragment_count": 0,
"min_size_bytes": 72,
"max_size_bytes": 1032,
}
hsi_frag_params = {
"fragment_type_description": "HSI",
"fragment_type": "Hardware_Signal",
"expected_fragment_count": 1,
"min_size_bytes": 100,
"max_size_bytes": 100,
}
ignored_logfile_problems = {
"-controller": [
"Worker with pid \\d+ was terminated due to signal 1",
],
"connectivity-service": [
"errorlog: -",
],
}
# Determine if the conditions are right for these tests
resource_validator = resource_validation.ResourceValidator()
resource_validator.cpu_count_needs(9, 18) # total number of data sources (6) plus three more for everything else
resource_validator.free_memory_needs(10, 20) # 25% more than what we observe being used ('free -h')
resource_validator.total_memory_needs() # no specific request, but it's useful to see how much is available
actual_output_path = get_pytest_tmpdir()
resource_validator.free_disk_space_needs(actual_output_path, 1) # what we observe
conf_dict = data_classes.integtest_params_for_generated_dunedaq_config()
conf_dict.object_databases = ["config/daqsystemtest/integrationtest-objects.data.xml"]
conf_dict.dro_map_config.n_streams = number_of_data_producers
conf_dict.dro_map_config.n_apps = number_of_readout_apps
conf_dict.op_env = "integtest"
conf_dict.config_session_name= "multidatawriter"
conf_dict.n_data_writers = 3
utility_functions.enable_fake_hsi_trigger(conf_dict, trigger_rate=10.0,
readout_window_before_ticks=52000, readout_window_after_ticks=1000)
conf_dict.config_substitutions.append(
data_classes.attribute_substitution(
obj_class="QueueDescriptor",
obj_id="trigger-records",
updates={"queue_type": "kFollyMPMCQueue"},
)
)
confgen_arguments = {
"WIBEth_System": conf_dict,
}
# The commands to run in dunerc, as a list
dunerc_command_list = (
"boot conf wait 5".split()
+ "start --run-number 101 wait 1 enable-triggers wait 30".split()
+ "disable-triggers wait 2 drain-dataflow wait 2 stop-trigger-sources stop ".split()
+ "start --run-number 102 wait 1 enable-triggers wait 30".split()
+ "disable-triggers wait 2 drain-dataflow wait 2 stop-trigger-sources stop ".split()
+ " scrap terminate".split()
)
# The tests themselves
def test_dunerc_success(run_dunerc, caplog):
# checks for run control success, problems during pytest setup, etc.
utility_functions.basic_checks(run_dunerc, caplog, print_test_name=False)
def test_log_files(run_dunerc):
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(
run_dunerc.log_files, True, True, ignored_logfile_problems,
verbosity_helper=run_dunerc.verbosity_helper
)
def test_data_files(run_dunerc):
fragment_check_list = [triggercandidate_frag_params, hsi_frag_params, wibeth_frag_params]
fragment_check_list.append(triggerprimitive_frag_params)
fragment_check_list.append(triggeractivity_frag_params)
# Run some tests on the output data file
all_ok = len(run_dunerc.data_files) == 6 # three for each run
#print("") # Clear potential dot from pytest
if all_ok:
if run_dunerc.verbosity_helper.compare_level(IntegtestVerbosityLevels.drunc_transitions):
print("\N{WHITE HEAVY CHECK MARK} The correct number of raw data files was found (6)")
else:
print(f"\N{POLICE CARS REVOLVING LIGHT} An incorrect number of raw data files was found, expected 6, found {len(run_dunerc.data_files)} \N{POLICE CARS REVOLVING LIGHT}")
for idx in range(len(run_dunerc.data_files)):
data_file = data_file_checks.DataFile(run_dunerc.data_files[idx], run_dunerc.verbosity_helper)
all_ok &= data_file_checks.sanity_check(data_file)
all_ok &= data_file_checks.check_file_attributes(data_file)
for jdx in range(len(fragment_check_list)):
all_ok &= data_file_checks.check_fragment_count(
data_file, fragment_check_list[jdx]
)
all_ok &= data_file_checks.check_fragment_sizes(
data_file, fragment_check_list[jdx]
)
assert all_ok, "\N{POLICE CARS REVOLVING LIGHT} One or more raw data file checks failed! \N{POLICE CARS REVOLVING LIGHT}"