コード例 #1
0
    def test_ssl_error(self, es):
        import elasticsearch
        import urllib3.exceptions

        es.info.side_effect = elasticsearch.ConnectionError("N/A",
                                                            "[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:719)",
                                                            urllib3.exceptions.SSLError(
                                                                "[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:719)"))
        with self.assertRaisesRegex(expected_exception=exceptions.SystemSetupError,
                                    expected_regex="Could not connect to cluster via https. Is this an https endpoint?"):
            driver.wait_for_rest_layer(es, max_attempts=3)
コード例 #2
0
    def test_retries_on_transport_errors(self, es, sleep):
        import elasticsearch

        es.info.side_effect = [
            elasticsearch.TransportError(503, "Service Unavailable"),
            elasticsearch.TransportError(401, "Unauthorized"),
            {
                "version": {
                    "number": "5.0.0",
                    "build_hash": "abc123"
                }
            }
        ]
        self.assertTrue(driver.wait_for_rest_layer(es, max_attempts=3))
コード例 #3
0
    def test_dont_retries_eternally_on_transport_errors(self, es, sleep):
        import elasticsearch

        es.info.side_effect = elasticsearch.TransportError(401, "Unauthorized")
        self.assertFalse(driver.wait_for_rest_layer(es, max_attempts=3))
コード例 #4
0
 def test_successfully_waits_for_rest_layer(self, es):
     self.assertTrue(driver.wait_for_rest_layer(es, max_attempts=3))