예제 #1
0
 def test_slow_redirect(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     url = "/redirect?url=/redirect?delay=0.5"
     r = s.get(url)
     stats = global_stats.get(url, method="GET")
     self.assertEqual(1, stats.num_requests)
     self.assertGreater(stats.avg_response_time, 500)
예제 #2
0
파일: test_client.py 프로젝트: sanga/locust
 def test_slow_redirect(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     url = "/redirect?url=/redirect?delay=0.5"
     r = s.get(url)
     stats = global_stats.get(url, method="GET")
     assert 1 == stats.num_requests
     assert stats.avg_response_time > 500
예제 #3
0
 def test_streaming_response(self):
     """
     Test a request to an endpoint that returns a streaming response
     """
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/streaming/30")
     
     # verify that the time reported includes the download time of the whole streamed response
     self.assertGreater(global_stats.get("/streaming/30", method="GET").avg_response_time, 250)
     global_stats.clear_all()
     
     # verify that response time does NOT include whole download time, when using stream=True
     r = s.get("/streaming/30", stream=True)
     self.assertGreater(global_stats.get("/streaming/30", method="GET").avg_response_time, 0)
     self.assertLess(global_stats.get("/streaming/30", method="GET").avg_response_time, 250)
     
     # download the content of the streaming response (so we don't get an ugly exception in the log)
     _ = r.content
예제 #4
0
 def test_get(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/ultra_fast")
     self.assertEqual(200, r.status_code)
예제 #5
0
 def test_connection_error(self):
     s = HttpSession("http://localhost:1")
     r = s.get("/", timeout=0.1)
     self.assertEqual(r.status_code, 0)
     self.assertEqual(None, r.content)
     self.assertRaises(RequestException, r.raise_for_status)
예제 #6
0
파일: test_client.py 프로젝트: sanga/locust
 def test_connection_error(self):
     s = HttpSession("http://localhost:1")
     r = s.get("/", timeout=0.1)
     assert r.status_code == 0
     assert None == r.content
     raises(RequestException, r.raise_for_status)
예제 #7
0
 def test_connection_error(self):
     s = HttpSession("http://localhost:1")
     r = s.get("/", timeout=0.1)
     self.assertFalse(r)
     self.assertEqual(None, r.content)
     self.assertRaises(RequestException, r.raise_for_status)
예제 #8
0
파일: test_client.py 프로젝트: sanga/locust
 def test_get(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/ultra_fast")
     assert 200 == r.status_code
예제 #9
0
 def detail(self):
     zabo = self.client.get("/api/zaboes/100/")
     image_url = json.loads(zabo.content)["posters"][0]["image"]
     session = HttpSession(base_url="")
     session.get(image_url)
예제 #10
0
    class InitializeClient(SequentialTaskSet):
        """
        Initial loading of cellxgene - when the user hits the main route.

        Currently this sequence skips some of the static assets, which are quite small and should be served by the
        HTTP server directly.

        1. Load index.html, etc.
        2. Concurrently load /config, /schema
        3. Concurrently load /layout/obs, /annotations/var?annotation-name=<the index>
        -- Does initial render --
        4. Concurrently load all /annotations/obs and all /layouts/obs
        -- Fully initialized --
        """

        # Users hit all of the init routes as fast as they can, subject to the ordering constraints and network latency.
        wait_time = between(0.01, 0.1)

        def on_start(self):
            self.dataset = self.parent.dataset
            self.client.verify = False
            self.api_less_client = HttpSession(
                base_url=self.client.base_url.replace("api.", "").replace(
                    "cellxgene/", ""),
                request_success=self.client.request_success,
                request_failure=self.client.request_failure,
            )

        @task
        def index(self):
            self.api_less_client.get(f"{self.dataset}", stream=True)

        @task
        def loadConfigAndSchema(self):
            self.client.get(f"{self.dataset}/{API_SUFFIX}/schema",
                            stream=True,
                            catch_response=True)
            self.client.get(f"{self.dataset}/{API_SUFFIX}/config",
                            stream=True,
                            catch_response=True)

        @task
        def loadBootstrapData(self):
            self.client.get(f"{self.dataset}/{API_SUFFIX}/layout/obs",
                            headers={"Accept": "application/octet-stream"},
                            stream=True)
            self.client.get(
                f"{self.dataset}/{API_SUFFIX}/annotations/var?annotation-name={self.parent.var_index_name()}",
                headers={"Accept": "application/octet-stream"},
                catch_response=True,
            )

        @task
        def loadObsAnnotationsAndLayouts(self):
            obs_names = self.parent.obs_annotation_names()
            for name in obs_names:
                self.client.get(
                    f"{self.dataset}/{API_SUFFIX}/annotations/obs?annotation-name={name}",
                    headers={"Accept": "application/octet-stream"},
                    stream=True,
                )

            layouts = self.parent.layout_names()
            for name in layouts:
                self.client.get(
                    f"{self.dataset}/{API_SUFFIX}/annotations/obs?layout-name={name}",
                    headers={"Accept": "application/octet-stream"},
                    stream=True,
                )

        @task
        def done(self):
            self.interrupt()
예제 #11
0
 def getLogUser( self,accress_token):
     s = HttpSession("https://qa-api.aswat.co")
     response = s.get("https://qa-api.aswat.co/profile", headers={'access_token':accress_token})
     return response
예제 #12
0
 def test_cookie(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.post("/set_cookie?name=testcookie&value=1337")
     self.assertEqual(200, r.status_code)
     r = s.get("/get_cookie?name=testcookie")
     self.assertEqual('1337', r.content.decode())
예제 #13
0
 def test_get(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/ultra_fast")
     self.assertEqual(200, r.status_code)