-
Notifications
You must be signed in to change notification settings - Fork 1
chore: fix lint issues #56
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
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| version: "2" | ||
|
|
||
| run: | ||
| build-tags: | ||
| - e2e | ||
| - unit | ||
|
|
||
| output: | ||
| formats: | ||
| tab: | ||
| path: stdout | ||
| sort-order: | ||
| - file | ||
| - severity | ||
| - linter |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,7 +64,7 @@ func TestMain(m *testing.M) { | |||||||||||||||||||||||||||||||||||||||
| if err == nil { | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("Performing global image cleanup") | ||||||||||||||||||||||||||||||||||||||||
| for image := range globalImagesToRemove { | ||||||||||||||||||||||||||||||||||||||||
| dockerCli.ImageRemove(ctx, image, imageApi.RemoveOptions{ | ||||||||||||||||||||||||||||||||||||||||
| _, _ = dockerCli.ImageRemove(ctx, image, imageApi.RemoveOptions{ | ||||||||||||||||||||||||||||||||||||||||
| Force: true, | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -121,11 +121,11 @@ func getEnvVars() (*config, error) { | |||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| var config config | ||||||||||||||||||||||||||||||||||||||||
| if err := env.Parse(&config); err != nil { | ||||||||||||||||||||||||||||||||||||||||
| var cfg config | ||||||||||||||||||||||||||||||||||||||||
| if err := env.Parse(&cfg); err != nil { | ||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| return &config, nil | ||||||||||||||||||||||||||||||||||||||||
| return &cfg, nil | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| func pullRequiredImages(t *testing.T, ctx context.Context, dockerApi *dockerApi.Client, containers []Container) { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -147,7 +147,7 @@ func pullRequiredImages(t *testing.T, ctx context.Context, dockerApi *dockerApi. | |||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if err := g.Wait(); err != nil { | ||||||||||||||||||||||||||||||||||||||||
| cleanup(t, dockerApi, containers, nil) | ||||||||||||||||||||||||||||||||||||||||
| cleanup(dockerApi, containers, nil) | ||||||||||||||||||||||||||||||||||||||||
| t.Fatal(err) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -209,7 +209,7 @@ func startRequiredContainers(t *testing.T, ctx context.Context, dockerCli *docke | |||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if err := g.Wait(); err != nil { | ||||||||||||||||||||||||||||||||||||||||
| cleanup(t, dockerCli, containers, nil) | ||||||||||||||||||||||||||||||||||||||||
| cleanup(dockerCli, containers, nil) | ||||||||||||||||||||||||||||||||||||||||
| t.Fatal(err) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -233,22 +233,22 @@ func setClients(t *testing.T, containers []Container) (*docker.Client, *pihole.C | |||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| piholeClient := pihole.NewClient(piholeURL, "password") | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("Waiting for Pi-hole to be ready...") | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("Waiting for Pi-Hole to be ready...") | ||||||||||||||||||||||||||||||||||||||||
| piholeLoginTimeout := time.After(60 * time.Second) | ||||||||||||||||||||||||||||||||||||||||
| piholeLoginTicker := time.NewTicker(3 * time.Second) | ||||||||||||||||||||||||||||||||||||||||
| defer piholeLoginTicker.Stop() | ||||||||||||||||||||||||||||||||||||||||
| PiholeLoginLoop: | ||||||||||||||||||||||||||||||||||||||||
| for { | ||||||||||||||||||||||||||||||||||||||||
| select { | ||||||||||||||||||||||||||||||||||||||||
| case <-piholeLoginTimeout: | ||||||||||||||||||||||||||||||||||||||||
| t.Fatalf("Timed out waiting for Pi-hole to be ready at %s", piholeURL) | ||||||||||||||||||||||||||||||||||||||||
| t.Fatalf("Timed out waiting for Pi-Hole to be ready at %s", piholeURL) | ||||||||||||||||||||||||||||||||||||||||
| case <-piholeLoginTicker.C: | ||||||||||||||||||||||||||||||||||||||||
| err = piholeClient.Login() | ||||||||||||||||||||||||||||||||||||||||
| if err == nil { | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("Successfully logged into Pi-hole") | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("Successfully logged into Pi-Hole") | ||||||||||||||||||||||||||||||||||||||||
| break PiholeLoginLoop | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| logger.Error("Pi-hole not ready, retrying...", "error", err) | ||||||||||||||||||||||||||||||||||||||||
| logger.Error("Pi-Hole not ready, retrying...", "error", err) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
@@ -284,7 +284,7 @@ func setup(t *testing.T, ctx context.Context, dockerCli *dockerApi.Client, conta | |||||||||||||||||||||||||||||||||||||||
| return dockerClient, piholeClient, npmClient, adguardHomeClient | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| func cleanup(t *testing.T, dockerCli *dockerApi.Client, containers []Container, npmClient *npm.Client) { | ||||||||||||||||||||||||||||||||||||||||
| func cleanup(dockerCli *dockerApi.Client, containers []Container, npmClient *npm.Client) { | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("In cleanup") | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Use background context for cleanup to ensure it completes even if test is canceled | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -293,7 +293,7 @@ func cleanup(t *testing.T, dockerCli *dockerApi.Client, containers []Container, | |||||||||||||||||||||||||||||||||||||||
| if npmClient != nil { | ||||||||||||||||||||||||||||||||||||||||
| npmProxyHosts, err := npmClient.GetProxyHosts() | ||||||||||||||||||||||||||||||||||||||||
| if err == nil { | ||||||||||||||||||||||||||||||||||||||||
| npmClient.DeleteProxyHosts(slices.Collect(maps.Keys(npmProxyHosts))) | ||||||||||||||||||||||||||||||||||||||||
| _, _ = npmClient.DeleteProxyHosts(slices.Collect(maps.Keys(npmProxyHosts))) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| var wg sync.WaitGroup | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -360,7 +360,7 @@ func TestE2E(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| dockerClient, piholeClient, npmClient, adguardHomeClient := setup(t, ctx, dockerCli, containers) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| t.Cleanup(func() { | ||||||||||||||||||||||||||||||||||||||||
| cleanup(t, dockerCli, containers, npmClient) | ||||||||||||||||||||||||||||||||||||||||
| cleanup(dockerCli, containers, npmClient) | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| time.Sleep(2 * time.Second) | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -408,9 +408,14 @@ func TestE2E(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Deleting to assert delete functionality | ||||||||||||||||||||||||||||||||||||||||
| piholeClient.DeleteDnsRecords(urls) | ||||||||||||||||||||||||||||||||||||||||
| npmClient.DeleteProxyHosts(urls) | ||||||||||||||||||||||||||||||||||||||||
| adguardHomeClient.DeleteDnsRewrites(urls, npmClient.GetIP()) | ||||||||||||||||||||||||||||||||||||||||
| _, err = piholeClient.DeleteDnsRecords(urls) | ||||||||||||||||||||||||||||||||||||||||
| require.NoError(t, err, "Failed to delete Pi-Hole DNS records") | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| _, err = npmClient.DeleteProxyHosts(urls) | ||||||||||||||||||||||||||||||||||||||||
| require.NoError(t, err, "Failed to delete NPM proxy hosts") | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| _, err = adguardHomeClient.DeleteDnsRewrites(urls, npmClient.GetIP()) | ||||||||||||||||||||||||||||||||||||||||
| require.NoError(t, err, "Failed to delete AdGuard Home DNS rewrites") | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+411
to
+418
Contributor
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert that the delete operations actually deleted entries. These checks only prove the calls didn't error. Suggested assertion shape- _, err = piholeClient.DeleteDnsRecords(urls)
+ deletedDNS, err := piholeClient.DeleteDnsRecords(urls)
require.NoError(t, err, "Failed to delete Pi-Hole DNS records")
+ require.Equal(t, len(urls), deletedDNS, "Expected Pi-Hole to delete all requested records")
- _, err = npmClient.DeleteProxyHosts(urls)
+ deletedProxyHosts, err := npmClient.DeleteProxyHosts(urls)
require.NoError(t, err, "Failed to delete NPM proxy hosts")
+ require.True(t, deletedProxyHosts, "Expected NPM to delete a proxy host")
- _, err = adguardHomeClient.DeleteDnsRewrites(urls, npmClient.GetIP())
+ deletedRewrites, err := adguardHomeClient.DeleteDnsRewrites(urls, npmClient.GetIP())
require.NoError(t, err, "Failed to delete AdGuard Home DNS rewrites")
+ require.Equal(t, len(urls), deletedRewrites, "Expected AdGuard Home to delete all requested rewrites")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| piholeDnsRecords, err := piholeClient.GetDnsRecords() | ||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -461,7 +466,7 @@ func TestE2E_CreateOnHealthy(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| dockerClient, piholeClient, npmClient, adguardHomeClient := setup(t, ctx, dockerCli, infraContainers) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| t.Cleanup(func() { | ||||||||||||||||||||||||||||||||||||||||
| cleanup(t, dockerCli, infraContainers, npmClient) | ||||||||||||||||||||||||||||||||||||||||
| cleanup(dockerCli, infraContainers, npmClient) | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| proc := processor.New( | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -502,7 +507,7 @@ func TestE2E_CreateOnHealthy(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| startRequiredContainers(t, ctx, dockerCli, testContainers) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| t.Cleanup(func() { | ||||||||||||||||||||||||||||||||||||||||
| dockerCli.ContainerRemove(context.Background(), testContainers[0].id, containerApi.RemoveOptions{Force: true}) | ||||||||||||||||||||||||||||||||||||||||
| _ = dockerCli.ContainerRemove(context.Background(), testContainers[0].id, containerApi.RemoveOptions{Force: true}) | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Assert entry DOES NOT exist while unhealthy | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -521,8 +526,8 @@ func TestE2E_CreateOnHealthy(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| // Wait for Docker to mark it healthy | ||||||||||||||||||||||||||||||||||||||||
| logger.Info("Waiting for Docker to mark container as healthy") | ||||||||||||||||||||||||||||||||||||||||
| require.Eventually(t, func() bool { | ||||||||||||||||||||||||||||||||||||||||
| inspect, err := dockerCli.ContainerInspect(ctx, testContainers[0].id) | ||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||
| inspect, inspectErr := dockerCli.ContainerInspect(ctx, testContainers[0].id) | ||||||||||||||||||||||||||||||||||||||||
| if inspectErr != nil { | ||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| return inspect.State.Health != nil && inspect.State.Health.Status == "healthy" | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -577,7 +582,7 @@ func TestE2E_CreateOnHealthy_NoHealthcheck(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| dockerClient, _, npmClient, adguardHomeClient := setup(t, ctx, dockerCli, infraContainers) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| t.Cleanup(func() { | ||||||||||||||||||||||||||||||||||||||||
| cleanup(t, dockerCli, infraContainers, npmClient) | ||||||||||||||||||||||||||||||||||||||||
| cleanup(dockerCli, infraContainers, npmClient) | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| proc := processor.New( | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -614,7 +619,7 @@ func TestE2E_CreateOnHealthy_NoHealthcheck(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||
| startRequiredContainers(t, ctx, dockerCli, testContainers) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| t.Cleanup(func() { | ||||||||||||||||||||||||||||||||||||||||
| dockerCli.ContainerRemove(context.Background(), testContainers[0].id, containerApi.RemoveOptions{Force: true}) | ||||||||||||||||||||||||||||||||||||||||
| _ = dockerCli.ContainerRemove(context.Background(), testContainers[0].id, containerApi.RemoveOptions{Force: true}) | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Assert entry NEVER exists | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Don't suppress NPM teardown failures.
If
DeleteProxyHostsfails here, the bind-mountednpm-datastate survives container removal and can poison later E2E runs, but this path now hides that completely. Please surface the error at least as a log, or return/aggregate it so thet.Cleanupcaller can fail the test.🤖 Prompt for AI Agents