Exemplo n.º 1
0
def composite_two_normal_event_streams(draw):
    input_a = draw(some_events(max_size=MAX_EVENTS_SIZE // 2))
    input_b = draw(some_events(max_size=MAX_EVENTS_SIZE // 2))
    stream_a = ListEventStream(input_a)
    stream_b = ListEventStream(input_b)
    stream = CompositeEventStream(stream_a, stream_b)
    events = draw(sim_event_stream(stream, max_size=MAX_EVENTS_SIZE))
    return input_a, input_b, events
Exemplo n.º 2
0
def model_event_stream(draw, model_factory):
    input_a = draw(some_events(max_size=MAX_EVENTS_SIZE // 2))
    input_b = draw(some_events(max_size=MAX_EVENTS_SIZE // 2))
    stream_a = ListEventStream(input_a)
    stream_b = ListEventStream(input_b)
    stream = CompositeEventStream(stream_a, stream_b)
    model = model_factory()
    model_with_events = ModelWithExternalEvents(model, stream)
    events = process_model(draw, model_with_events, max_size=MAX_EVENTS_SIZE)
    return input_a, input_b, events, model
Exemplo n.º 3
0
def list_event_stream(draw):
    stream = ListEventStream(draw(some_events(min_size=1)))

    # Get some timestamps stats
    events = stream.events
    min_ts = min(ev.timestamp for ev in events)
    max_ts = max(ev.timestamp for ev in events)
    duration = max_ts - min_ts

    # Add some random out of order events
    start_ts = min_ts - duration
    max_size = MAX_EVENTS_SIZE // 5
    max_interval = 3 * duration // max_size  # So that events are generated in range [min_ts-duration, max_ts+duration]
    more_events = draw(
        some_events(min_size=1,
                    max_size=max_size,
                    min_interval=max_interval // 5,
                    max_interval=max_interval,
                    start_ts=start_ts))
    shuffle(more_events)
    stream.extend(more_events)

    # Generate events
    input = stream.events
    events = draw(sim_event_stream(stream, max_size=MAX_EVENTS_SIZE))
    return input, events
Exemplo n.º 4
0
def composite_normal_and_random_event_stream(draw):
    input = draw(some_events(max_size=MAX_EVENTS_SIZE))
    stream_a = RandomEventStream(draw, some_event())
    stream_b = ListEventStream(input)
    stream = CompositeEventStream(stream_a, stream_b)
    events = draw(sim_event_stream(stream, max_size=MAX_EVENTS_SIZE))
    return input, events
Exemplo n.º 5
0
def pool_model_events(draw, node_count):
    greek_names = [
        'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta'
    ]
    node_names = greek_names[:node_count]

    events = []
    events.extend(
        draw(
            sim_events(st.one_of(
                outage_event(max_count=1,
                             node_names=node_names,
                             min_duration=3),
                outage_event(max_count=node_count // 2,
                             node_names=node_names,
                             min_duration=3),
                restart_event(node_names=node_names)),
                       min_interval=10)))
    events.extend(
        draw(
            sim_events(corrupt_event(node_names=node_names),
                       max_size=1,
                       min_interval=50,
                       max_interval=1000)))

    pool = PoolModel(node_names)
    model = ModelWithExternalEvents(pool, ListEventStream(events))
    return pool, process_model(draw, model, max_size=1000)
Exemplo n.º 6
0
 def __init__(self, name: str, node_names: List[str], connections: PoolConnections):
     self._name = name
     self._node_names = node_names
     self._quorum = Quorums(len(node_names))
     self._ts = 0
     self._corrupted_name = None
     self._timer = TimerModel(name)
     self._connections = connections
     self._view_changer = create_view_changer(self)
     self._internal_outbox = ListEventStream()
     self.outbox = CompositeEventStream(self._internal_outbox, self._timer.outbox())
     self._check_performance_timer = RepeatingTimer(self._timer, 30, self._check_performance)
Exemplo n.º 7
0
 def __init__(self, name):
     self._name = name
     self._ts = 0
     self._outbox = ListEventStream()
Exemplo n.º 8
0
 def __init__(self):
     self.processed_events = []
     self._events = st.one_of(st.just(ErrorEvent(reason="random")),
                              some_event())
     self._outbox = ListEventStream()
     self._error_status = None
Exemplo n.º 9
0
 def __init__(self):
     self.processed_events = []
     self._outbox = ListEventStream()