def test_multiple_subscriptions(endpoint, evt_man): """Test event emission for multiple subscriptions of the same type.""" msg = events.createReadEventSubscriptionMsg(1, 0, 0, 50) subscribe(endpoint, evt_man, 1, msg) msg = events.createReadEventSubscriptionMsg(2, 0, 0, 20) subscribe(endpoint, evt_man, 2, msg) msg = events.createReadEventSubscriptionMsg(3, 0, 0, 5) subscribe(endpoint, evt_man, 3, msg) seq_num = evt_man.emitReadEvent(0, 5, 'fileUuid') msg = events.createReadEventMsg(1, 'fileUuid', [(0, 5)], seq_num) endpoint.wait_for_specific_messages(msg) msg = events.createServerSubscriptionCancellationMsg(3, 0, 0) unsubscribe(endpoint, evt_man, 3, msg) seq_num = evt_man.emitReadEvent(0, 20, 'fileUuid') msg = events.createReadEventMsg(1, 'fileUuid', [(0, 20)], seq_num) endpoint.wait_for_specific_messages(msg) msg = events.createServerSubscriptionCancellationMsg(2, 0, 1) unsubscribe(endpoint, evt_man, 2, msg) seq_num = evt_man.emitReadEvent(0, 50, 'fileUuid') msg = events.createReadEventMsg(1, 'fileUuid', [(0, 50)], seq_num) endpoint.wait_for_specific_messages(msg) msg = events.createServerSubscriptionCancellationMsg(1, 0, 2) unsubscribe(endpoint, evt_man, 1, msg) seq_num = evt_man.emitReadEvent(0, 10, 'fileUuid') msg = events.createReadEventMsg(1, 'fileUuid', [(0, 10)], seq_num) with pytest.raises(Exception): endpoint.wait_for_specific_messages(msg, timeout_sec=1)
def test_different_subscriptions(endpoint, evt_man): """Test event emission for multiple subscriptions of a different type.""" msg = events.createReadEventSubscriptionMsg(1, 1, 0, 0) subscribe(endpoint, evt_man, 1, msg) msg = events.createWriteEventSubscriptionMsg(2, 1, 0, 0) subscribe(endpoint, evt_man, 2, msg) seq_num = evt_man.emitReadEvent(0, 10, 'fileUuid') msg = events.createReadEventMsg(1, 'fileUuid', [(0, 10)], seq_num) endpoint.wait_for_specific_messages(msg) msg = events.createServerSubscriptionCancellationMsg(1, 0, 0) unsubscribe(endpoint, evt_man, 1, msg) seq_num = evt_man.emitWriteEvent(0, 10, 'fileUuid') msg = events.createWriteEventMsg(1, 'fileUuid', 0, [(0, 10)], seq_num) endpoint.wait_for_specific_messages(msg) seq_num = evt_man.emitTruncateEvent(0, 'fileUuid') msg = events.createTruncateEventMsg(1, 'fileUuid', 0, seq_num) endpoint.wait_for_specific_messages(msg) msg = events.createServerSubscriptionCancellationMsg(2, 1, 0) unsubscribe(endpoint, evt_man, 2, msg) seq_num = evt_man.emitTruncateEvent(0, 'fileUuid') msg = events.createTruncateEventMsg(1, 'fileUuid', 0, seq_num) with pytest.raises(Exception): endpoint.wait_for_specific_messages(msg, timeout_sec=1)
def test_write_read_truncate_event_aggregation(result, size_thr, cycle_num, endpoint, evt_man): """Test aggregation of write, read and truncate events.""" evt_size = int(math.ceil(float(size_thr) / cycle_num)) msg = events.createReadEventSubscriptionMsg(1, 0, 0, size_thr) subscribe(endpoint, evt_man, 1, msg) msg = events.createWriteEventSubscriptionMsg(2, 0, 0, size_thr) subscribe(endpoint, evt_man, 2, msg) emit_time = Duration() for i in xrange(cycle_num - 1): with measure(emit_time): evt_man.emitWriteEvent(i * evt_size, evt_size, 'fileUuid') evt_man.emitReadEvent(i * evt_size, evt_size, 'fileUuid') evt_man.emitTruncateEvent((i + 1) * evt_size, 'fileUuid') with measure(emit_time): evt_man.emitReadEvent((cycle_num - 1) * evt_size, evt_size, 'fileUuid') msg = events.createReadEventMsg(cycle_num, 'fileUuid', [(0, cycle_num * evt_size)], 0) endpoint.wait_for_specific_messages(msg, timeout_sec=30) with measure(emit_time): evt_man.emitWriteEvent((cycle_num - 1) * evt_size, evt_size, 'fileUuid') msg = events.createWriteEventMsg(2 * cycle_num - 1, 'fileUuid', cycle_num * evt_size, [(0, cycle_num * evt_size)], 0) endpoint.wait_for_specific_messages(msg, timeout_sec=30) result.set([emit_time_param(emit_time.ms())])
def test_events_emission_when_size_threshold_exceeded(result, size_thr, evt_num, evt_size, endpoint, evt_man): """Test event emission for subscription with size threshold set.""" ctr_thr = int(math.ceil(float(size_thr) / evt_size)) msg = events.createReadEventSubscriptionMsg(1, 0, 0, size_thr) subscribe(endpoint, evt_man, 1, msg) emit_time = Duration() for i in xrange(evt_num): with measure(emit_time): evt_man.emitReadEvent(i * evt_size, evt_size, 'fileUuid') recv_time = Duration() for i in xrange(evt_num * evt_size / size_thr): msg = events.createReadEventMsg(ctr_thr, 'fileUuid', [ (i * ctr_thr * evt_size, ctr_thr * evt_size)], i) with measure(recv_time): endpoint.wait_for_specific_messages(msg) result.set([ emit_time_param(emit_time.ms()), recv_time_param(recv_time.ms()), evtps_param(evt_num, emit_time.us() + recv_time.us()) ])
def test_events_emission_when_time_threshold_exceeded(endpoint, evt_man): """Test event emission for subscription with time threshold set.""" msg = events.createReadEventSubscriptionMsg(1, 0, 100, 0) subscribe(endpoint, evt_man, 1, msg) evt_man.emitReadEvent(0, 10, 'fileUuid') msg = events.createReadEventMsg(1, 'fileUuid', [(0, 10)], 0) endpoint.wait_for_specific_messages(msg)