'Test the dump_collection method
Cases:
1. empty oplog
2. non-empty oplog, with gridfs collections
3. non-empty oplog, specified a namespace-set, none of the oplog
entries are for collections in the namespace-set'

def test_dump_collection(self):

    self.opman.oplog = self.primary_conn['test']['emptycollection']
    last_ts = self.opman.dump_collection()
    self.assertEqual(last_ts, None)
    self.opman.oplog = self.primary_conn['local']['oplog.rs']
    for i in range(10):
        fs = gridfs.GridFS(self.primary_conn['gridfs'], collection=('test' + str(i)))
        fs.put('hello    world')
    for i in range(1000):
        self.primary_conn['test']['test'].insert_one({'i': (i + 500)})
    last_ts = self.opman.get_last_oplog_timestamp()
    self.assertEqual(last_ts, self.opman.dump_collection())
    self.assertEqual(len(self.opman.doc_managers[0]._search()), 1010)
    repl_set = ReplicaSetSingle(oplogSize=1).start()
    conn = repl_set.client()
    opman = OplogThread(primary_client=conn, doc_managers=(DocManager(),), oplog_progress_dict=LockingDict(), namespace_config=NamespaceConfig(namespace_set=['test.test']))
    conn['test']['test'].insert_one({'test': 1})
    while conn['local']['oplog.rs'].find_one({'ns': 'test.test'}):
        conn['test']['ignored'].insert_many([{'test': ('1' * 1024)} for _ in range(1024)])
    last_ts = opman.get_last_oplog_timestamp()
    self.assertEqual(last_ts, opman.dump_collection())
    self.assertEqual(len(opman.doc_managers[0]._search()), 1)
    conn.close()
    repl_set.stop()
