def setUp(self):
        AgentTestCase.setUp(self)
        clear_singleton_instances(ProtocolUtil)
        self.lib_dir = tempfile.mkdtemp()
        self.event_dir = os.path.join(self.lib_dir, EVENTS_DIRECTORY)

        EventLoggerTools.initialize_event_logger(self.event_dir)
Esempio n. 2
0
 def setUp(self):
     super(TestRemoteAccessHandler, self).setUp()
     # Since ProtocolUtil is a singleton per thread, we need to clear it to ensure that the test cases do not
     # reuse a previous state
     clear_singleton_instances(ProtocolUtil)
     for data in TestRemoteAccessHandler.eventing_data:
         del data
Esempio n. 3
0
    def setUp(self):
        AgentTestCase.setUp(self)
        prefix = "UnitTest"
        logger.DEFAULT_LOGGER = Logger(prefix=prefix)

        # Since ProtocolUtil is a singleton per thread, we need to clear it to ensure that the test cases do not
        # reuse a previous state
        clear_singleton_instances(ProtocolUtil)
Esempio n. 4
0
 def setUp(self):
     AgentTestCase.setUp(self)
     event.init_event_logger(os.path.join(self.tmp_dir, EVENTS_DIRECTORY))
     CGroupsTelemetry.reset()
     clear_singleton_instances(ProtocolUtil)
     protocol = WireProtocol('endpoint')
     protocol.update_goal_state = MagicMock()
     self.get_protocol = patch('azurelinuxagent.common.protocol.util.ProtocolUtil.get_protocol', return_value=protocol)
     self.get_protocol.start()
Esempio n. 5
0
def _mock_wire_protocol():
    # Since ProtocolUtil is a singleton per thread, we need to clear it to ensure that the test cases do not
    # reuse a previous state
    clear_singleton_instances(ProtocolUtil)

    with mock_wire_protocol(DATA_FILE) as protocol:
        protocol_util = MagicMock()
        protocol_util.get_protocol = Mock(return_value=protocol)
        with patch("azurelinuxagent.ga.monitor.get_protocol_util", return_value=protocol_util):
            yield protocol
Esempio n. 6
0
    def setUp(self):
        AgentTestCase.setUp(self)
        prefix = "UnitTest"
        logger.DEFAULT_LOGGER = Logger(prefix=prefix)

        self.archive_path = os.path.join(self.tmp_dir, "logs.zip")
        self.mock_archive_path = patch("azurelinuxagent.ga.collect_logs.COMPRESSED_ARCHIVE_PATH", self.archive_path)
        self.mock_archive_path.start()

        # Since ProtocolUtil is a singleton per thread, we need to clear it to ensure that the test cases do not
        # reuse a previous state
        clear_singleton_instances(ProtocolUtil)
Esempio n. 7
0
    def setUp(self):
        AgentTestCase.setUp(self)
        clear_singleton_instances(ProtocolUtil)

        # Create the log directory if not exists
        fileutil.mkdir(conf.get_ext_log_dir())
 def setUp(self):
     super(TestProtocolUtil, self).setUp()
     # Since ProtocolUtil is a singleton per thread, we need to clear it to ensure that the test cases do not
     # reuse a previous state
     clear_singleton_instances(ProtocolUtil)
 def setUp(self):
     super(TestSingletonPerThread, self).setUp()
     # In a multi-threaded environment, exceptions thrown in the child thread will not be propagated to the parent
     # thread. In order to achieve that, adding all exceptions to a Queue and then checking that in parent thread.
     self.errors = Queue()
     clear_singleton_instances(TestClassToTestSingletonPerThread)