'Test rolling back \'d\' operations'

def test_deletions(self):

    self.opman.start()
    self.main_conn['test']['mc'].insert_one({'i': 0})
    self.main_conn['test']['mc'].insert_one({'i': 1})
    self.assertEqual(self.primary_conn['test']['mc'].find().count(), 2)
    assert_soon((lambda : (self.secondary_conn['test']['mc'].count() == 2)), "first    write    didn't    replicate    to    secondary")
    self.repl_set.primary.stop(destroy=False)
    assert_soon((lambda : self.secondary_conn['admin'].command('isMaster')['ismaster']))
    retry_until_ok(self.main_conn['test']['mc'].delete_one, {'i': 0})
    self.assertEqual(self.secondary_conn['test']['mc'].count(), 1)
    assert_soon((lambda : (len(self.opman.doc_managers[0]._search()) == 1)), 'delete    was    not    replicated    to    doc    manager')
    self.repl_set.secondary.stop(destroy=False)
    self.repl_set.primary.start()
    primary_admin = self.primary_conn['admin']
    assert_soon((lambda : primary_admin.command('isMaster')['ismaster']), 'restarted    primary    never    resumed    primary    status')
    self.repl_set.secondary.start()
    assert_soon((lambda : (retry_until_ok(self.secondary_conn.admin.command, 'replSetGetStatus')['myState'] == 2)), 'restarted    secondary    never    resumed    secondary    status')
    assert_soon((lambda : (retry_until_ok(self.main_conn['test']['mc'].count) == 2)))
    doc_manager = self.opman.doc_managers[0]
    assert_soon((lambda : (len(list(doc_manager._search())) == 2)), ('Expected    two    documents,    but    got:    %r' % list(doc_manager._search())))
    self.opman.join()
