Example #1
0
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()
Example #2
0
 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()
Example #3
0
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()
 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()
Example #5
0
 def setUpClass(cls):
     if db_user and db_password:
         auth_args = dict(auth_username=db_user, auth_key=db_password)
     else:
         auth_args = {}
     cls.cluster = ShardedClusterSingle().start()
     cls.main_uri = cls.cluster.uri + '/?readPreference=primaryPreferred'
     cls.dm = DocManager()
     cls.connector = Connector(mongo_address=cls.main_uri,
                               doc_managers=[cls.dm],
                               **auth_args)
     cls.connector.start()
     assert_soon(lambda: len(cls.connector.shard_set) == 2,
                 message='connector failed to find both shards!')
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()
Example #7
0
 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()