Ejemplo n.º 1
0
 def testNoSQLHandleConfigClone(self):
     max_content_length = 1024 * 1024
     config = get_handle_config(tenant_id)
     clone_config = config.clone()
     self.assertEqual(clone_config.get_endpoint(), endpoint)
     self.assertEqual(clone_config.get_default_timeout(), timeout)
     self.assertEqual(clone_config.get_default_table_request_timeout(),
                      table_request_timeout)
     self.assertEqual(clone_config.get_default_consistency(), consistency)
     self.assertEqual(clone_config.get_protocol(), config.get_protocol())
     self.assertEqual(clone_config.get_host(), config.get_host())
     self.assertEqual(clone_config.get_port(), config.get_port())
     self.assertEqual(clone_config.get_timeout(), timeout)
     self.assertEqual(clone_config.get_table_request_timeout(),
                      table_request_timeout)
     self.assertEqual(clone_config.get_sec_info_timeout(), sec_info_timeout)
     self.assertEqual(clone_config.get_consistency(), consistency)
     self.assertEqual(clone_config.get_pool_connections(), pool_connections)
     self.assertEqual(clone_config.get_pool_maxsize(), pool_maxsize)
     self.assertEqual(clone_config.get_max_content_length(),
                      max_content_length)
     self.assertEqual(clone_config.get_retry_handler().get_num_retries(),
                      retry_handler.get_num_retries())
     self.assertIsNotNone(clone_config.get_authorization_provider())
     self.assertEqual(clone_config.get_proxy_host(), proxy_host)
     self.assertEqual(clone_config.get_proxy_port(), proxy_port)
     self.assertEqual(clone_config.get_proxy_username(), proxy_username)
     self.assertEqual(clone_config.get_proxy_password(), proxy_password)
     self.assertIsNotNone(clone_config.get_logger())
 def testNoSQLHandleConfigRetryHandler(self):
     self.assertEqual(retry_handler.get_num_retries(), 10)
     # set illegal request to RetryHandler.do_retry
     self.assertRaises(IllegalArgumentException, retry_handler.do_retry,
                       'IllegalRequest', 3,
                       OperationThrottlingException('Test'))
     # set illegal retried number to RetryHandler.do_retry
     self.assertRaises(IllegalArgumentException, retry_handler.do_retry,
                       self.table_request, 'IllegalNumRetried',
                       RetryableException('Test'))
     self.assertRaises(IllegalArgumentException, retry_handler.do_retry,
                       self.table_request, 0, RetryableException('Test'))
     self.assertRaises(IllegalArgumentException, retry_handler.do_retry,
                       self.table_request, -1, RetryableException('Test'))
     # set illegal retryable exception to RetryHandler.do_retry
     self.assertRaises(IllegalArgumentException, retry_handler.do_retry,
                       self.table_request, 3, 'IllegalException')
     self.assertRaises(IllegalArgumentException, retry_handler.do_retry,
                       self.table_request, 3,
                       IllegalArgumentException('Test'))
     # set legal retried number and retryable exception to
     # RetryHandler.do_retry
     self.assertTrue(
         retry_handler.do_retry(self.table_request, 5,
                                SecurityInfoNotReadyException('Test')))
     self.assertFalse(
         retry_handler.do_retry(self.table_request, 5,
                                OperationThrottlingException('Test')))
     self.assertFalse(
         retry_handler.do_retry(self.table_request, 5,
                                RetryableException('Test')))
     self.assertTrue(
         retry_handler.do_retry(self.get_request, 5,
                                RetryableException('Test')))
     self.assertFalse(
         retry_handler.do_retry(self.get_request, 10,
                                RetryableException('Test')))
     # set illegal retried number to RetryHandler.delay
     self.assertRaises(IllegalArgumentException, retry_handler.delay,
                       'IllegalNumRetried', RetryableException('Test'))
     self.assertRaises(IllegalArgumentException, retry_handler.delay, 0,
                       RetryableException('Test'))
     self.assertRaises(IllegalArgumentException, retry_handler.delay, -1,
                       RetryableException('Test'))
     # set illegal retryable exception to RetryHandler.delay
     self.assertRaises(IllegalArgumentException, retry_handler.delay, 5000,
                       'IllegalException')
     self.assertRaises(IllegalArgumentException, retry_handler.delay, 5000,
                       IllegalArgumentException('Test'))
 def testNoSQLHandleConfigClone(self):
     config = get_handle_config(tenant_id)
     clone_config = config.clone()
     self._check_config(clone_config, config.get_service_url(),
                        retry_handler.get_num_retries())