Belle II Software development
HistogramStopTestCase Class Reference
Inheritance diagram for HistogramStopTestCase:
HLTZMQTestCase

Public Member Functions

def testStopPropagation (self)
 

Static Public Attributes

HLTZMQTestCase input_port = HLTZMQTestCase.get_free_port()
 input_port
 
HLTZMQTestCase monitoring_port = HLTZMQTestCase.get_free_port()
 monitoring_port
 
dict needed_programs
 needed_programs
 
open histogram_data = open(basf2.find_file("daq/hbasf2/tests/histos.raw"), "br").read()
 histogram_data
 
event_data
 event_data
 

Detailed Description

Test case

Definition at line 215 of file test_histogram.py.

Member Function Documentation

◆ testStopPropagation()

def testStopPropagation (   self)
test function

Definition at line 247 of file test_histogram.py.

247 def testStopPropagation(self):
248 """test function"""
249 monitoring_socket = self.create_socket(self.monitoring_port)
250
251 input_socket = self.create_socket(self.input_port)
252 self.send(input_socket, "h")
253 self.assertIsMsgType(input_socket, "c")
254
255 second_input_socket = self.create_socket(self.input_port, identity="other_socket")
256 self.send(second_input_socket, "h")
257 self.assertIsMsgType(second_input_socket, "c")
258
259 # At the beginning, everything should be at normal state
260 self.assertMonitoring(monitoring_socket, "input.registered_workers", 2)
261 self.assertNotHasOutputFile("outputFile.root", timeout=1)
262
263 # So far no stop messages should be there
264 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
265 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
266
267 # the first stop message should not trigger a transmission
268 self.send(input_socket, "l")
269 self.assertIsMsgType(input_socket, "c")
270 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 1)
271 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
272 self.assertNotHasOutputFile("outputFile.root", timeout=1)
273
274 # The second stop message should also not, as there are no histograms so far
275 self.send(second_input_socket, "l")
276 self.assertIsMsgType(second_input_socket, "c")
277 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 2)
278 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", True)
279 self.assertNotHasOutputFile("outputFile.root", timeout=1)
280
281 # Reset everything
282 self.send(monitoring_socket, "n")
283 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
284 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
285
286 # Now lets send some events
287 self.send(input_socket, "v", self.histogram_data, self.event_data)
288 self.assertIsMsgType(input_socket, "c")
289
290 self.send(input_socket, "v", self.histogram_data, self.event_data)
291 self.assertIsMsgType(input_socket, "c")
292
293 self.send(second_input_socket, "v", self.histogram_data, self.event_data)
294 self.assertIsMsgType(second_input_socket, "c")
295
296 self.send(input_socket, "v", self.histogram_data, self.event_data)
297 self.assertIsMsgType(input_socket, "c")
298
299 self.send(second_input_socket, "v", self.histogram_data, self.event_data)
300 self.assertIsMsgType(second_input_socket, "c")
301
302 self.send(second_input_socket, "v", self.histogram_data, self.event_data)
303 self.assertIsMsgType(second_input_socket, "c")
304
305 # This should not be enough to trigger a merge
306 self.assertMonitoring(monitoring_socket, "input.received_events", 6)
307 self.assertNotHasOutputFile("outputFile.root", timeout=1)
308
309 # But if we again send the stop messages
310 self.send(input_socket, "l")
311 self.assertIsMsgType(input_socket, "c")
312 self.send(second_input_socket, "l")
313 self.assertIsMsgType(second_input_socket, "c")
314
315 # .. it should have merged it. We expect 2 entries, as we have 2 clients (no matter how often they sent)
316 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 2)
317 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", True)
318 self.assertHasOutputFile("outputFile.root", unlink=False)
319 self.assertTrue(check_histogram_output("outputFile.root", 2))
320
321 # Now send a terminate message
322 self.send(input_socket, "x")
323 self.assertIsMsgType(input_socket, "c")
324 self.send(second_input_socket, "x")
325 self.assertIsMsgType(second_input_socket, "c")
326
327 # There should be no merge happening, as the files are already written
328 self.assertNotHasOutputFile("outputFile.root")
329
330 self.assertIsDown("histoserver")
331
332

Member Data Documentation

◆ event_data

b event_data
static
Initial value:
= b"""{
"_typename" : "Belle2::EventMetaData",
"fUniqueID" : 0,
"fBits" : 33554432,
"m_event" : 1,
"m_run" : 1,
"m_subrun" : 0,
"m_experiment" : 1,
"m_production" : 0,
"m_time" : 0,
"m_parentLfn" : "",
"m_generatedWeight" : 1,
"m_errorFlag" : 0
}"""

event_data

Definition at line 232 of file test_histogram.py.

◆ histogram_data

open histogram_data = open(basf2.find_file("daq/hbasf2/tests/histos.raw"), "br").read()
static

histogram_data

Definition at line 230 of file test_histogram.py.

◆ input_port

input_port

Definition at line 218 of file test_histogram.py.

◆ monitoring_port

HLTZMQTestCase monitoring_port = HLTZMQTestCase.get_free_port()
static

monitoring_port

Definition at line 220 of file test_histogram.py.

◆ needed_programs

dict needed_programs
static
Initial value:
= {"histoserver": ["b2hlt_finalhistoserver", "--input", f"tcp://*:{input_port}",
"--rootFileName", "outputFile.root",
"--timeout", "0", # we remove the timeout on purpose
"--monitor", f"tcp://*:{monitoring_port}"],
}

needed_programs

Definition at line 223 of file test_histogram.py.


The documentation for this class was generated from the following file: