'Test with a single replication target'

def test_single_target(self):

    self.opman.start()
    self.main_conn['test']['mc'].insert_one({'i': 0})
    self.assertEqual(self.primary_conn['test']['mc'].find().count(), 1)
    secondary = self.secondary_conn
    assert_soon((lambda : (secondary['test']['mc'].count() == 1)), "first    write    didn't    replicate    to    secondary")
    self.repl_set.primary.stop(destroy=False)
    assert_soon((lambda : secondary['admin'].command('isMaster')['ismaster']))
    retry_until_ok(self.main_conn['test']['mc'].insert_one, {'i': 1})
    self.assertEqual(secondary['test']['mc'].count(), 2)
    assert_soon((lambda : (len(self.opman.doc_managers[0]._search()) == 2)), 'not    all    writes    were    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(secondary.admin.command, 'replSetGetStatus')['myState'] == 2)), 'restarted    secondary    never    resumed    secondary    status')
    assert_soon((lambda : (retry_until_ok(self.main_conn.test.mc.find().count) > 0)), 'documents    not    found    after    primary/secondary    restarted')
    self.assertEqual(self.main_conn['test']['mc'].count(), 1)
    self.assertEqual(self.main_conn['test']['mc'].find_one()['i'], 0)
    doc_manager = self.opman.doc_managers[0]
    assert_soon((lambda : (len(doc_manager._search()) == 1)), 'documents    never    rolled    back    in    doc    manager.')
    self.assertEqual(doc_manager._search()[0]['i'], 0)
    self.opman.join()
