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

golangci-lint: lint code with e2e build tags, fix issues #707

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
run:
timeout: 5m
modules-download-mode: readonly
build-tags:
- e2e

output:
formats:
Expand Down
2 changes: 1 addition & 1 deletion e2e/getdents/getdents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestGetDEnts(t *testing.T) {

stdout, stderr, err := ct.Kubeclient.Exec(ctx, ct.Namespace, pods[0].Name, []string{"/bin/sh", "-c", "find /toomany | wc -l"})
require.NoError(err, "stderr: %q", stderr)
require.Equal(stdout, "10001\n", "output: %s", stdout)
require.Equal("10001\n", stdout, "output: %s", stdout)
})
}

Expand Down
17 changes: 10 additions & 7 deletions e2e/release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestRelease(t *testing.T) {
contrast := &contrast{dir}

for _, sub := range []string{"help"} {
contrast.Run(t, ctx, 2*time.Second, sub)
contrast.Run(ctx, t, 2*time.Second, sub)
}

t.Cleanup(func() {
Expand Down Expand Up @@ -79,7 +79,9 @@ func TestRelease(t *testing.T) {

// Delete resources 1-by-1 so that we don't stop on errors.
for _, resource := range resources {
k.Delete(ctx, resource)
if err := k.Delete(ctx, resource); err != nil {
t.Logf("deleting resource %s: %v", resource.GetName(), err)
}
}
})

Expand Down Expand Up @@ -136,9 +138,9 @@ func TestRelease(t *testing.T) {
}
}), "unpacking needs to succeed for subsequent tests to run")

contrast.Run(t, ctx, 2*time.Minute, "generate", "--reference-values", "aks-clh-snp", "deployment/")
contrast.Run(t, ctx, 1*time.Minute, "set", "-c", coordinatorIP+":1313", "deployment/")
contrast.Run(t, ctx, 1*time.Minute, "verify", "-c", coordinatorIP+":1313")
contrast.Run(ctx, t, 2*time.Minute, "generate", "--reference-values", "aks-clh-snp", "deployment/")
contrast.Run(ctx, t, 1*time.Minute, "set", "-c", coordinatorIP+":1313", "deployment/")
contrast.Run(ctx, t, 1*time.Minute, "verify", "-c", coordinatorIP+":1313")

require.True(t, t.Run("apply-demo", func(t *testing.T) {
require := require.New(t)
Expand Down Expand Up @@ -176,7 +178,7 @@ func TestRelease(t *testing.T) {

c := http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "tcp", net.JoinHostPort(emojiwebIP, "443"))
},
TLSClientConfig: cfg,
Expand All @@ -186,6 +188,7 @@ func TestRelease(t *testing.T) {
require.NoError(err)
resp, err := c.Do(req)
require.NoError(err)
defer resp.Body.Close()
require.Equal(http.StatusOK, resp.StatusCode)
})
}
Expand All @@ -194,7 +197,7 @@ type contrast struct {
dir string
}

func (c *contrast) Run(t *testing.T, ctx context.Context, timeout time.Duration, args ...string) {
func (c *contrast) Run(ctx context.Context, t *testing.T, timeout time.Duration, args ...string) {
require.True(t, t.Run(args[0], func(t *testing.T) {
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
Expand Down
2 changes: 1 addition & 1 deletion e2e/servicemesh/servicemesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestIngressEgress(t *testing.T) {

tlsConf := &tls.Config{RootCAs: pool}
hc := &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConf}}
req, err := http.NewRequest("GET", fmt.Sprintf("https://%s/", web), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://%s/", web), http.NoBody)
require.NoError(err)
resp, err := hc.Do(req)
require.NoError(err)
Expand Down