MCPcopy
hub / github.com/moby/moby / TestDefaultNetworkOpts

Function TestDefaultNetworkOpts

integration/network/network_linux_test.go:104–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestDefaultNetworkOpts(t *testing.T) {
105 skip.If(t, testEnv.IsRemoteDaemon)
106 skip.If(t, testEnv.IsRootless, "rootless mode has different view of network")
107 ctx := testutil.StartSpan(baseContext, t)
108
109 tests := []struct {
110 name string
111 mtu int
112 configFrom bool
113 args []string
114 }{
115 {
116 name: "default value",
117 mtu: 1500,
118 args: []string{},
119 },
120 {
121 name: "cmdline value",
122 mtu: 1234,
123 args: []string{"--default-network-opt", "bridge=com.docker.network.driver.mtu=1234"},
124 },
125 {
126 name: "config-from value",
127 configFrom: true,
128 mtu: 1233,
129 args: []string{"--default-network-opt", "bridge=com.docker.network.driver.mtu=1234"},
130 },
131 }
132
133 for _, tc := range tests {
134 t.Run(tc.name, func(t *testing.T) {
135 ctx := testutil.StartSpan(ctx, t)
136 d := daemon.New(t)
137 d.StartWithBusybox(ctx, t, tc.args...)
138 defer d.Stop(t)
139 c := d.NewClientT(t)
140 defer c.Close()
141
142 if tc.configFrom {
143 // Create a new network config
144 network.CreateNoError(ctx, t, c, "from-net", func(create *client.NetworkCreateOptions) {
145 create.ConfigOnly = true
146 create.Options = map[string]string{
147 "com.docker.network.driver.mtu": fmt.Sprint(tc.mtu),
148 }
149 })
150 defer c.NetworkRemove(ctx, "from-net", client.NetworkRemoveOptions{})
151 }
152
153 // Create a new network
154 networkName := "testnet"
155 networkId := network.CreateNoError(ctx, t, c, networkName, func(create *client.NetworkCreateOptions) {
156 if tc.configFrom {
157 create.ConfigFrom = "from-net"
158 }
159 })
160 defer c.NetworkRemove(ctx, networkName, client.NetworkRemoveOptions{})
161

Callers

nothing calls this directly

Calls 15

StartSpanFunction · 0.92
NewFunction · 0.92
CreateNoErrorFunction · 0.92
RunFunction · 0.92
WithNetworkModeFunction · 0.92
ExecFunction · 0.92
StartWithBusyboxMethod · 0.80
NewClientTMethod · 0.80
CheckMethod · 0.80
CombinedMethod · 0.80
RunMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…