class TestConnectorSharded(unittest.TestCase): def setUp(self): if not (db_user and db_password): raise SkipTest('Need to set a user/password to test this.') self.cluster = ShardedClusterSingle().start() def tearDown(self): try: os.unlink('oplog.timestamp') except OSError: pass self.cluster.stop() def test_start_with_auth(self): dm = DocManager() connector = Connector(mongo_address=self.cluster.uri, doc_managers=[dm], auth_username=db_user, auth_key=db_password) connector.start() # Insert some documents into the sharded cluster. These # should go to the DocManager, and the connector should not # have an auth failure. self.cluster.client().test.test.insert_one({'auth_failure': False}) assert_soon(lambda: len(dm._search()) > 0) connector.join()
class TestConnectorSharded(unittest.TestCase): def setUp(self): if db_user and db_password: auth_args = dict(auth_username=db_user, auth_key=db_password) else: auth_args = {} self.cluster = ShardedClusterSingle().start() self.dm = DocManager() self.connector = Connector(mongo_address=self.cluster.uri, doc_managers=[self.dm], **auth_args) self.connector.start() def tearDown(self): self.connector.join() try: os.unlink('oplog.timestamp') except OSError: pass self.cluster.stop()
class TestConnectorSharded(unittest.TestCase): def setUp(self): if db_user and db_password: auth_args = dict(auth_username=db_user, auth_key=db_password) else: auth_args = {} self.cluster = ShardedClusterSingle().start() self.dm = DocManager() self.connector = Connector( mongo_address=self.cluster.uri, doc_managers=[self.dm], **auth_args ) self.connector.start() def tearDown(self): self.connector.join() try: os.unlink('oplog.timestamp') except OSError: pass self.cluster.stop()