Skip to content

test: migrate test api network get defaults and filter#50529

Merged
thaJeztah merged 1 commit intomoby:masterfrom
mdaffad:50159-migrate-test-api-network-defaults-and-filter
Sep 22, 2025
Merged

test: migrate test api network get defaults and filter#50529
thaJeztah merged 1 commit intomoby:masterfrom
mdaffad:50159-migrate-test-api-network-defaults-and-filter

Conversation

@mdaffad
Copy link
Contributor

@mdaffad mdaffad commented Jul 27, 2025

- What I did

Migrated the TestAPINetworkGetDefaults and TestAPINetworkFilter to integration tests in reference to the integration-cli migration epic #50159

- How I did it

Using test on integration-cli/docker_api_network_test.go

- How to verify it

Run integration test

@mdaffad mdaffad force-pushed the 50159-migrate-test-api-network-defaults-and-filter branch 2 times, most recently from 07124f3 to 1841885 Compare July 27, 2025 15:09
@thaJeztah
Copy link
Member

Thx! Didn't review yet, but see there's some linting failures (looks like easy fix);

integration/network/network_test.go:13:2: ST1019: package "github.com/moby/moby/api/types/network" is being imported more than once (staticcheck)
	"github.com/moby/moby/api/types/network"
	^
integration/network/network_test.go:14:2: ST1019(related information): other import of "github.com/moby/moby/api/types/network" (staticcheck)
	networktypes "github.com/moby/moby/api/types/network"
	^
integration-cli/docker_api_network_test.go:217:6: func getNetworkIDByName is unused (unused)
func getNetworkIDByName(t *testing.T, name string) string {
     ^

@thaJeztah thaJeztah added status/2-code-review area/networking Networking area/testing kind/refactor PR's that refactor, or clean-up code labels Jul 27, 2025
}

func TestAPINetworkGetDefaults(t *testing.T) {
skip.If(t, runtime.GOOS == "windows")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is a test specific for the bridge network, so will never be "un skipped" - so probably makes sense to put it in the _linux_test.go file

PERHAPS (but didn't look closely) even in https://github.com/moby/moby/tree/master/integration/network/bridge/

if it's for the bridge driver

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, i think if we solve the case for network name for windows platform, it will be also fixable. "bridge" for this case is the defaults created network name.

If that is not the case, i will move to your _linux_test.go options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, give default network name for windows use case

ctx := setupTest(t)
apiClient := testEnv.APIClient()

networkName := "bridge"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be fixable for windows if we make the name of the network depend on platform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, give "nat" network name for windows

@mdaffad mdaffad force-pushed the 50159-migrate-test-api-network-defaults-and-filter branch 4 times, most recently from a3cd9d6 to 96afa4e Compare August 5, 2025 02:42
Copy link
Member

@akerouanton akerouanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits, otherwise LGTM.

@mdaffad mdaffad force-pushed the 50159-migrate-test-api-network-defaults-and-filter branch from 96afa4e to 2d942ee Compare August 5, 2025 13:51
Copy link
Member

@akerouanton akerouanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mdaffad mdaffad requested a review from thaJeztah August 25, 2025 15:10
@akerouanton akerouanton requested a review from robmry September 19, 2025 06:54
Copy link
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mdaffad - thank you for this, and sorry it's taken us so long to approve the PR.

Unfortunately, because we were slow, although there's no merge conflict it needs a rebase and an update. There's been a lot of refactoring of API types, but this should do the trick ...

diff --git a/integration/network/network_test.go b/integration/network/network_test.go
index 03365d21bd..10e5177a34 100644
--- a/integration/network/network_test.go
+++ b/integration/network/network_test.go
@@ -9,10 +9,10 @@ import (

        "github.com/moby/moby/api/types/filters"
        networktypes "github.com/moby/moby/api/types/network"
+       "github.com/moby/moby/client"
        "github.com/moby/moby/v2/internal/testutil"
        "github.com/moby/moby/v2/internal/testutil/request"
        "gotest.tools/v3/assert"
-
        is "gotest.tools/v3/assert/cmp"
 )

@@ -131,7 +131,7 @@ func TestAPINetworkFilter(t *testing.T) {
        ctx := setupTest(t)
        apiClient := testEnv.APIClient()

-       networks, err := apiClient.NetworkList(ctx, networktypes.ListOptions{
+       networks, err := apiClient.NetworkList(ctx, client.NetworkListOptions{
                Filters: filters.NewArgs(filters.Arg("name", networkName)),
        })

Please squash changes into a single commit and force-push to keep the git history clean - or I can make the update if you prefer, just let me know.

apiClient := testEnv.APIClient()

defaults := []string{"bridge", "host", "none"}
if runtime.GOOS == "windows" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably more correct would be to check the daemon's platform. We don't currently do so, but these tests could be run from a Linux environment testing a Windows daemon;

	if testEnv.DaemonInfo.OSType == "windows" {


func TestAPINetworkFilter(t *testing.T) {
networkName := "bridge"
if runtime.GOOS == "windows" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here;

if testEnv.DaemonInfo.OSType == "windows" {

Signed-off-by: Muhammad Daffa Dinaya <muhammaddaffadinaya@gmail.com>
@mdaffad mdaffad force-pushed the 50159-migrate-test-api-network-defaults-and-filter branch from 2d942ee to 87d1da5 Compare September 20, 2025 06:02
@mdaffad mdaffad requested review from robmry and thaJeztah September 20, 2025 06:02
Copy link
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you.

The test failures are unrelated, GitHub having a bad day I think.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 69d5112 into moby:master Sep 22, 2025
401 of 412 checks passed
@thaJeztah thaJeztah added this to the 29.0.0 milestone Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants