Exemplo n.º 1
0
    def test_query_api_with_retries_temp_error_rate_limited( self ):
        with mock.patch.object( KubernetesApi, "query_api" ) as mock_query:
            mock_query.side_effect = K8sApiTemporaryError( "Temporary Error" )

            k8s = KubernetesApi()
            rate_limiter = BlockingRateLimiter(
                num_agents=1, initial_cluster_rate=100, max_cluster_rate=1000, min_cluster_rate=1,
                consecutive_success_threshold=1,
                strategy='multiply',
            )
            options = ApiQueryOptions( rate_limiter=rate_limiter, max_retries=0 )
            self.assertRaises( K8sApiTemporaryError, lambda: k8s.query_api_with_retries( "/foo/bar", options ) )
            self.assertEqual( rate_limiter.current_cluster_rate, 50.0 )
Exemplo n.º 2
0
 def _raise_temp_error(pod_namespace, pod_name):
     raise K8sApiTemporaryError("Temporary error")