Skip to content

Commit

Permalink
Backport go_srcs_in_module changes and fix goword failures.
Browse files Browse the repository at this point in the history
Signed-off-by: James Blair <mail@jamesblair.net>
  • Loading branch information
jmhbnz committed Feb 24, 2023
1 parent 183af50 commit 1ea808b
Show file tree
Hide file tree
Showing 42 changed files with 121 additions and 313 deletions.
2 changes: 1 addition & 1 deletion api/etcdserverpb/raft_internal_stringer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
)

// TestInvalidGoYypeIntPanic tests conditions that caused
// TestInvalidGoTypeIntPanic tests conditions that caused
// panic: invalid Go type int for field k8s_io.kubernetes.vendor.go_etcd_io.etcd.etcdserver.etcdserverpb.loggablePutRequest.value_size
// See https://github.com/kubernetes/kubernetes/issues/91937 for more details
func TestInvalidGoTypeIntPanic(t *testing.T) {
Expand Down
55 changes: 0 additions & 55 deletions etcdctl/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion etcdctl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func SplitTestArgs(args []string) (testArgs, appArgs []string) {
return
}

// Empty test to avoid no-tests warning.
// TestEmpty to avoid no-tests warning.
func TestEmpty(t *testing.T) {}

/**
Expand Down
55 changes: 0 additions & 55 deletions etcdutl/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion etcdutl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func SplitTestArgs(args []string) (testArgs, appArgs []string) {
return
}

// Empty test to avoid no-tests warning.
// TestEmpty to avoid no-tests warning.
func TestEmpty(t *testing.T) {}

/**
Expand Down
35 changes: 0 additions & 35 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/ioutil/pagewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestPageWriterRandom(t *testing.T) {
t.Logf("total write bytes: %d (of %d)", cw.writeBytes, n)
}

// TestPageWriterPariallack tests the case where a write overflows the buffer
// TestPageWriterPartialSlack tests the case where a write overflows the buffer
// but there is not enough data to complete the slack write.
func TestPageWriterPartialSlack(t *testing.T) {
defaultBufferBytes = 1024
Expand Down
2 changes: 1 addition & 1 deletion raft/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestNodeStep(t *testing.T) {
}
}

// Cancel and Stop should unblock Step()
// TestNodeStepUnblock should Cancel and Stop should unblock Step()
func TestNodeStepUnblock(t *testing.T) {
// a node without buffer to block step
n := &node{
Expand Down
14 changes: 7 additions & 7 deletions raft/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,8 @@ func TestPastElectionTimeout(t *testing.T) {
}
}

// ensure that the Step function ignores the message from old term and does not pass it to the
// actual stepX function.
// TestStepIgnoreOldTermMsg to ensure that the Step function ignores the message
// from old term and does not pass it to the actual stepX function.
func TestStepIgnoreOldTermMsg(t *testing.T) {
called := false
fakeStep := func(r *raft, m pb.Message) error {
Expand Down Expand Up @@ -2479,7 +2479,7 @@ func TestLeaderAppResp(t *testing.T) {
}
}

// When the leader receives a heartbeat tick, it should
// TestBcastBeat is when the leader receives a heartbeat tick, it should
// send a MsgHeartbeat with m.Index = 0, m.LogTerm=0 and empty entries.
func TestBcastBeat(t *testing.T) {
offset := uint64(1000)
Expand Down Expand Up @@ -2539,7 +2539,7 @@ func TestBcastBeat(t *testing.T) {
}
}

// tests the output of the state machine when receiving MsgBeat
// TestRecvMsgBeat tests the output of the state machine when receiving MsgBeat
func TestRecvMsgBeat(t *testing.T) {
tests := []struct {
state StateType
Expand Down Expand Up @@ -2818,7 +2818,7 @@ func TestRestoreWithLearner(t *testing.T) {
}
}

// Tests if outgoing voter can receive and apply snapshot correctly.
// TestRestoreWithVotersOutgoing tests if outgoing voter can receive and apply snapshot correctly.
func TestRestoreWithVotersOutgoing(t *testing.T) {
s := pb.Snapshot{
Metadata: pb.SnapshotMetadata{
Expand Down Expand Up @@ -4306,12 +4306,12 @@ func testConfChangeCheckBeforeCampaign(t *testing.T, v2 bool) {
}
}

// Tests if unapplied ConfChange is checked before campaign.
// TestConfChangeCheckBeforeCampaign tests if unapplied ConfChange is checked before campaign.
func TestConfChangeCheckBeforeCampaign(t *testing.T) {
testConfChangeCheckBeforeCampaign(t, false)
}

// Tests if unapplied ConfChangeV2 is checked before campaign.
// TestConfChangeV2CheckBeforeCampaign tests if unapplied ConfChangeV2 is checked before campaign.
func TestConfChangeV2CheckBeforeCampaign(t *testing.T) {
testConfChangeCheckBeforeCampaign(t, true)
}
Expand Down
10 changes: 5 additions & 5 deletions raft/rawnode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ type rawNodeAdapter struct {

var _ Node = (*rawNodeAdapter)(nil)

// Node specifies lead, which is pointless, can just be filled in.
// TransferLeadership is to test when node specifies lead, which is pointless, can just be filled in.
func (a *rawNodeAdapter) TransferLeadership(ctx context.Context, lead, transferee uint64) {
a.RawNode.TransferLeader(transferee)
}

// Node has a goroutine, RawNode doesn't need this.
// Stop when node has a goroutine, RawNode doesn't need this.
func (a *rawNodeAdapter) Stop() {}

// RawNode returns a *Status.
// Status returns RawNode's status as *Status.
func (a *rawNodeAdapter) Status() Status { return a.RawNode.Status() }

// RawNode takes a Ready. It doesn't really have to do that I think? It can hold on
// Advance is when RawNode takes a Ready. It doesn't really have to do that I think? It can hold on
// to it internally. But maybe that approach is frail.
func (a *rawNodeAdapter) Advance() { a.RawNode.Advance(Ready{}) }

// RawNode returns a Ready, not a chan of one.
// Ready when RawNode returns a Ready, not a chan of one.
func (a *rawNodeAdapter) Ready() <-chan Ready { return nil }

// Node takes more contexts. Easy enough to fix.
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function relativePath {
# go_srcs_in_module [package]
# returns list of all not-generated go sources in the current (dir) module.
function go_srcs_in_module {
go fmt -n "$1" | grep -Eo "([^ ]*)$" | grep -vE "(\\_test.go|\\.pb\\.go|\\.pb\\.gw.go)"
go list -f "{{with \$c:=.}}{{range \$f:=\$c.GoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{range \$f:=\$c.TestGoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{range \$f:=\$c.XTestGoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{end}}" ./... | grep -vE "(\\.pb\\.go|\\.pb\\.gw.go)"
}

# pkgs_in_module [optional:package_pattern]
Expand Down
4 changes: 2 additions & 2 deletions server/auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestNewAuthStoreRevision(t *testing.T) {
}
}

// TestNewAuthStoreBryptCost ensures that NewAuthStore uses default when given bcrypt-cost is invalid
// TestNewAuthStoreBcryptCost ensures that NewAuthStore uses default when given bcrypt-cost is invalid
func TestNewAuthStoreBcryptCost(t *testing.T) {
b, _ := betesting.NewDefaultTmpBackend(t)
defer betesting.Close(t, b)
Expand Down Expand Up @@ -766,7 +766,7 @@ func TestIsAuthEnabled(t *testing.T) {
}
}

// TestAuthRevisionRace ensures that access to authStore.revision is thread-safe.
// TestAuthInfoFromCtxRace ensures that access to authStore.revision is thread-safe.
func TestAuthInfoFromCtxRace(t *testing.T) {
b, _ := betesting.NewDefaultTmpBackend(t)
defer betesting.Close(t, b)
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/api/v2http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func TestServeMembers(t *testing.T) {
}
}

// TODO: consolidate **ALL** fake server implementations and add no leader test case.
// TestServeLeader TODO: consolidate **ALL** fake server implementations and add no leader test case.
func TestServeLeader(t *testing.T) {
memb1 := membership.Member{ID: 1, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8080"}}}
memb2 := membership.Member{ID: 2, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8081"}}}
Expand Down
22 changes: 11 additions & 11 deletions server/etcdserver/api/v2store/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,84 @@ import (
"go.etcd.io/etcd/client/pkg/v3/testutil"
)

// Ensure that a successful Get is recorded in the stats.
// TestStoreStatsGetSuccess to ensure that a successful Get is recorded in the stats.
func TestStoreStatsGetSuccess(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Get("/foo", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.GetSuccess, "")
}

// Ensure that a failed Get is recorded in the stats.
// TestStoreStatsGetFail to ensure that a failed Get is recorded in the stats.
func TestStoreStatsGetFail(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Get("/no_such_key", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.GetFail, "")
}

// Ensure that a successful Create is recorded in the stats.
// TestStoreStatsCreateSuccess to ensure that a successful Create is recorded in the stats.
func TestStoreStatsCreateSuccess(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CreateSuccess, "")
}

// Ensure that a failed Create is recorded in the stats.
// TestStoreStatsCreateFail to ensure that a failed Create is recorded in the stats.
func TestStoreStatsCreateFail(t *testing.T) {
s := newStore()
s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CreateFail, "")
}

// Ensure that a successful Update is recorded in the stats.
// TestStoreStatsUpdateSuccess to ensure that a successful Update is recorded in the stats.
func TestStoreStatsUpdateSuccess(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.UpdateSuccess, "")
}

// Ensure that a failed Update is recorded in the stats.
// TestStoreStatsUpdateFail to ensure that a failed Update is recorded in the stats.
func TestStoreStatsUpdateFail(t *testing.T) {
s := newStore()
s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.UpdateFail, "")
}

// Ensure that a successful CAS is recorded in the stats.
// TestStoreStatsCompareAndSwapSuccess to ensure that a successful CAS is recorded in the stats.
func TestStoreStatsCompareAndSwapSuccess(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapSuccess, "")
}

// Ensure that a failed CAS is recorded in the stats.
// TestStoreStatsCompareAndSwapFail to ensure that a failed CAS is recorded in the stats.
func TestStoreStatsCompareAndSwapFail(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapFail, "")
}

// Ensure that a successful Delete is recorded in the stats.
// TestStoreStatsDeleteSuccess to ensure that a successful Delete is recorded in the stats.
func TestStoreStatsDeleteSuccess(t *testing.T) {
s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Delete("/foo", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.DeleteSuccess, "")
}

// Ensure that a failed Delete is recorded in the stats.
// TestStoreStatsDeleteFail to ensure that a failed Delete is recorded in the stats.
func TestStoreStatsDeleteFail(t *testing.T) {
s := newStore()
s.Delete("/foo", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.DeleteFail, "")
}

// Ensure that the number of expirations is recorded in the stats.
// TestStoreStatsExpireCount to ensure that the number of expirations is recorded in the stats.
func TestStoreStatsExpireCount(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand Down
22 changes: 11 additions & 11 deletions server/etcdserver/api/v2store/store_ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/jonboulle/clockwork"
)

// Ensure that any TTL <= minExpireTime becomes Permanent
// TestMinExpireTime to ensure that any TTL <= minExpireTime becomes Permanent
func TestMinExpireTime(t *testing.T) {
s := newStore()
fc := clockwork.NewFakeClock()
Expand All @@ -44,7 +44,7 @@ func TestMinExpireTime(t *testing.T) {
testutil.AssertEqual(t, e.Node.TTL, int64(0))
}

// Ensure that the store can recursively retrieve a directory listing.
// TestStoreGetDirectory to ensure that the store can recursively retrieve a directory listing.
// Note that hidden files should not be returned.
func TestStoreGetDirectory(t *testing.T) {
s := newStore()
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestStoreGetDirectory(t *testing.T) {
}
}

// Ensure that the store can update the TTL on a value.
// TestStoreUpdateValueTTL to ensure that the store can update the TTL on a value.
func TestStoreUpdateValueTTL(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand All @@ -113,7 +113,7 @@ func TestStoreUpdateValueTTL(t *testing.T) {
testutil.AssertEqual(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound)
}

// Ensure that the store can update the TTL on a directory.
// TestStoreUpdateDirTTL to ensure that the store can update the TTL on a directory.
func TestStoreUpdateDirTTL(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand All @@ -139,7 +139,7 @@ func TestStoreUpdateDirTTL(t *testing.T) {
testutil.AssertEqual(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound)
}

// Ensure that the store can watch for key expiration.
// TestStoreWatchExpire to ensure that the store can watch for key expiration.
func TestStoreWatchExpire(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestStoreWatchExpire(t *testing.T) {
testutil.AssertEqual(t, e.Node.Dir, true)
}

// Ensure that the store can watch for key expiration when refreshing.
// TestStoreWatchExpireRefresh to ensure that the store can watch for key expiration when refreshing.
func TestStoreWatchExpireRefresh(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestStoreWatchExpireRefresh(t *testing.T) {
testutil.AssertEqual(t, e.Node.Key, "/foofoo")
}

// Ensure that the store can watch for key expiration when refreshing with an empty value.
// TestStoreWatchExpireEmptyRefresh to ensure that the store can watch for key expiration when refreshing with an empty value.
func TestStoreWatchExpireEmptyRefresh(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand All @@ -238,7 +238,7 @@ func TestStoreWatchExpireEmptyRefresh(t *testing.T) {
testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
}

// Update TTL of a key (set TTLOptionSet.Refresh to false) and send notification
// TestStoreWatchNoRefresh to update TTL of a key (set TTLOptionSet.Refresh to false) and send notification
func TestStoreWatchNoRefresh(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand All @@ -264,7 +264,7 @@ func TestStoreWatchNoRefresh(t *testing.T) {
testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
}

// Ensure that the store can update the TTL on a value with refresh.
// TestStoreRefresh to ensure that the store can update the TTL on a value with refresh.
func TestStoreRefresh(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand All @@ -286,7 +286,7 @@ func TestStoreRefresh(t *testing.T) {
testutil.AssertNil(t, err)
}

// Ensure that the store can recover from a previously saved state that includes an expiring key.
// TestStoreRecoverWithExpiration to ensure that the store can recover from a previously saved state that includes an expiring key.
func TestStoreRecoverWithExpiration(t *testing.T) {
s := newStore()
s.clock = newFakeClock()
Expand Down Expand Up @@ -320,7 +320,7 @@ func TestStoreRecoverWithExpiration(t *testing.T) {
testutil.AssertNil(t, e)
}

// Ensure that the store doesn't see expirations of hidden keys.
// TestStoreWatchExpireWithHiddenKey to ensure that the store doesn't see expirations of hidden keys.
func TestStoreWatchExpireWithHiddenKey(t *testing.T) {
s := newStore()
fc := newFakeClock()
Expand Down
5 changes: 2 additions & 3 deletions server/etcdserver/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,8 @@ func TestProcessDuplicatedAppRespMessage(t *testing.T) {
}
}

// Test that none of the expvars that get added during init panic.
// This matters if another package imports etcdserver,
// doesn't use it, but does use expvars.
// TestExpvarWithNoRaftStatus to test that none of the expvars that get added during init panic.
// This matters if another package imports etcdserver, doesn't use it, but does use expvars.
func TestExpvarWithNoRaftStatus(t *testing.T) {
defer func() {
if err := recover(); err != nil {
Expand Down
Loading

0 comments on commit 1ea808b

Please sign in to comment.