@@ -7439,7 +7439,7 @@ func TestPlannedReparentShard(t *testing.T) {
7439
7439
req * vtctldatapb.PlannedReparentShardRequest
7440
7440
expected * vtctldatapb.PlannedReparentShardResponse
7441
7441
expectEventsToOccur bool
7442
- shouldErr bool
7442
+ expectedErr string
7443
7443
}{
7444
7444
{
7445
7445
name : "successful reparent" ,
@@ -7554,7 +7554,6 @@ func TestPlannedReparentShard(t *testing.T) {
7554
7554
},
7555
7555
},
7556
7556
expectEventsToOccur : true ,
7557
- shouldErr : false ,
7558
7557
},
7559
7558
{
7560
7559
// Note: this is testing the error-handling done in
@@ -7570,7 +7569,7 @@ func TestPlannedReparentShard(t *testing.T) {
7570
7569
Shard : "-" ,
7571
7570
},
7572
7571
expectEventsToOccur : false ,
7573
- shouldErr : true ,
7572
+ expectedErr : "node doesn't exist: keyspaces/testkeyspace/shards/-" ,
7574
7573
},
7575
7574
{
7576
7575
name : "invalid WaitReplicasTimeout" ,
@@ -7580,7 +7579,71 @@ func TestPlannedReparentShard(t *testing.T) {
7580
7579
Nanos : 1 ,
7581
7580
},
7582
7581
},
7583
- shouldErr : true ,
7582
+ expectedErr : "duration: seconds:-1 nanos:1 is out of range for time.Duration" ,
7583
+ },
7584
+ {
7585
+ name : "tablet unreachable" ,
7586
+ ts : memorytopo .NewServer (ctx , "zone1" ),
7587
+ tablets : []* topodatapb.Tablet {
7588
+ {
7589
+ Alias : & topodatapb.TabletAlias {
7590
+ Cell : "zone1" ,
7591
+ Uid : 100 ,
7592
+ },
7593
+ Type : topodatapb .TabletType_PRIMARY ,
7594
+ PrimaryTermStartTime : & vttime.Time {
7595
+ Seconds : 100 ,
7596
+ },
7597
+ Keyspace : "testkeyspace" ,
7598
+ Shard : "-" ,
7599
+ },
7600
+ {
7601
+ Alias : & topodatapb.TabletAlias {
7602
+ Cell : "zone1" ,
7603
+ Uid : 200 ,
7604
+ },
7605
+ Type : topodatapb .TabletType_REPLICA ,
7606
+ Keyspace : "testkeyspace" ,
7607
+ Shard : "-" ,
7608
+ },
7609
+ {
7610
+ Alias : & topodatapb.TabletAlias {
7611
+ Cell : "zone1" ,
7612
+ Uid : 101 ,
7613
+ },
7614
+ Type : topodatapb .TabletType_RDONLY ,
7615
+ Keyspace : "testkeyspace" ,
7616
+ Shard : "-" ,
7617
+ },
7618
+ },
7619
+ tmc : & testutil.TabletManagerClient {
7620
+ // This is only needed to verify reachability, so empty results are fine.
7621
+ PrimaryStatusResults : map [string ]struct {
7622
+ Status * replicationdatapb.PrimaryStatus
7623
+ Error error
7624
+ }{
7625
+ "zone1-0000000200" : {
7626
+ Error : fmt .Errorf ("primary status failed" ),
7627
+ },
7628
+ "zone1-0000000101" : {
7629
+ Status : & replicationdatapb.PrimaryStatus {},
7630
+ },
7631
+ "zone1-0000000100" : {
7632
+ Status : & replicationdatapb.PrimaryStatus {},
7633
+ },
7634
+ },
7635
+ },
7636
+ req : & vtctldatapb.PlannedReparentShardRequest {
7637
+ Keyspace : "testkeyspace" ,
7638
+ Shard : "-" ,
7639
+ NewPrimary : & topodatapb.TabletAlias {
7640
+ Cell : "zone1" ,
7641
+ Uid : 200 ,
7642
+ },
7643
+ WaitReplicasTimeout : protoutil .DurationToProto (time .Millisecond * 10 ),
7644
+ },
7645
+ expectEventsToOccur : true ,
7646
+ expectedErr : "primary status failed" ,
7584
7647
},
7585
7648
}
7586
7649
@@ -7610,8 +7673,8 @@ func TestPlannedReparentShard(t *testing.T) {
7610
7673
testutil .AssertLogutilEventsOccurred (t , resp , "expected events to occur during ERS" )
7611
7674
}()
7612
7675
7613
- if tt .shouldErr {
7614
- assert .Error (t , err )
7676
+ if tt .expectedErr != "" {
7677
+ assert .EqualError (t , err , tt . expectedErr )
7615
7678
7616
7679
return
7617
7680
}
0 commit comments