309 def testHelloAndMessageTransmission(self):
310 """test function"""
311 monitoring_socket = self.create_socket(self.monitoring_port)
312
313
314 input_socket = self.create_socket(self.input_port)
315 self.send(input_socket, "h")
316
317
318 self.assertNothingMore(input_socket)
319 self.assertMonitoring(monitoring_socket, "input.registered_workers", 0)
320
321
322 output_socket = self.create_output_socket()
323
324
325 self.assertIsMsgType(input_socket, "c")
326 self.assertMonitoring(monitoring_socket, "input.registered_workers", 1)
327
328
329 second_input_socket = self.create_socket(self.input_port, identity="other_socket")
330 self.send(second_input_socket, "h")
331 self.assertIsMsgType(second_input_socket, "c")
332 self.assertMonitoring(monitoring_socket, "input.registered_workers", 2)
333
334
335 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
336 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
337
338
339 self.send(input_socket, "l")
340 self.assertIsMsgType(input_socket, "c")
341 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 1)
342 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
343 self.assertNothingMore(output_socket)
344
345
346 self.send(second_input_socket, "l")
347 self.assertIsMsgType(second_input_socket, "c")
348 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 2)
349 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", True)
350
351 self.get_signal(output_socket, "l")
352
353
354 self.send(input_socket, "l")
355 self.assertIsMsgType(input_socket, "c")
356 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 2)
357 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", True)
358 self.assertNothingMore(output_socket)
359
360
361 self.send(monitoring_socket, "n")
362 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
363 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
364
365
366 self.send(input_socket, "l")
367 self.assertIsMsgType(input_socket, "c")
368 self.send(second_input_socket, "l")
369 self.assertIsMsgType(second_input_socket, "c")
370
371 self.get_signal(output_socket, "l")
372
373
374 self.send(monitoring_socket, "n")
375 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
376 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
377
378
379 self.send(input_socket, "l")
380 self.assertIsMsgType(input_socket, "c")
381
382
383 self.send(second_input_socket, "d", b"other_socket")
384 self.assertIsMsgType(second_input_socket, "c")
385 self.assertMonitoring(monitoring_socket, "input.registered_workers", 1)
386
387
388 self.get_signal(output_socket, "l")
389 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 1)
390 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", True)
391
392
393 self.send(second_input_socket, "h")
394 self.assertIsMsgType(second_input_socket, "c")
395 self.send(monitoring_socket, "n")
396 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
397 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
398 self.assertMonitoring(monitoring_socket, "input.registered_workers", 2)
399
400
401 self.send(second_input_socket, "d", b"other_socket")
402 self.assertIsMsgType(second_input_socket, "c")
403 self.send(input_socket, "l")
404 self.assertIsMsgType(input_socket, "c")
405 self.assertMonitoring(monitoring_socket, "input.registered_workers", 1)
406
407 self.get_signal(output_socket, "l")
408 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 1)
409 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", True)
410
411
412 self.send(second_input_socket, "h")
413 self.assertIsMsgType(second_input_socket, "c")
414 self.send(monitoring_socket, "n")
415 self.assertMonitoring(monitoring_socket, "input.received_stop_messages", 0)
416 self.assertMonitoring(monitoring_socket, "input.all_stop_messages", False)
417 self.assertMonitoring(monitoring_socket, "input.registered_workers", 2)
418
419
420
421 self.assertMonitoring(monitoring_socket, "input.received_terminate_messages", 0)
422 self.assertMonitoring(monitoring_socket, "input.all_terminate_messages", False)
423
424
425 self.send(input_socket, "x")
426 self.assertIsMsgType(input_socket, "c")
427 self.assertMonitoring(monitoring_socket, "input.received_terminate_messages", 1)
428 self.assertMonitoring(monitoring_socket, "input.all_terminate_messages", False)
429 self.assertNothingMore(output_socket)
430
431
432 self.send(input_socket, "x")
433 self.assertIsMsgType(input_socket, "c")
434 self.assertMonitoring(monitoring_socket, "input.received_terminate_messages", 1)
435 self.assertMonitoring(monitoring_socket, "input.all_terminate_messages", False)
436 self.assertNothingMore(output_socket)
437
438
439 self.send(monitoring_socket, "n")
440 self.assertMonitoring(monitoring_socket, "input.received_terminate_messages", 0)
441 self.assertMonitoring(monitoring_socket, "input.all_terminate_messages", False)
442
443
444 self.send(input_socket, "x")
445 self.assertIsMsgType(input_socket, "c")
446 self.send(second_input_socket, "x")
447 self.assertIsMsgType(second_input_socket, "c")
448
449 self.get_signal(output_socket, "x")
450
451
452 self.assertIsDown("collector")
453
454
455