Skip to content
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

enable thelper linter #1022

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
327ae74
fix(thelper): rename testing.TB params to 'tb'
PaulYakow Jan 30, 2024
14fa61b
fix(thelper): testing.TB is first param of helper function
PaulYakow Jan 30, 2024
2d89b9b
fix(thelper): test helper function start from t.Helper()
PaulYakow Jan 30, 2024
3845e32
fix(thelper): test helper function start from tb.Helper()
PaulYakow Jan 30, 2024
6c5ddb6
fix(linters): enable thelper
PaulYakow Jan 30, 2024
cd2be5b
Apply suggestions from code review
asmyasnikov Jan 31, 2024
159ff0d
Update client_test.go
asmyasnikov Jan 31, 2024
84b8092
Update committer_test.go
asmyasnikov Jan 31, 2024
09f9f6b
Update writer_reconnector_test.go
asmyasnikov Jan 31, 2024
e4b115b
Update client_test.go
asmyasnikov Jan 31, 2024
db0f2a3
Update stream_reconnector.go
asmyasnikov Jan 31, 2024
b4f5d29
Merge branch 'master' into fix/enable-thelper
asmyasnikov Jan 31, 2024
8ad38c5
Merge branch 'master' into fix/enable-thelper
asmyasnikov Feb 20, 2024
36bc172
Merge branch 'master' into fix/enable-thelper
PaulYakow Mar 11, 2024
45be5c7
Update internal/query/client_test.go
PaulYakow Mar 11, 2024
280e018
Update internal/query/result_test.go
PaulYakow Mar 11, 2024
0d2f8dc
Update internal/topic/topicwriterinternal/writer_grpc_mock_test.go
PaulYakow Mar 11, 2024
6d089d6
Update internal/table/client_test.go (interfacer)
PaulYakow Mar 11, 2024
3a6f7c4
Merge branch 'master' into fix/enable-thelper
PaulYakow Mar 11, 2024
14eac3d
Merge branch 'master' into fix/enable-thelper
asmyasnikov Mar 12, 2024
ef76778
Update internal/query/result_test.go (typecheck)
PaulYakow Mar 12, 2024
4f7b879
fix: update stream_reconnector.go (test time out panic)
PaulYakow Mar 13, 2024
6d0cb2e
Merge branch 'master' into fix/enable-thelper
PaulYakow Mar 18, 2024
21a8d23
fix: update pool_test.go
PaulYakow Mar 18, 2024
a312f2d
Merge branch 'master' into fix/enable-thelper
PaulYakow Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ linters:
- structcheck
- testableexamples
- testpackage
- thelper
- varnamelen
- wrapcheck
- wsl
Expand Down
26 changes: 14 additions & 12 deletions internal/background/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ func TestWorkerClose(t *testing.T) {
}

func TestWorkerConcurrentStartAndClose(t *testing.T) {
xtest.TestManyTimes(t, func(t testing.TB) {
xtest.TestManyTimes(t, func(tb testing.TB) {
tb.Helper()
targetClose := int64(10)

parallel := runtime.GOMAXPROCS(0)

var counter xatomic.Int64

ctx := xtest.Context(t)
ctx := xtest.Context(tb)
w := NewWorker(ctx)

stopNewStarts := xatomic.Bool{}
Expand All @@ -126,24 +127,25 @@ func TestWorkerConcurrentStartAndClose(t *testing.T) {
}

// wait start some backgrounds - for ensure about process worked
xtest.SpinWaitCondition(t, nil, func() bool {
xtest.SpinWaitCondition(tb, nil, func() bool {
return counter.Load() > targetClose
})

require.NoError(t, w.Close(xtest.ContextWithCommonTimeout(ctx, t), nil))
require.NoError(tb, w.Close(xtest.ContextWithCommonTimeout(ctx, tb), nil))

stopNewStarts.Store(true)
xtest.WaitGroup(t, &wgStarters)
xtest.WaitGroup(tb, &wgStarters)

_, ok := <-w.tasks
require.False(t, ok)
require.True(t, w.closed)
require.False(tb, ok)
require.True(tb, w.closed)
})
}

func TestWorkerStartCompletedWhileLongWait(t *testing.T) {
xtest.TestManyTimes(t, func(t testing.TB) {
ctx := xtest.Context(t)
xtest.TestManyTimes(t, func(tb testing.TB) {
tb.Helper()
ctx := xtest.Context(tb)
w := NewWorker(ctx)

allowStop := make(empty.Chan)
Expand Down Expand Up @@ -175,17 +177,17 @@ func TestWorkerStartCompletedWhileLongWait(t *testing.T) {
_ = w.Close(ctx, nil)
}()

xtest.WaitChannelClosed(t, callStartFinished)
xtest.WaitChannelClosed(tb, callStartFinished)
runtime.Gosched()

select {
case <-closed:
t.Fatal()
tb.Fatal()
default:
// pass
}

close(allowStop)
xtest.WaitChannelClosed(t, closed)
xtest.WaitChannelClosed(tb, closed)
})
}
20 changes: 11 additions & 9 deletions internal/balancer/local_dc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,23 @@ func TestCheckFastestAddress(t *testing.T) {

func TestDetectLocalDC(t *testing.T) {
ctx := context.Background()
xtest.TestManyTimesWithName(t, "Ok", func(t testing.TB) {
xtest.TestManyTimesWithName(t, "Ok", func(tb testing.TB) {
tb.Helper()
listen1, err := net.ListenTCP("tcp", &net.TCPAddr{IP: localIP})
require.NoError(t, err)
require.NoError(tb, err)
defer func() { _ = listen1.Close() }()

listen2, err := net.ListenTCP("tcp", &net.TCPAddr{IP: localIP})
require.NoError(t, err)
require.NoError(tb, err)
listen2Addr := listen2.Addr().String()
_ = listen2.Close() // force close, for not accept tcp connections

dc, err := detectLocalDC(ctx, []endpoint.Endpoint{
&mock.Endpoint{LocationField: "a", AddrField: "grpc://" + listen1.Addr().String()},
&mock.Endpoint{LocationField: "b", AddrField: "grpc://" + listen2Addr},
})
require.NoError(t, err)
require.Equal(t, "a", dc)
require.NoError(tb, err)
require.Equal(tb, "a", dc)
})
t.Run("Empty", func(t *testing.T) {
res, err := detectLocalDC(ctx, nil)
Expand Down Expand Up @@ -222,12 +223,13 @@ func TestGetRandomEndpoints(t *testing.T) {
res = getRandomEndpoints(source, 4)
require.Equal(t, source, res)
})
xtest.TestManyTimesWithName(t, "SelectRandom", func(t testing.TB) {
xtest.TestManyTimesWithName(t, "SelectRandom", func(tb testing.TB) {
tb.Helper()
res := getRandomEndpoints(source, 2)
require.Len(t, res, 2)
require.Len(tb, res, 2)
for _, ep := range res {
require.Contains(t, source, ep)
require.Contains(tb, source, ep)
}
require.NotEqual(t, res[0], res[1])
require.NotEqual(tb, res[0], res[1])
})
}
Loading
Loading