Skip to content

Commit

Permalink
Fix oplogSuite.TestStops by inserting row before starting tailer
Browse files Browse the repository at this point in the history
TestStops was intermittently failing on arm64. I was able to fire up an
arm64 EC2 instance and repro it there, every 50 runs or so. I'm still
not sure why this fixes it, but with this change I can't reproduce it
over thousands of runs. Plus, inserting the row before starting the
tailer is consistent with what TestHonoursInitialTs does.

I also added a cleanup task to drop the fake oplog collection at the
end of the test. This doesn't actually seem to do anything, but I added
it because initially I thought the failure was related to
TestHonoursInitialTs not cleaning up after itself, and TestStops failing
as a result of some interaction. So the AddCleanup here doesn't actually
fix anything, but still seems like the right thing to do.
  • Loading branch information
benhoyt committed Jan 5, 2021
1 parent 880e1ec commit 5451c1a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mongo/oplog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ func (s *oplogSuite) TestStops(c *gc.C) {
_, session := s.startMongo(c)

oplog := s.makeFakeOplog(c, session)
s.insertDoc(c, session, oplog, &mongo.OplogDoc{Timestamp: 1})

tailer := mongo.NewOplogTailer(mongo.NewOplogSession(oplog, nil), time.Time{})
defer tailer.Stop()

s.insertDoc(c, session, oplog, &mongo.OplogDoc{Timestamp: 1})
s.getNextOplog(c, tailer)

err := tailer.Stop()
Expand Down Expand Up @@ -271,6 +271,10 @@ func (s *oplogSuite) makeFakeOplog(c *gc.C, session *mgo.Session) *mgo.Collectio
MaxBytes: 1024 * 1024,
})
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(c *gc.C) {
err := oplog.DropCollection()
c.Assert(err, jc.ErrorIsNil)
})
return oplog
}

Expand Down

0 comments on commit 5451c1a

Please sign in to comment.