def test_flush_fail(self):
        server = TestServer(5006)
        server.set_response_data("unparsablejson")
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(
            dashboard_address = 'http://localhost:5006',
            agent_key = 'key1',
            app_name = 'TestPythonApp',
            debug = True
        )

        m = {
            'm1': 1
        }
        agent.message_queue.add('t1', m)

        m = {
            'm2': 2
        }        
        agent.message_queue.add('t1', m)

        agent.message_queue.flush()
        self.assertEqual(len(agent.message_queue.queue), 2)

        agent.destroy()
        server.join()
Пример #2
0
    def test_post(self):
        server = TestServer(5001)
        server.set_response_data(json.dumps({'c': 3, 'd': 4}))
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(dashboard_address='http://localhost:5001',
                                  agent_key='key1',
                                  app_name='TestPythonApp',
                                  app_environment='test',
                                  app_version='1.1.1',
                                  debug=True)

        api_request = APIRequest(agent)

        api_request.post('test', {'a': 1, 'b': 2})
        data = json.loads(server.get_request_data())
        self.assertEqual(data['run_id'], agent.run_id)
        self.assertEqual(data['run_ts'], agent.run_ts)
        self.assertEqual(data['process_id'], os.getpid())
        self.assertEqual(data['host_name'], socket.gethostname())
        self.assertEqual(data['runtime_type'], 'python')
        self.assertEqual(
            data['runtime_version'],
            '{0.major}.{0.minor}.{0.micro}'.format(sys.version_info))
        self.assertEqual(data['agent_version'], agent.AGENT_VERSION)
        self.assertEqual(data['app_name'], 'TestPythonApp')
        self.assertEqual(data['app_environment'], 'test')
        self.assertEqual(data['app_version'], '1.1.1')
        self.assertEqual(data['payload'], {'a': 1, 'b': 2})

        agent.destroy()
        server.join()
    def test_flush_fail(self):
        server = TestServer(5005)
        server.set_response_data("unparsablejson")
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(
            dashboard_address = 'http://localhost:5005',
            agent_key = 'key1',
            app_name = 'TestPythonApp',
            debug = True
        )

        m = {
            'm1': 1
        }
        agent.message_queue.add('t1', m)

        m = {
            'm2': 2
        }        
        agent.message_queue.add('t1', m)

        agent.message_queue.flush()
        self.assertEqual(len(agent.message_queue.queue), 2)

        agent.destroy()
        server.join()
Пример #4
0
    def test_load(self):
        server = TestServer(5008)
        server.set_response_data('{"profiling_disabled":"yes"}')
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(dashboard_address='http://localhost:5008',
                                  agent_key='key1',
                                  app_name='TestPythonApp',
                                  debug=True)

        agent.config_loader.load()

        self.assertTrue(agent.config.is_profiling_disabled())

        agent.destroy()
        server.join()
    def test_load(self):
        server = TestServer(5008)
        server.set_response_data('{"profiling_disabled":"yes"}')
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(
            dashboard_address = 'http://localhost:5008',
            agent_key = 'key1',
            app_name = 'TestPythonApp',
            debug = True
        )

        agent.config_loader.load()
        
        self.assertTrue(agent.config.is_profiling_disabled())

        agent.destroy()
        server.join()