test: migrate test api network get defaults and filter#50529
Conversation
07124f3 to
1841885
Compare
|
Thx! Didn't review yet, but see there's some linting failures (looks like easy fix); |
integration/network/network_test.go
Outdated
| } | ||
|
|
||
| func TestAPINetworkGetDefaults(t *testing.T) { | ||
| skip.If(t, runtime.GOOS == "windows") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Updated, give default network name for windows use case
integration/network/network_test.go
Outdated
| ctx := setupTest(t) | ||
| apiClient := testEnv.APIClient() | ||
|
|
||
| networkName := "bridge" |
There was a problem hiding this comment.
This may be fixable for windows if we make the name of the network depend on platform
There was a problem hiding this comment.
Updated, give "nat" network name for windows
a3cd9d6 to
96afa4e
Compare
akerouanton
left a comment
There was a problem hiding this comment.
Two nits, otherwise LGTM.
96afa4e to
2d942ee
Compare
robmry
left a comment
There was a problem hiding this comment.
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.
integration/network/network_test.go
Outdated
| apiClient := testEnv.APIClient() | ||
|
|
||
| defaults := []string{"bridge", "host", "none"} | ||
| if runtime.GOOS == "windows" { |
There was a problem hiding this comment.
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" {
integration/network/network_test.go
Outdated
|
|
||
| func TestAPINetworkFilter(t *testing.T) { | ||
| networkName := "bridge" | ||
| if runtime.GOOS == "windows" { |
There was a problem hiding this comment.
Same here;
if testEnv.DaemonInfo.OSType == "windows" {Signed-off-by: Muhammad Daffa Dinaya <muhammaddaffadinaya@gmail.com>
2d942ee to
87d1da5
Compare
robmry
left a comment
There was a problem hiding this comment.
LGTM - thank you.
The test failures are unrelated, GitHub having a bad day I think.
- 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