55 "testing"
66 "time"
77
8+ "github.com/10gen/migration-verifier/mslices"
89 "github.com/pkg/errors"
910 "github.com/samber/lo"
1011 "github.com/stretchr/testify/require"
@@ -35,6 +36,12 @@ func TestChangeStreamFilter(t *testing.T) {
3536// terminates that verifier, updates the source cluster, starts a new
3637// verifier with change stream, and confirms that things look as they should.
3738func (suite * IntegrationTestSuite ) TestChangeStreamResumability () {
39+ suite .Require ().NoError (
40+ suite .srcMongoClient .
41+ Database (suite .DBNameForTest ()).
42+ CreateCollection (suite .Context (), "testColl" ),
43+ )
44+
3845 func () {
3946 verifier1 := suite .BuildVerifier ()
4047 ctx , cancel := context .WithCancel (context .Background ())
@@ -43,7 +50,7 @@ func (suite *IntegrationTestSuite) TestChangeStreamResumability() {
4350 suite .Require ().NoError (err )
4451 }()
4552
46- ctx , cancel := context .WithCancel (context . Background ())
53+ ctx , cancel := context .WithCancel (suite . Context ())
4754 defer cancel ()
4855
4956 _ , err := suite .srcMongoClient .
@@ -213,14 +220,21 @@ func (suite *IntegrationTestSuite) TestNoStartAtTime() {
213220}
214221
215222func (suite * IntegrationTestSuite ) TestWithChangeEventsBatching () {
216- verifier := suite .BuildVerifier ()
223+ ctx := suite .Context ()
217224
218- ctx , cancel := context .WithCancel (context .Background ())
219- defer cancel ()
225+ db := suite .srcMongoClient .Database (suite .DBNameForTest ())
226+ coll1 := db .Collection ("testColl1" )
227+ coll2 := db .Collection ("testColl2" )
228+
229+ for _ , coll := range mslices .Of (coll1 , coll2 ) {
230+ suite .Require ().NoError (db .CreateCollection (ctx , coll .Name ()))
231+ }
232+
233+ verifier := suite .BuildVerifier ()
220234
221235 suite .Require ().NoError (verifier .StartChangeStream (ctx ))
222236
223- _ , err := suite . srcMongoClient . Database ( "testDb" ). Collection ( "testColl1" ) .InsertOne (ctx , bson.D {{"_id" , 1 }})
237+ _ , err := coll1 .InsertOne (ctx , bson.D {{"_id" , 1 }})
224238 suite .Require ().NoError (err )
225239 _ , err = suite .srcMongoClient .Database ("testDb" ).Collection ("testColl1" ).InsertOne (ctx , bson.D {{"_id" , 2 }})
226240 suite .Require ().NoError (err )
@@ -239,6 +253,7 @@ func (suite *IntegrationTestSuite) TestWithChangeEventsBatching() {
239253 500 * time .Millisecond ,
240254 "the verifier should flush a recheck doc after a batch" ,
241255 )
256+
242257}
243258
244259func (suite * IntegrationTestSuite ) TestEventBeforeWritesOff () {
0 commit comments