From e0eee4ffbaee1e1127bfc3377b86f5aeee1d9646 Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Sun, 2 Jun 2024 13:45:03 +0530 Subject: [PATCH 1/8] fix Signed-off-by: Ari1009 --- go/tools/asthelpergen/asthelpergen_test.go | 5 +- go/trace/trace_test.go | 4 +- go/vt/binlog/binlog_streamer_rbr_test.go | 19 ++-- go/vt/binlog/tables_filter_test.go | 17 +-- go/vt/wrangler/tablet_test.go | 115 +++++++++------------ go/vt/wrangler/vexec_test.go | 9 +- go/vt/zkctl/zkctl_test.go | 39 +++---- 7 files changed, 83 insertions(+), 125 deletions(-) diff --git a/go/tools/asthelpergen/asthelpergen_test.go b/go/tools/asthelpergen/asthelpergen_test.go index ce5a59c84e7..bfe2ba1e1e5 100644 --- a/go/tools/asthelpergen/asthelpergen_test.go +++ b/go/tools/asthelpergen/asthelpergen_test.go @@ -21,6 +21,7 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -42,8 +43,6 @@ func TestFullGeneration(t *testing.T) { require.Contains(t, contents, "http://www.apache.org/licenses/LICENSE-2.0") applyIdx := strings.Index(contents, "func (a *application) apply(parent, node AST, replacer replacerFunc)") cloneIdx := strings.Index(contents, "CloneAST(in AST) AST") - if applyIdx == 0 && cloneIdx == 0 { - t.Fatalf("file doesn't contain expected contents") - } + assert.False(t, applyIdx == 0 && cloneIdx == 0, "file doesn't contain expected contents") } } diff --git a/go/trace/trace_test.go b/go/trace/trace_test.go index 7f1f6d8c528..88071b8d5ad 100644 --- a/go/trace/trace_test.go +++ b/go/trace/trace_test.go @@ -62,11 +62,11 @@ func TestRegisterService(t *testing.T) { closer := StartTracing(serviceName) tracer, ok := closer.(*fakeTracer) if !ok { - t.Fatalf("did not get the expected tracer, got %+v (%T)", tracer, tracer) + require.FailNow(t, fmt.Sprintf("did not get the expected tracer, got %+v (%T)", tracer, tracer)) } if tracer.name != serviceName { - t.Fatalf("expected the name to be `%v` but it was `%v`", serviceName, tracer.name) + require.FailNow(t, fmt.Sprintf("expected the name to be `%v` but it was `%v`", serviceName, tracer.name)) } } diff --git a/go/vt/binlog/binlog_streamer_rbr_test.go b/go/vt/binlog/binlog_streamer_rbr_test.go index 1678b086719..f6afac3a113 100644 --- a/go/vt/binlog/binlog_streamer_rbr_test.go +++ b/go/vt/binlog/binlog_streamer_rbr_test.go @@ -21,6 +21,8 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/mysql/binlog" "vitess.io/vitess/go/mysql/collations" @@ -519,17 +521,12 @@ func TestStreamerParseRBRNameEscapes(t *testing.T) { go sendTestEvents(events, input) _, err := bls.parseEvents(context.Background(), events, errs) - if err != ErrServerEOF { - t.Errorf("unexpected error: %v", err) - } + require.Equal(t, ErrServerEOF, err, "unexpected error: %v", err) - if !reflect.DeepEqual(got, want) { - t.Errorf("binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) - for i, fbt := range got { - t.Errorf("Got (%v)=%v", i, fbt.statements) - } - for i, fbt := range want { - t.Errorf("Want(%v)=%v", i, fbt.statements) - } + assert.True(t, reflect.DeepEqual(got, want), "binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) + + for i, fbt := range got { + assert.Equal(t, fbt.statements, want[i].statements, "Got (%v)=%v, want (%v)=%v", i, fbt.statements, i, want[i].statements) } + } diff --git a/go/vt/binlog/tables_filter_test.go b/go/vt/binlog/tables_filter_test.go index 0c6aeef3fcc..4818615dc4f 100644 --- a/go/vt/binlog/tables_filter_test.go +++ b/go/vt/binlog/tables_filter_test.go @@ -20,6 +20,7 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/assert" binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" querypb "vitess.io/vitess/go/vt/proto/query" ) @@ -60,9 +61,7 @@ func TestTablesFilterPass(t *testing.T) { }) _ = f(eventToken, statements) want := `statement: <6, "set1"> statement: <7, "dml1 /* _stream included1 (id ) (500 ); */"> statement: <7, "dml2 /* _stream included2 (id ) (500 ); */"> position: "MariaDB/0-41983-1" ` - if want != got { - t.Errorf("want\n%s, got\n%s", want, got) - } + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) } func TestTablesFilterSkip(t *testing.T) { @@ -90,9 +89,7 @@ func TestTablesFilterSkip(t *testing.T) { }) _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` - if want != got { - t.Errorf("want %s, got %s", want, got) - } + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) } func TestTablesFilterDDL(t *testing.T) { @@ -120,9 +117,7 @@ func TestTablesFilterDDL(t *testing.T) { }) _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` - if want != got { - t.Errorf("want %s, got %s", want, got) - } + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) } func TestTablesFilterMalformed(t *testing.T) { @@ -156,9 +151,7 @@ func TestTablesFilterMalformed(t *testing.T) { }) _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` - if want != got { - t.Errorf("want %s, got %s", want, got) - } + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) } func bltToString(tx *binlogdatapb.BinlogTransaction) string { diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index c5ae032fe07..5943e5a8ba7 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -18,9 +18,9 @@ package wrangler import ( "context" - "strings" "testing" + "github.com/stretchr/testify/require" "vitess.io/vitess/go/vt/logutil" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/topo" @@ -48,20 +48,14 @@ func TestInitTabletShardConversion(t *testing.T) { Shard: "80-C0", } - if err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/); err != nil { - t.Fatalf("InitTablet failed: %v", err) - } + err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) + require.NoError(t, err, "InitTablet failed") ti, err := ts.GetTablet(context.Background(), tablet.Alias) - if err != nil { - t.Fatalf("GetTablet failed: %v", err) - } - if ti.Shard != "80-c0" { - t.Errorf("Got wrong tablet.Shard, got %v expected 80-c0", ti.Shard) - } - if string(ti.KeyRange.Start) != "\x80" || string(ti.KeyRange.End) != "\xc0" { - t.Errorf("Got wrong tablet.KeyRange, got %v expected 80-c0", ti.KeyRange) - } + require.NoError(t, err, "GetTablet failed") + require.Equal(t, "80-c0", ti.Shard, "Got wrong tablet.Shard") + require.Equal(t, "\x80", string(ti.KeyRange.Start), "Got wrong tablet.KeyRange start") + require.Equal(t, "\xc0", string(ti.KeyRange.End), "Got wrong tablet.KeyRange end") } // TestDeleteTabletBasic tests delete of non-primary tablet @@ -82,17 +76,14 @@ func TestDeleteTabletBasic(t *testing.T) { Keyspace: "test", } - if err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/); err != nil { - t.Fatalf("InitTablet failed: %v", err) - } + err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) + require.NoError(t, err, "InitTablet failed") - if _, err := ts.GetTablet(context.Background(), tablet.Alias); err != nil { - t.Fatalf("GetTablet failed: %v", err) - } + _, err = ts.GetTablet(context.Background(), tablet.Alias) + require.NoError(t, err, "GetTablet failed") - if err := wr.DeleteTablet(context.Background(), tablet.Alias, false); err != nil { - t.Fatalf("DeleteTablet failed: %v", err) - } + err = wr.DeleteTablet(context.Background(), tablet.Alias, false) + require.NoError(t, err, "DeleteTablet failed") } // TestDeleteTabletTruePrimary tests that you can delete a true primary tablet @@ -115,31 +106,27 @@ func TestDeleteTabletTruePrimary(t *testing.T) { Type: topodatapb.TabletType_PRIMARY, } - if err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/); err != nil { - t.Fatalf("InitTablet failed: %v", err) - } - if _, err := ts.GetTablet(context.Background(), tablet.Alias); err != nil { - t.Fatalf("GetTablet failed: %v", err) - } + err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) + require.NoError(t, err, "InitTablet failed") + + _, err = ts.GetTablet(context.Background(), tablet.Alias) + require.NoError(t, err, "GetTablet failed") // set PrimaryAlias and PrimaryTermStartTime on shard to match chosen primary tablet - if _, err := ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { + _, err = ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { si.PrimaryAlias = tablet.Alias si.PrimaryTermStartTime = tablet.PrimaryTermStartTime return nil - }); err != nil { - t.Fatalf("UpdateShardFields failed: %v", err) - } + }) + require.NoError(t, err, "UpdateShardFields failed") - err := wr.DeleteTablet(context.Background(), tablet.Alias, false) + err = wr.DeleteTablet(context.Background(), tablet.Alias, false) wantError := "as it is a primary, use allow_primary flag" - if err == nil || !strings.Contains(err.Error(), wantError) { - t.Fatalf("DeleteTablet on primary: want error = %v, got error = %v", wantError, err) - } + require.Error(t, err, "DeleteTablet on primary: want error") + require.Contains(t, err.Error(), wantError, "DeleteTablet on primary: want specific error message") - if err := wr.DeleteTablet(context.Background(), tablet.Alias, true); err != nil { - t.Fatalf("DeleteTablet failed: %v", err) - } + err = wr.DeleteTablet(context.Background(), tablet.Alias, true) + require.NoError(t, err, "DeleteTablet failed") } // TestDeleteTabletFalsePrimary tests that you can delete a false primary tablet @@ -162,9 +149,8 @@ func TestDeleteTabletFalsePrimary(t *testing.T) { Type: topodatapb.TabletType_PRIMARY, } - if err := wr.TopoServer().InitTablet(context.Background(), tablet1, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/); err != nil { - t.Fatalf("InitTablet failed: %v", err) - } + err := wr.TopoServer().InitTablet(context.Background(), tablet1, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) + require.NoError(t, err, "InitTablet failed") tablet2 := &topodatapb.Tablet{ Alias: &topodatapb.TabletAlias{ @@ -175,23 +161,20 @@ func TestDeleteTabletFalsePrimary(t *testing.T) { Shard: "0", Type: topodatapb.TabletType_PRIMARY, } - if err := wr.TopoServer().InitTablet(context.Background(), tablet2, true /*allowPrimaryOverride*/, false /*createShardAndKeyspace*/, false /*allowUpdate*/); err != nil { - t.Fatalf("InitTablet failed: %v", err) - } + err = wr.TopoServer().InitTablet(context.Background(), tablet2, true /*allowPrimaryOverride*/, false /*createShardAndKeyspace*/, false /*allowUpdate*/) + require.NoError(t, err, "InitTablet failed") // set PrimaryAlias and PrimaryTermStartTime on shard to match chosen primary tablet - if _, err := ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { + _, err = ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { si.PrimaryAlias = tablet2.Alias si.PrimaryTermStartTime = tablet2.PrimaryTermStartTime return nil - }); err != nil { - t.Fatalf("UpdateShardFields failed: %v", err) - } + }) + require.NoError(t, err, "UpdateShardFields failed") // Should be able to delete old (false) primary with allowPrimary = false - if err := wr.DeleteTablet(context.Background(), tablet1.Alias, false); err != nil { - t.Fatalf("DeleteTablet failed: %v", err) - } + err = wr.DeleteTablet(context.Background(), tablet1.Alias, false) + require.NoError(t, err, "DeleteTablet failed") } // TestDeleteTabletShardNonExisting tests that you can delete a true primary @@ -214,29 +197,25 @@ func TestDeleteTabletShardNonExisting(t *testing.T) { Type: topodatapb.TabletType_PRIMARY, } - if err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/); err != nil { - t.Fatalf("InitTablet failed: %v", err) - } - if _, err := ts.GetTablet(context.Background(), tablet.Alias); err != nil { - t.Fatalf("GetTablet failed: %v", err) - } + err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) + require.NoError(t, err, "InitTablet failed") + + _, err = ts.GetTablet(context.Background(), tablet.Alias) + require.NoError(t, err, "GetTablet failed") // set PrimaryAlias and PrimaryTermStartTime on shard to match chosen primary tablet - if _, err := ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { + _, err = ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { si.PrimaryAlias = tablet.Alias si.PrimaryTermStartTime = tablet.PrimaryTermStartTime return nil - }); err != nil { - t.Fatalf("UpdateShardFields failed: %v", err) - } + }) + require.NoError(t, err, "UpdateShardFields failed") // trigger a shard deletion - if err := ts.DeleteShard(context.Background(), "test", "0"); err != nil { - t.Fatalf("DeleteShard failed: %v", err) - } + err = ts.DeleteShard(context.Background(), "test", "0") + require.NoError(t, err, "DeleteShard failed") // DeleteTablet should not fail if a shard no longer exist - if err := wr.DeleteTablet(context.Background(), tablet.Alias, true); err != nil { - t.Fatalf("DeleteTablet failed: %v", err) - } + err = wr.DeleteTablet(context.Background(), tablet.Alias, true) + require.NoError(t, err, "DeleteTablet failed") } diff --git a/go/vt/wrangler/vexec_test.go b/go/vt/wrangler/vexec_test.go index 27efbe61a9f..c6897493c16 100644 --- a/go/vt/wrangler/vexec_test.go +++ b/go/vt/wrangler/vexec_test.go @@ -26,6 +26,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "vitess.io/vitess/go/sqltypes" @@ -151,15 +152,11 @@ func TestVExec(t *testing.T) { if testCase.errorString == "" { require.NoError(t, err) for _, result := range results { - if !testCase.result.Equal(result) { - t.Errorf("mismatched result:\nwant: %v\ngot: %v", testCase.result, result) - } + assert.True(t, testCase.result.Equal(result), "mismatched result:\nwant: %v\ngot: %v", testCase.result, result) } } else { require.Error(t, err) - if !strings.Contains(err.Error(), testCase.errorString) { - t.Fatalf("Wrong error, want %s, got %s", testCase.errorString, err.Error()) - } + assert.Contains(t, err.Error(), testCase.errorString, "Wrong error, want %s, got %s", testCase.errorString, err.Error()) } }) } diff --git a/go/vt/zkctl/zkctl_test.go b/go/vt/zkctl/zkctl_test.go index 5e4c856b5a7..e28a24e7821 100644 --- a/go/vt/zkctl/zkctl_test.go +++ b/go/vt/zkctl/zkctl_test.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -13,13 +13,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - package zkctl import ( "fmt" - "strings" "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // This test depend on starting and stopping a ZK instance, @@ -39,29 +40,21 @@ func TestLifeCycle(t *testing.T) { adminServerCfg := "admin.serverPort=8081" zkConf.Extra = []string{tpcKeepAliveCfg, adminServerCfg} - if zkObservedConf, err := MakeZooCfg([]string{zkConf.ConfigFile()}, zkConf, "header"); err != nil { - t.Fatalf("MakeZooCfg err: %v", err) - } else if !strings.Contains(zkObservedConf, fmt.Sprintf("\n%s\n", tpcKeepAliveCfg)) { - t.Fatalf("Expected tpcKeepAliveCfg in zkObservedConf") - } else if !strings.Contains(zkObservedConf, fmt.Sprintf("\n%s\n", adminServerCfg)) { - t.Fatalf("Expected adminServerCfg in zkObservedConf") - } + zkObservedConf, err := MakeZooCfg([]string{zkConf.ConfigFile()}, zkConf, "header") + require.NoError(t, err, "MakeZooCfg err: %v", err) + assert.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", tpcKeepAliveCfg), "Expected tpcKeepAliveCfg in zkObservedConf") + assert.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", adminServerCfg), "Expected adminServerCfg in zkObservedConf") zkd := NewZkd(zkConf) - if err := zkd.Init(); err != nil { - t.Fatalf("Init() err: %v", err) - } + err = zkd.Init() + require.NoError(t, err, "Init() err: %v", err) - if err := zkd.Shutdown(); err != nil { - t.Fatalf("Shutdown() err: %v", err) - } - - if err := zkd.Start(); err != nil { - t.Fatalf("Start() err: %v", err) - } + err = zkd.Shutdown() + require.NoError(t, err, "Shutdown() err: %v", err) - if err := zkd.Teardown(); err != nil { - t.Fatalf("Teardown() err: %v", err) - } + err = zkd.Start() + require.NoError(t, err, "Start() err: %v", err) + err = zkd.Teardown() + require.NoError(t, err, "Teardown() err: %v", err) } From 6b67e76198ece91a71ddfe5e838b91f53a98e8db Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Mon, 3 Jun 2024 12:32:36 +0530 Subject: [PATCH 2/8] update Signed-off-by: Ari1009 --- go/tools/asthelpergen/asthelpergen_test.go | 5 ++-- go/vt/binlog/binlog_streamer_rbr_test.go | 27 ++++------------------ go/vt/binlog/tables_filter_test.go | 6 ++--- go/vt/wrangler/tablet_test.go | 3 +-- go/vt/wrangler/vexec_test.go | 6 ++--- go/vt/zkctl/zkctl_test.go | 5 ++-- 6 files changed, 15 insertions(+), 37 deletions(-) diff --git a/go/tools/asthelpergen/asthelpergen_test.go b/go/tools/asthelpergen/asthelpergen_test.go index bfe2ba1e1e5..ee2a6b19428 100644 --- a/go/tools/asthelpergen/asthelpergen_test.go +++ b/go/tools/asthelpergen/asthelpergen_test.go @@ -8,7 +8,7 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, +distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. @@ -21,7 +21,6 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -43,6 +42,6 @@ func TestFullGeneration(t *testing.T) { require.Contains(t, contents, "http://www.apache.org/licenses/LICENSE-2.0") applyIdx := strings.Index(contents, "func (a *application) apply(parent, node AST, replacer replacerFunc)") cloneIdx := strings.Index(contents, "CloneAST(in AST) AST") - assert.False(t, applyIdx == 0 && cloneIdx == 0, "file doesn't contain expected contents") + require.False(t, applyIdx == 0 && cloneIdx == 0, "file doesn't contain expected contents") } } diff --git a/go/vt/binlog/binlog_streamer_rbr_test.go b/go/vt/binlog/binlog_streamer_rbr_test.go index f6afac3a113..cb20fe207fd 100644 --- a/go/vt/binlog/binlog_streamer_rbr_test.go +++ b/go/vt/binlog/binlog_streamer_rbr_test.go @@ -18,11 +18,9 @@ package binlog import ( "context" - "reflect" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/mysql/binlog" "vitess.io/vitess/go/mysql/collations" @@ -272,19 +270,8 @@ func TestStreamerParseRBREvents(t *testing.T) { go sendTestEvents(events, input) _, err := bls.parseEvents(context.Background(), events, errs) - if err != ErrServerEOF { - t.Errorf("unexpected error: %v", err) - } - - if !reflect.DeepEqual(got, want) { - t.Errorf("binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) - for i, fbt := range got { - t.Errorf("Got (%v)=%v", i, fbt.statements) - } - for i, fbt := range want { - t.Errorf("Want(%v)=%v", i, fbt.statements) - } - } + assert.EqualError(t, err, ErrServerEOF.Error(), "unexpected error") + assert.Equal(t, want, got, "binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) } func TestStreamerParseRBRNameEscapes(t *testing.T) { @@ -521,12 +508,6 @@ func TestStreamerParseRBRNameEscapes(t *testing.T) { go sendTestEvents(events, input) _, err := bls.parseEvents(context.Background(), events, errs) - require.Equal(t, ErrServerEOF, err, "unexpected error: %v", err) - - assert.True(t, reflect.DeepEqual(got, want), "binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) - - for i, fbt := range got { - assert.Equal(t, fbt.statements, want[i].statements, "Got (%v)=%v, want (%v)=%v", i, fbt.statements, i, want[i].statements) - } - + assert.EqualError(t, err, ErrServerEOF.Error(), "unexpected error") + assert.Equal(t, want, got, "binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) } diff --git a/go/vt/binlog/tables_filter_test.go b/go/vt/binlog/tables_filter_test.go index 4818615dc4f..17ff9599d71 100644 --- a/go/vt/binlog/tables_filter_test.go +++ b/go/vt/binlog/tables_filter_test.go @@ -89,7 +89,7 @@ func TestTablesFilterSkip(t *testing.T) { }) _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` - assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc()") } func TestTablesFilterDDL(t *testing.T) { @@ -117,7 +117,7 @@ func TestTablesFilterDDL(t *testing.T) { }) _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` - assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc()") } func TestTablesFilterMalformed(t *testing.T) { @@ -151,7 +151,7 @@ func TestTablesFilterMalformed(t *testing.T) { }) _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` - assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc()") } func bltToString(tx *binlogdatapb.BinlogTransaction) string { diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index 5943e5a8ba7..409acf85ac3 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -122,8 +122,7 @@ func TestDeleteTabletTruePrimary(t *testing.T) { err = wr.DeleteTablet(context.Background(), tablet.Alias, false) wantError := "as it is a primary, use allow_primary flag" - require.Error(t, err, "DeleteTablet on primary: want error") - require.Contains(t, err.Error(), wantError, "DeleteTablet on primary: want specific error message") + require.ErrorContains(t, err, wantError, "DeleteTablet on primary: want specific error message") err = wr.DeleteTablet(context.Background(), tablet.Alias, true) require.NoError(t, err, "DeleteTablet failed") diff --git a/go/vt/wrangler/vexec_test.go b/go/vt/wrangler/vexec_test.go index c6897493c16..80cd2aef565 100644 --- a/go/vt/wrangler/vexec_test.go +++ b/go/vt/wrangler/vexec_test.go @@ -152,11 +152,11 @@ func TestVExec(t *testing.T) { if testCase.errorString == "" { require.NoError(t, err) for _, result := range results { - assert.True(t, testCase.result.Equal(result), "mismatched result:\nwant: %v\ngot: %v", testCase.result, result) + assert.True(t, testCase.result.Equal(result), "mismatched result") } } else { - require.Error(t, err) - assert.Contains(t, err.Error(), testCase.errorString, "Wrong error, want %s, got %s", testCase.errorString, err.Error()) + require.ErrorContains(t, err, testCase.errorString, "Wrong error, want %s, got %s", testCase.errorString, err.Error()) + } }) } diff --git a/go/vt/zkctl/zkctl_test.go b/go/vt/zkctl/zkctl_test.go index e28a24e7821..3fa1b9ee0f8 100644 --- a/go/vt/zkctl/zkctl_test.go +++ b/go/vt/zkctl/zkctl_test.go @@ -19,7 +19,6 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -42,8 +41,8 @@ func TestLifeCycle(t *testing.T) { zkObservedConf, err := MakeZooCfg([]string{zkConf.ConfigFile()}, zkConf, "header") require.NoError(t, err, "MakeZooCfg err: %v", err) - assert.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", tpcKeepAliveCfg), "Expected tpcKeepAliveCfg in zkObservedConf") - assert.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", adminServerCfg), "Expected adminServerCfg in zkObservedConf") + require.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", tpcKeepAliveCfg), "Expected tpcKeepAliveCfg in zkObservedConf") + require.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", adminServerCfg), "Expected adminServerCfg in zkObservedConf") zkd := NewZkd(zkConf) err = zkd.Init() From 91d9c25909d0715c44be6ab231b655e518fb17a9 Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Mon, 3 Jun 2024 12:39:21 +0530 Subject: [PATCH 3/8] Update_2 Signed-off-by: Ari1009 --- go/tools/asthelpergen/asthelpergen_test.go | 2 +- go/vt/binlog/tables_filter_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/tools/asthelpergen/asthelpergen_test.go b/go/tools/asthelpergen/asthelpergen_test.go index ee2a6b19428..fd0e8b42daa 100644 --- a/go/tools/asthelpergen/asthelpergen_test.go +++ b/go/tools/asthelpergen/asthelpergen_test.go @@ -8,7 +8,7 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software -distributed on an "AS IS" BASIS, +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/go/vt/binlog/tables_filter_test.go b/go/vt/binlog/tables_filter_test.go index 17ff9599d71..2564e85d972 100644 --- a/go/vt/binlog/tables_filter_test.go +++ b/go/vt/binlog/tables_filter_test.go @@ -61,7 +61,7 @@ func TestTablesFilterPass(t *testing.T) { }) _ = f(eventToken, statements) want := `statement: <6, "set1"> statement: <7, "dml1 /* _stream included1 (id ) (500 ); */"> statement: <7, "dml2 /* _stream included2 (id ) (500 ); */"> position: "MariaDB/0-41983-1" ` - assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc(): got:\n%+v\nwant:\n%+v", got, want) + assert.Equal(t, want, got, "binlogConnStreamer.tablesFilterFunc()") } func TestTablesFilterSkip(t *testing.T) { From 42395660258caa76b78bd070911108330ed8979c Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Mon, 3 Jun 2024 17:20:48 +0530 Subject: [PATCH 4/8] Updates_3 Signed-off-by: Ari1009 --- go/trace/trace_test.go | 8 ++------ go/vt/binlog/binlog_streamer_rbr_test.go | 5 +++-- go/vt/binlog/tables_filter_test.go | 1 + go/vt/wrangler/tablet_test.go | 1 + 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/go/trace/trace_test.go b/go/trace/trace_test.go index 88071b8d5ad..660f9bd5aea 100644 --- a/go/trace/trace_test.go +++ b/go/trace/trace_test.go @@ -61,13 +61,9 @@ func TestRegisterService(t *testing.T) { serviceName := "vtservice" closer := StartTracing(serviceName) tracer, ok := closer.(*fakeTracer) - if !ok { - require.FailNow(t, fmt.Sprintf("did not get the expected tracer, got %+v (%T)", tracer, tracer)) - } + require.True(t, ok, fmt.Sprintf("did not get the expected tracer, got %+v (%T)", tracer, tracer)) + require.Equal(t, serviceName, tracer.name) - if tracer.name != serviceName { - require.FailNow(t, fmt.Sprintf("expected the name to be `%v` but it was `%v`", serviceName, tracer.name)) - } } func TestNewFromString(t *testing.T) { diff --git a/go/vt/binlog/binlog_streamer_rbr_test.go b/go/vt/binlog/binlog_streamer_rbr_test.go index cb20fe207fd..6ae9bc4afcf 100644 --- a/go/vt/binlog/binlog_streamer_rbr_test.go +++ b/go/vt/binlog/binlog_streamer_rbr_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/mysql/binlog" "vitess.io/vitess/go/mysql/collations" @@ -271,7 +272,7 @@ func TestStreamerParseRBREvents(t *testing.T) { go sendTestEvents(events, input) _, err := bls.parseEvents(context.Background(), events, errs) assert.EqualError(t, err, ErrServerEOF.Error(), "unexpected error") - assert.Equal(t, want, got, "binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) + assert.Equal(t, want, got, "binlogConnStreamer.parseEvents()") } func TestStreamerParseRBRNameEscapes(t *testing.T) { @@ -509,5 +510,5 @@ func TestStreamerParseRBRNameEscapes(t *testing.T) { go sendTestEvents(events, input) _, err := bls.parseEvents(context.Background(), events, errs) assert.EqualError(t, err, ErrServerEOF.Error(), "unexpected error") - assert.Equal(t, want, got, "binlogConnStreamer.parseEvents(): got:\n%+v\nwant:\n%+v", got, want) + assert.Equal(t, want, got, "binlogConnStreamer.parseEvents()") } diff --git a/go/vt/binlog/tables_filter_test.go b/go/vt/binlog/tables_filter_test.go index 2564e85d972..c65f64b5aef 100644 --- a/go/vt/binlog/tables_filter_test.go +++ b/go/vt/binlog/tables_filter_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" querypb "vitess.io/vitess/go/vt/proto/query" ) diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index 409acf85ac3..bcda9621b0f 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "vitess.io/vitess/go/vt/logutil" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/vt/topo" From 3c10f000e1d00f8a31c75da31d1bbcbf37a6e97e Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Tue, 4 Jun 2024 20:19:15 +0530 Subject: [PATCH 5/8] Update_4 Signed-off-by: Ari1009 --- go/tools/asthelpergen/asthelpergen_test.go | 2 +- go/trace/trace_test.go | 5 ++--- go/vt/wrangler/tablet_test.go | 2 +- go/vt/zkctl/zkctl_test.go | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/tools/asthelpergen/asthelpergen_test.go b/go/tools/asthelpergen/asthelpergen_test.go index fd0e8b42daa..19ac865575d 100644 --- a/go/tools/asthelpergen/asthelpergen_test.go +++ b/go/tools/asthelpergen/asthelpergen_test.go @@ -8,7 +8,7 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/go/trace/trace_test.go b/go/trace/trace_test.go index 660f9bd5aea..688d60551e3 100644 --- a/go/trace/trace_test.go +++ b/go/trace/trace_test.go @@ -60,10 +60,9 @@ func TestRegisterService(t *testing.T) { serviceName := "vtservice" closer := StartTracing(serviceName) - tracer, ok := closer.(*fakeTracer) - require.True(t, ok, fmt.Sprintf("did not get the expected tracer, got %+v (%T)", tracer, tracer)) - require.Equal(t, serviceName, tracer.name) + tracer := closer.(*fakeTracer) + require.Equal(t, serviceName, tracer.name, fmt.Sprintf("tracer name mismatch: expected %s, got %s", serviceName, tracer.name)) } func TestNewFromString(t *testing.T) { diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index bcda9621b0f..87748d60d58 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -50,7 +50,7 @@ func TestInitTabletShardConversion(t *testing.T) { } err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) - require.NoError(t, err, "InitTablet failed") + require.NoError(t, err) ti, err := ts.GetTablet(context.Background(), tablet.Alias) require.NoError(t, err, "GetTablet failed") diff --git a/go/vt/zkctl/zkctl_test.go b/go/vt/zkctl/zkctl_test.go index 3fa1b9ee0f8..824e7b7739c 100644 --- a/go/vt/zkctl/zkctl_test.go +++ b/go/vt/zkctl/zkctl_test.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + package zkctl import ( From 6b4b485bfffb49fbd9daefba63a8d5ecd1409c93 Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Tue, 4 Jun 2024 22:52:01 +0530 Subject: [PATCH 6/8] Remove_UnecessaryPrint Signed-off-by: Ari1009 --- go/vt/wrangler/tablet_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index 87748d60d58..b59fe40f3e4 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -78,7 +78,7 @@ func TestDeleteTabletBasic(t *testing.T) { } err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) - require.NoError(t, err, "InitTablet failed") + require.NoError(t, err) _, err = ts.GetTablet(context.Background(), tablet.Alias) require.NoError(t, err, "GetTablet failed") @@ -108,7 +108,7 @@ func TestDeleteTabletTruePrimary(t *testing.T) { } err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) - require.NoError(t, err, "InitTablet failed") + require.NoError(t, err) _, err = ts.GetTablet(context.Background(), tablet.Alias) require.NoError(t, err, "GetTablet failed") @@ -150,7 +150,7 @@ func TestDeleteTabletFalsePrimary(t *testing.T) { } err := wr.TopoServer().InitTablet(context.Background(), tablet1, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) - require.NoError(t, err, "InitTablet failed") + require.NoError(t, err) tablet2 := &topodatapb.Tablet{ Alias: &topodatapb.TabletAlias{ @@ -162,7 +162,7 @@ func TestDeleteTabletFalsePrimary(t *testing.T) { Type: topodatapb.TabletType_PRIMARY, } err = wr.TopoServer().InitTablet(context.Background(), tablet2, true /*allowPrimaryOverride*/, false /*createShardAndKeyspace*/, false /*allowUpdate*/) - require.NoError(t, err, "InitTablet failed") + require.NoError(t, err) // set PrimaryAlias and PrimaryTermStartTime on shard to match chosen primary tablet _, err = ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { @@ -198,7 +198,7 @@ func TestDeleteTabletShardNonExisting(t *testing.T) { } err := wr.TopoServer().InitTablet(context.Background(), tablet, false /*allowPrimaryOverride*/, true /*createShardAndKeyspace*/, false /*allowUpdate*/) - require.NoError(t, err, "InitTablet failed") + require.NoError(t, err) _, err = ts.GetTablet(context.Background(), tablet.Alias) require.NoError(t, err, "GetTablet failed") From e03a73508fed30e3c717fb01a63392a8ba2946a5 Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Wed, 5 Jun 2024 00:02:59 +0530 Subject: [PATCH 7/8] cleanup Signed-off-by: Ari1009 --- go/vt/wrangler/tablet_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index b59fe40f3e4..897086283df 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -53,7 +53,7 @@ func TestInitTabletShardConversion(t *testing.T) { require.NoError(t, err) ti, err := ts.GetTablet(context.Background(), tablet.Alias) - require.NoError(t, err, "GetTablet failed") + require.NoError(t, err) require.Equal(t, "80-c0", ti.Shard, "Got wrong tablet.Shard") require.Equal(t, "\x80", string(ti.KeyRange.Start), "Got wrong tablet.KeyRange start") require.Equal(t, "\xc0", string(ti.KeyRange.End), "Got wrong tablet.KeyRange end") @@ -81,7 +81,7 @@ func TestDeleteTabletBasic(t *testing.T) { require.NoError(t, err) _, err = ts.GetTablet(context.Background(), tablet.Alias) - require.NoError(t, err, "GetTablet failed") + require.NoError(t, err) err = wr.DeleteTablet(context.Background(), tablet.Alias, false) require.NoError(t, err, "DeleteTablet failed") @@ -111,7 +111,7 @@ func TestDeleteTabletTruePrimary(t *testing.T) { require.NoError(t, err) _, err = ts.GetTablet(context.Background(), tablet.Alias) - require.NoError(t, err, "GetTablet failed") + require.NoError(t, err) // set PrimaryAlias and PrimaryTermStartTime on shard to match chosen primary tablet _, err = ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { @@ -217,5 +217,5 @@ func TestDeleteTabletShardNonExisting(t *testing.T) { // DeleteTablet should not fail if a shard no longer exist err = wr.DeleteTablet(context.Background(), tablet.Alias, true) - require.NoError(t, err, "DeleteTablet failed") + require.NoError(t, err) } From 49876f35ed253270e29c5535710820f5baec82db Mon Sep 17 00:00:00 2001 From: Ari1009 Date: Wed, 5 Jun 2024 10:53:31 +0530 Subject: [PATCH 8/8] Cleanup_2 Signed-off-by: Ari1009 --- go/vt/wrangler/tablet_test.go | 16 ++++++++-------- go/vt/zkctl/zkctl_test.go | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/go/vt/wrangler/tablet_test.go b/go/vt/wrangler/tablet_test.go index 897086283df..113743d9c19 100644 --- a/go/vt/wrangler/tablet_test.go +++ b/go/vt/wrangler/tablet_test.go @@ -84,7 +84,7 @@ func TestDeleteTabletBasic(t *testing.T) { require.NoError(t, err) err = wr.DeleteTablet(context.Background(), tablet.Alias, false) - require.NoError(t, err, "DeleteTablet failed") + require.NoError(t, err) } // TestDeleteTabletTruePrimary tests that you can delete a true primary tablet @@ -119,14 +119,14 @@ func TestDeleteTabletTruePrimary(t *testing.T) { si.PrimaryTermStartTime = tablet.PrimaryTermStartTime return nil }) - require.NoError(t, err, "UpdateShardFields failed") + require.NoError(t, err) err = wr.DeleteTablet(context.Background(), tablet.Alias, false) wantError := "as it is a primary, use allow_primary flag" require.ErrorContains(t, err, wantError, "DeleteTablet on primary: want specific error message") err = wr.DeleteTablet(context.Background(), tablet.Alias, true) - require.NoError(t, err, "DeleteTablet failed") + require.NoError(t, err) } // TestDeleteTabletFalsePrimary tests that you can delete a false primary tablet @@ -170,11 +170,11 @@ func TestDeleteTabletFalsePrimary(t *testing.T) { si.PrimaryTermStartTime = tablet2.PrimaryTermStartTime return nil }) - require.NoError(t, err, "UpdateShardFields failed") + require.NoError(t, err) // Should be able to delete old (false) primary with allowPrimary = false err = wr.DeleteTablet(context.Background(), tablet1.Alias, false) - require.NoError(t, err, "DeleteTablet failed") + require.NoError(t, err) } // TestDeleteTabletShardNonExisting tests that you can delete a true primary @@ -201,7 +201,7 @@ func TestDeleteTabletShardNonExisting(t *testing.T) { require.NoError(t, err) _, err = ts.GetTablet(context.Background(), tablet.Alias) - require.NoError(t, err, "GetTablet failed") + require.NoError(t, err) // set PrimaryAlias and PrimaryTermStartTime on shard to match chosen primary tablet _, err = ts.UpdateShardFields(context.Background(), "test", "0", func(si *topo.ShardInfo) error { @@ -209,11 +209,11 @@ func TestDeleteTabletShardNonExisting(t *testing.T) { si.PrimaryTermStartTime = tablet.PrimaryTermStartTime return nil }) - require.NoError(t, err, "UpdateShardFields failed") + require.NoError(t, err) // trigger a shard deletion err = ts.DeleteShard(context.Background(), "test", "0") - require.NoError(t, err, "DeleteShard failed") + require.NoError(t, err) // DeleteTablet should not fail if a shard no longer exist err = wr.DeleteTablet(context.Background(), tablet.Alias, true) diff --git a/go/vt/zkctl/zkctl_test.go b/go/vt/zkctl/zkctl_test.go index 824e7b7739c..a0c03a58df2 100644 --- a/go/vt/zkctl/zkctl_test.go +++ b/go/vt/zkctl/zkctl_test.go @@ -41,20 +41,20 @@ func TestLifeCycle(t *testing.T) { zkConf.Extra = []string{tpcKeepAliveCfg, adminServerCfg} zkObservedConf, err := MakeZooCfg([]string{zkConf.ConfigFile()}, zkConf, "header") - require.NoError(t, err, "MakeZooCfg err: %v", err) + require.NoError(t, err) require.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", tpcKeepAliveCfg), "Expected tpcKeepAliveCfg in zkObservedConf") require.Contains(t, zkObservedConf, fmt.Sprintf("\n%s\n", adminServerCfg), "Expected adminServerCfg in zkObservedConf") zkd := NewZkd(zkConf) err = zkd.Init() - require.NoError(t, err, "Init() err: %v", err) + require.NoError(t, err) err = zkd.Shutdown() - require.NoError(t, err, "Shutdown() err: %v", err) + require.NoError(t, err) err = zkd.Start() - require.NoError(t, err, "Start() err: %v", err) + require.NoError(t, err) err = zkd.Teardown() - require.NoError(t, err, "Teardown() err: %v", err) + require.NoError(t, err) }