Esempio n. 1
0
def inline_test_threading():
    """
    :return:
    """
    tingyun.embattle.log_file._initialized = False
    initialize_logging(thread_test_log, logging.DEBUG)
    _logger = logging.getLogger("tingyun.api")
    _logger.debug(write_separate_msg)
Esempio n. 2
0
    def test_create_connection(self):
        """
        """
        settings = global_settings()
        settings.license_key = "999-999-999"
        test_log = os.path.join(os.path.dirname(__file__), "test.log")
        initialize_logging(test_log, logging.DEBUG)

        session = create_connection("999-999-999", "Python App Test", [],
                                    env_config(), settings)
        self.assertTrue(isinstance(session, Engine), "")

        if os.path.isfile(test_log):
            os.remove(test_log)
Esempio n. 3
0
    def test_initialize_logging(self):
        """
        """
        self.clear_env()

        # reset the log status
        tingyun.embattle.log_file._initialized = False
        initialize_logging(self.test_log, logging.DEBUG)
        _logger = logging.getLogger("tingyun." + __name__)
        _logger.debug("test for log.")

        self.assertTrue(os.path.isfile(self.test_log), "test log failed...")

        self.clear_env()
Esempio n. 4
0
    def test_transmitter(self):
        """
        """
        # prepare the log environment for test
        test_log = os.path.join(os.path.dirname(__file__), "test.log")
        initialize_logging(test_log, logging.DEBUG)

        url = connect_url("getRedirectHost")
        # redirect_url = transmitter(None, url, "getRedirectHost", param={"licenseKey": "999-999-999"})
        # self.assertTrue(redirect_url, "get url error.")

        try:
            host = transmitter(None,
                               url,
                               "getRedirectHost",
                               param={"licenseKey": "8sadf8-8fsd8-fds88"})
        except Exception as _:
            host = ""
        # self.assertTrue(host in redirect_hosts, "")

        local_conf = {
            "host": "dev.agent.com",
            "appName": [
                "PythonApp",
            ],
            "language": "Python",
            "agentVersion": "1.0",
            "config": {
                "nbs.enabled": "true"
            },
            "env": {
                "Os": "linux"
            }
        }

        # url = connect_url("initAgentApp", host, with_port=False)
        # server_conf = transmitter(None, url, "initAgentApp", local_conf, {"licenseKey": "999-999-999"})
        #
        # self.assertTrue("config" in server_conf, "")
        # self.assertTrue(isinstance(server_conf["config"], dict), "")
        #
        # self.assertTrue("applicationId" in server_conf, "")
        # self.assertTrue("enabled" in server_conf, "")
        # self.assertTrue("appSessionKey" in server_conf, "")
        # self.assertTrue("dataSentInterval" in server_conf, "")
        # self.assertTrue("apdex_t" in server_conf, "")

        if os.path.isfile(test_log):
            os.remove(test_log)
Esempio n. 5
0
    def inspect_prerequisites(self):
        """ Do some prerequisite check for corps operation
        :return:
        """
        log_bootstrap("Inspecting config file %s" % self.config_file,
                      close=True)

        if not self._config_parser.read(self.config_file):
            raise ConfigurationError("Unable to access the config file. %s",
                                     self.config_file)

        self._settings.config_file = self.config_file
        self.load_settings()
        self.load_settings('tingyun:exclude', "plugins")
        self.load_settings('tingyun:private', "port")
        self.load_settings('tingyun:private', "host")
        self.load_settings('tingyun:proxy', "proxy_host")
        self.load_settings('tingyun:proxy', "proxy_port")
        self.load_settings('tingyun:proxy', "proxy_user")
        self.load_settings('tingyun:proxy', "proxy_pwd")
        self.load_settings('tingyun:proxy', "proxy_scheme")

        # we can not access the log file and log level from the config parser. it maybe empty.
        initialize_logging(self._settings.log_file, self._settings.log_level)