Browse code

TestBridgeIPIsExcludedFromAllocatorPool: don't use deprecated fields

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/11/10 20:07:19
Showing 1 changed files
... ...
@@ -1052,6 +1052,8 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T
1052 1052
 	s.d.StartWithBusybox(testutil.GetContext(c), c, "--bip", bridgeRange)
1053 1053
 	defer s.d.Restart(c)
1054 1054
 
1055
+	apiClient := s.d.NewClientT(c)
1056
+
1055 1057
 	var cont int
1056 1058
 	for {
1057 1059
 		contName := fmt.Sprintf("container%d", cont)
... ...
@@ -1060,9 +1062,14 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T
1060 1060
 			// pool exhausted
1061 1061
 			break
1062 1062
 		}
1063
-		ip, err := s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.IPAddress}}'", contName)
1064
-		assert.Assert(c, err == nil, ip)
1065 1063
 
1064
+		res, err := apiClient.ContainerInspect(c.Context(), contName, client.ContainerInspectOptions{})
1065
+		assert.NilError(c, err)
1066
+
1067
+		assert.Check(c, res.Container.NetworkSettings != nil)
1068
+		assert.Check(c, res.Container.NetworkSettings.Networks["bridge"] != nil)
1069
+		ip := res.Container.NetworkSettings.Networks["bridge"].IPAddress.String()
1070
+		assert.Assert(c, err == nil, ip)
1066 1071
 		assert.Assert(c, ip != bridgeIP)
1067 1072
 		cont++
1068 1073
 	}