def test_client_options(self):
     repl_set = ReplicaSet().start()
     try:
         config_def = {
             'mainAddress': repl_set.uri,
             'oplogFile': from_here('lib', 'dummy.timestamp'),
             'docManagers': [
                 {
                     'docManager': 'solr_doc_manager',
                     'targetURL': solr_url,
                     'args': {
                         'clientOptions': {
                             'timeout': 100
                         }
                     }
                 }
             ]
         }
         config_obj = config.Config(get_config_options())
         config_obj.load_json(json.dumps(config_def))
         config_obj.parse_args(argv=[])
         conn = connector.Connector.from_config(config_obj)
         self.assertEqual(100, conn.doc_managers[0].solr.timeout)
     finally:
         repl_set.stop()
Пример #2
0
 def test_ssl_options(self):
     config_def = {
         "mainAddress": "localhost:27017",
         "oplogFile": from_here("lib", "dummy.timestamp"),
         "ssl": {
             "sslCertfile": "certfile.pem",
             "sslKeyfile": "certfile.key",
             "sslCACerts": "ca.pem",
         },
     }
     for cert_policy, expected_ssl_cert_req in [
         ("ignored", ssl.CERT_NONE),
         ("optional", ssl.CERT_OPTIONAL),
         ("required", ssl.CERT_REQUIRED),
         (None, None),
     ]:
         config_def["ssl"]["sslCertificatePolicy"] = cert_policy
         config_obj = config.Config(get_config_options())
         config_obj.load_json(json.dumps(config_def))
         config_obj.parse_args(argv=[])
         mc = connector.Connector.from_config(config_obj)
         self.assertEqual("certfile.pem", mc.ssl_kwargs.get("ssl_certfile"))
         self.assertEqual("ca.pem", mc.ssl_kwargs.get("ssl_ca_certs"))
         self.assertEqual("certfile.key", mc.ssl_kwargs.get("ssl_keyfile"))
         self.assertEqual(expected_ssl_cert_req, mc.ssl_kwargs.get("ssl_cert_reqs"))
Пример #3
0
 def test_client_options(self):
     config_def = {
         "mainAddress": "localhost:27017",
         "oplogFile": from_here("lib", "dummy.timestamp"),
         "docManagers": [
             {
                 "docManager": "mongo_doc_manager",
                 "targetURL": "dummyhost:27017",
                 "args": {"clientOptions": {"maxPoolSize": 50, "connect": False}},
             }
         ],
     }
     config_obj = config.Config(get_config_options())
     config_obj.load_json(json.dumps(config_def))
     config_obj.parse_args(argv=[])
     conn = connector.Connector.from_config(config_obj)
     self.assertEqual(50, conn.doc_managers[0].mongo.max_pool_size)
Пример #4
0
 def test_client_options(self):
     config_def = {
         'mainAddress':
         'localhost:27017',
         'oplogFile':
         from_here('lib', 'dummy.timestamp'),
         'docManagers': [{
             'docManager': 'mongo_doc_manager',
             'targetURL': 'dummyhost:27017',
             'args': {
                 'clientOptions': {
                     'maxPoolSize': 50,
                     'connect': False
                 }
             }
         }]
     }
     config_obj = config.Config(get_config_options())
     config_obj.load_json(json.dumps(config_def))
     config_obj.parse_args(argv=[])
     conn = connector.Connector.from_config(config_obj)
     self.assertEqual(50, conn.doc_managers[0].mongo.max_pool_size)
 def test_client_options(self):
     config_def = {
         'mainAddress': 'localhost:27017',
         'oplogFile': from_here('lib', 'dummy.timestamp'),
         'docManagers': [
             {
                 'docManager': 'mongo_doc_manager',
                 'targetURL': 'dummyhost:27017',
                 'args': {
                     'clientOptions': {
                         'maxPoolSize': 50,
                         'connect': False
                     }
                 }
             }
         ]
     }
     config_obj = config.Config(get_config_options())
     config_obj.load_json(json.dumps(config_def))
     config_obj.parse_args(argv=[])
     conn = connector.Connector.from_config(config_obj)
     self.assertEqual(50, conn.doc_managers[0].mongo.max_pool_size)
 def test_ssl_options(self):
     config_def = {
         'mainAddress': 'localhost:27017',
         'oplogFile': from_here('lib', 'dummy.timestamp'),
         'ssl': {
             'sslCertfile': 'certfile.pem',
             'sslKeyfile': 'certfile.key',
             'sslCACerts': 'ca.pem'
         },
     }
     for cert_policy, expected_ssl_cert_req in [
         ('ignored', ssl.CERT_NONE), ('optional', ssl.CERT_OPTIONAL),
         ('required', ssl.CERT_REQUIRED), (None, None)
     ]:
         config_def['ssl']['sslCertificatePolicy'] = cert_policy
         config_obj = config.Config(get_config_options())
         config_obj.load_json(json.dumps(config_def))
         config_obj.parse_args(argv=[])
         mc = connector.Connector.from_config(config_obj)
         self.assertEqual('certfile.pem', mc.ssl_kwargs.get('ssl_certfile'))
         self.assertEqual('ca.pem', mc.ssl_kwargs.get('ssl_ca_certs'))
         self.assertEqual('certfile.key', mc.ssl_kwargs.get('ssl_keyfile'))
         self.assertEqual(expected_ssl_cert_req,
                          mc.ssl_kwargs.get('ssl_cert_reqs'))
Пример #7
0
 def reset_config(self):
     self.options = get_config_options()
     self.conf = config.Config(self.options)
 def setUp(self):
     self.config = config.Config(get_config_options())
     # Remove all logging Handlers, since tests may create Handlers.
     logger = logging.getLogger()
     for handler in logger.handlers:
         logger.removeHandler(handler)
Пример #9
0
 def reset_config(self):
     self.options = get_config_options()
     self.conf = config.Config(self.options)