Esempio n. 1
0
    def __init__(self, configuration, monitors):
        CopyingManager.__init__(self, configuration, monitors)
        # Approach:  We will override key methods of CopyingManager, blocking them from returning until the controller
        # tells it to proceed.  This allows us to then do things like write new log lines while the CopyingManager is
        # blocked.   Coordinating the communication between the two threads is done using two condition variables.
        # We changed the CopyingManager to block in three places: while it is sleeping before it starts a new loop,
        # when it invokes ``_send_events`` to send a new request, and when it blocks to receive the response.
        # These three states or referred to as "sleeping", "blocked_on_send", "blocked_on_receive".
        #
        # This cv protects all of the variables written by the CopyingManager thread.
        self.__test_state_cv = threading.Condition()
        # Which state the CopyingManager is currently blocked in -- "sleeping", "blocked_on_send", "blocked_on_receive"
        self.__test_state = None
        # The number of times the CopyingManager has blocked.
        self.__test_state_changes = 0
        # Whether or not the CopyingManager should stop.
        self.__test_stopping = False
        # Written by CopyingManager.  The last AddEventsRequest request passed into ``_send_events``.
        self.__captured_request = None
        # Protected by __test_state_cv.  The status message to return for the next call to ``_send_events``.
        self.__pending_response = None

        # This cv protects __advance_requests and is used mainly by the testing thread.
        self.__advance_requests_cv = threading.Condition()
        # This is incremented everytime the controller wants the CopyingManager to advance to the next blocking state,
        # regardless of which state it is in.
        self.__advance_requests = 0

        self.__controller = TestableCopyingManager.TestController(self)
    def __init__(self, configuration, monitors):
        CopyingManager.__init__(self, configuration, monitors)
        # Approach:  We will override key methods of CopyingManager, blocking them from returning until the controller
        # tells it to proceed.  This allows us to then do things like write new log lines while the CopyingManager is
        # blocked.   Coordinating the communication between the two threads is done using two condition variables.
        # We changed the CopyingManager to block in three places: while it is sleeping before it starts a new loop,
        # when it invokes ``_send_events`` to send a new request, and when it blocks to receive the response.
        # These three states or referred to as "sleeping", "blocked_on_send", "blocked_on_receive".
        #
        # This cv protects all of the variables written by the CopyingManager thread.
        self.__test_state_cv = threading.Condition()
        # Which state the CopyingManager is currently blocked in -- "sleeping", "blocked_on_send", "blocked_on_receive"
        self.__test_state = None
        # The number of times the CopyingManager has blocked.
        self.__test_state_changes = 0
        # Whether or not the CopyingManager should stop.
        self.__test_stopping = False
        # Written by CopyingManager.  The last AddEventsRequest request passed into ``_send_events``.
        self.__captured_request = None
        # Protected by __test_state_cv.  The status message to return for the next call to ``_send_events``.
        self.__pending_response = None

        # This cv protects __advance_requests and is used mainly by the testing thread.
        self.__advance_requests_cv = threading.Condition()
        # This is incremented everytime the controller wants the CopyingManager to advance to the next blocking state,
        # regardless of which state it is in.
        self.__advance_requests = 0

        self.__controller = TestableCopyingManager.TestController(self)
Esempio n. 3
0
    def __init__(self, configuration, monitors):
        CopyingManager.__init__(self, configuration, monitors)
        # Approach:  We will override key methods of CopyingManager, blocking them from returning until the controller
        # tells it to proceed.  This allows us to then do things like write new log lines while the CopyingManager is
        # blocked.   Coordinating the communication between the two threads is done using one condition variable.
        # We changed the CopyingManager to block in three places: while it is sleeping before it starts a new loop,
        # when it invokes `_send_events` to send a new request, and when it blocks to receive the response.
        # These three states are referred to as 'sleeping', 'sending', 'responding'.
        #
        # The CopyingManager will have state to record where it should next block (i.e., if it should block at
        # 'sleeping' when it attempts to sleep).  The test controller will manipulate this state, notifying changes on
        # the condition variable. The CopyingManager will block in this state (and indicate it is blocked) until the
        # test controller sets a new state to block at.
        #
        # This cv protects all of the variables written by the CopyingManager thread.
        self.__test_state_cv = threading.Condition()
        # Which state the CopyingManager should block in -- "sleeping", "sending", "responding"
        # We initialize it to a special value "all" so that it stops as soon the CopyingManager starts up.
        self.__test_stop_state = 'all'
        # If not none, a state the test must pass through before it tries to stop at `__test_stop_state`.
        # If this transition is not observed by the time it does get to the stop state, an assertion is thrown.
        self.__test_required_transition = None
        # Whether or not the CopyingManager is stopped at __test_stop_state.
        self.__test_is_stopped = False
        # Written by CopyingManager.  The last AddEventsRequest request passed into ``_send_events``.
        self.__captured_request = None
        # Protected by __test_state_cv.  The status message to return for the next call to ``_send_events``.
        self.__pending_response = None

        self.__controller = TestableCopyingManager.TestController(self)
Esempio n. 4
0
    def __init__(self, configuration, monitors):
        CopyingManager.__init__(self, configuration, monitors)
        TestableCopyingManagerFlowController.__init__(self, configuration)

        # do this just to tell static analyzer that this is a testable instances.
        self._log_matchers = self._log_matchers  # type: List[TestableLogMatcher]