Skip to content

Commit 129cd21

Browse files
committed
enable sharding
1 parent 43db3b4 commit 129cd21

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

internal/verifier/metadata_test.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (suite *IntegrationTestSuite) TestShardingMismatch() {
2929
{"key", key},
3030
},
3131
).Err(),
32-
fmt.Sprintf("%s: should create %#q", label, dbname+"."+collName),
32+
fmt.Sprintf("%s: should shard %#q", label, dbname+"."+collName),
3333
)
3434
}
3535

@@ -40,8 +40,8 @@ func (suite *IntegrationTestSuite) TestShardingMismatch() {
4040
"sharded_dst",
4141
)
4242

43-
for _, collName := range collections {
44-
for c, client := range mslices.Of(suite.srcMongoClient, suite.dstMongoClient) {
43+
for c, client := range mslices.Of(suite.srcMongoClient, suite.dstMongoClient) {
44+
for _, collName := range collections {
4545
suite.Require().NoError(
4646
client.Database(dbname).CreateCollection(
4747
ctx,
@@ -54,6 +54,13 @@ func (suite *IntegrationTestSuite) TestShardingMismatch() {
5454
}
5555

5656
if srcInfo.Topology == util.TopologySharded {
57+
suite.Require().NoError(
58+
suite.srcMongoClient.Database("admin").RunCommand(
59+
ctx,
60+
bson.D{{"enableSharding", dbname}},
61+
).Err(),
62+
)
63+
5764
shardCollection(
5865
suite.srcMongoClient,
5966
"idonly",
@@ -75,6 +82,13 @@ func (suite *IntegrationTestSuite) TestShardingMismatch() {
7582
}
7683

7784
if dstInfo.Topology == util.TopologySharded {
85+
suite.Require().NoError(
86+
suite.dstMongoClient.Database("admin").RunCommand(
87+
ctx,
88+
bson.D{{"enableSharding", dbname}},
89+
).Err(),
90+
)
91+
7892
shardCollection(
7993
suite.dstMongoClient,
8094
"idonly",
@@ -130,15 +144,7 @@ func (suite *IntegrationTestSuite) TestShardingMismatch() {
130144

131145
suite.Require().Len(tasks, len(collections))
132146

133-
if srcInfo.Topology != dstInfo.Topology {
134-
for _, task := range tasks {
135-
suite.Assert().Equal(
136-
verificationTaskCompleted,
137-
task.Status,
138-
"mismatched topologies, so task should have succeeded: %v", task,
139-
)
140-
}
141-
} else {
147+
if srcInfo.Topology == util.TopologySharded && dstInfo.Topology == util.TopologySharded {
142148
taskMap := mslices.ToMap(
143149
tasks,
144150
func(task VerificationTask) string {
@@ -171,5 +177,13 @@ func (suite *IntegrationTestSuite) TestShardingMismatch() {
171177
)
172178

173179
suite.T().Logf("tasks: %+v", tasks)
180+
} else {
181+
for _, task := range tasks {
182+
suite.Assert().Equal(
183+
verificationTaskCompleted,
184+
task.Status,
185+
"mismatched topologies, so task should have succeeded: %v", task,
186+
)
187+
}
174188
}
175189
}

0 commit comments

Comments
 (0)