-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server: fix unexported-return lint issue #19052
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -113,12 +113,14 @@ func setupAuthStore(t *testing.T) (store *authStore, teardownfunc func(t *testin | |||||||
|
||||||||
// The UserAdd function cannot generate old etcd version user data (user's option is nil) | ||||||||
// add special users through the underlying interface | ||||||||
addUserWithNoOption(as) | ||||||||
asImpl, ok := as.(*authStore) | ||||||||
require.Truef(t, ok, "addUserWithNoOption: needs an AuthStore implementation") | ||||||||
Comment on lines
+116
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a validation in production code similar to below? etcd/server/storage/schema/auth.go Line 41 in 4abcda4
Suggested change
|
||||||||
addUserWithNoOption(asImpl) | ||||||||
|
||||||||
tearDown := func(_ *testing.T) { | ||||||||
as.Close() | ||||||||
} | ||||||||
return as, tearDown | ||||||||
return asImpl, tearDown | ||||||||
} | ||||||||
|
||||||||
func addUserWithNoOption(as *authStore) { | ||||||||
|
@@ -133,7 +135,7 @@ func addUserWithNoOption(as *authStore) { | |||||||
as.refreshRangePermCache(tx) | ||||||||
} | ||||||||
|
||||||||
func enableAuthAndCreateRoot(as *authStore) error { | ||||||||
func enableAuthAndCreateRoot(as AuthStore) error { | ||||||||
_, err := as.UserAdd(&pb.AuthUserAddRequest{Name: "root", HashedPassword: encodePassword("root"), Options: &authpb.UserAddOptions{NoPassword: false}}) | ||||||||
if err != nil { | ||||||||
return err | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ type serverVersionAdapter struct { | |
*EtcdServer | ||
} | ||
|
||
func NewServerVersionAdapter(s *EtcdServer) *serverVersionAdapter { | ||
func NewServerVersionAdapter(s *EtcdServer) serverversion.Server { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
return &serverVersionAdapter{ | ||
EtcdServer: s, | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -44,7 +44,7 @@ func TestWatch(t *testing.T) { | |||||||
defer w.Close() | ||||||||
|
||||||||
w.Watch(0, testKey, nil, 0) | ||||||||
if !s.synced.contains(string(testKey)) { | ||||||||
if !s.(*watchableStore).synced.contains(string(testKey)) { | ||||||||
// the key must have had an entry in synced | ||||||||
t.Errorf("existence = false, want true") | ||||||||
} | ||||||||
|
@@ -67,7 +67,7 @@ func TestNewWatcherCancel(t *testing.T) { | |||||||
t.Error(err) | ||||||||
} | ||||||||
|
||||||||
if s.synced.contains(string(testKey)) { | ||||||||
if s.(*watchableStore).synced.contains(string(testKey)) { | ||||||||
// the key shoud have been deleted | ||||||||
t.Errorf("existence = true, want false") | ||||||||
} | ||||||||
|
@@ -340,7 +340,9 @@ func TestWatchNoEventLossOnCompact(t *testing.T) { | |||||||
require.NoError(t, err) | ||||||||
} | ||||||||
// fill up w.Chan() with 1 buf via 2 compacted watch response | ||||||||
s.syncWatchers([]mvccpb.Event{}) | ||||||||
sImpl, ok := s.(*watchableStore) | ||||||||
require.Truef(t, ok, "TestWatchNoEventLossOnCompact: needs a WatchableKV implementation") | ||||||||
Comment on lines
+343
to
+344
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This already exists
Confirming if also suggesting to remove the assertions? |
||||||||
sImpl.syncWatchers([]mvccpb.Event{}) | ||||||||
|
||||||||
for len(watchers) > 0 { | ||||||||
resp := <-w.Chan() | ||||||||
|
@@ -355,7 +357,7 @@ func TestWatchNoEventLossOnCompact(t *testing.T) { | |||||||
require.Equalf(t, nextRev, ev.Kv.ModRevision, "got event revision %d but want %d for watcher with watch ID %d", ev.Kv.ModRevision, nextRev, resp.WatchID) | ||||||||
nextRev++ | ||||||||
} | ||||||||
if nextRev == s.rev()+1 { | ||||||||
if nextRev == sImpl.rev()+1 { | ||||||||
delete(watchers, resp.WatchID) | ||||||||
} | ||||||||
} | ||||||||
|
@@ -566,10 +568,13 @@ func TestWatchBatchUnsynced(t *testing.T) { | |||||||
} | ||||||||
assert.Equal(t, tc.expectRevisionBatches, revisionBatches) | ||||||||
|
||||||||
s.store.revMu.Lock() | ||||||||
defer s.store.revMu.Unlock() | ||||||||
assert.Equal(t, 1, s.synced.size()) | ||||||||
assert.Equal(t, 0, s.unsynced.size()) | ||||||||
sImpl, ok := s.(*watchableStore) | ||||||||
require.Truef(t, ok, "TestWatchBatchUnsynced: needs a WatchableKV implementation") | ||||||||
Comment on lines
+571
to
+572
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exists
|
||||||||
|
||||||||
sImpl.store.revMu.Lock() | ||||||||
defer sImpl.store.revMu.Unlock() | ||||||||
assert.Equal(t, 1, sImpl.synced.size()) | ||||||||
assert.Equal(t, 0, sImpl.unsynced.size()) | ||||||||
}) | ||||||||
} | ||||||||
} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change!