Browse code

Merge pull request #50397 from thaJeztah/testutil_denoise

minor cleanups and reduce logs in tests

Rob Murray authored on 2025/07/16 01:25:29
Showing 2 changed files
... ...
@@ -1140,7 +1140,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
1140 1140
 
1141 1141
 	// Kill daemon ungracefully and restart
1142 1142
 	assert.NilError(c, s.d.Kill())
1143
-	s.d.Restart(c)
1143
+	s.d.Start(c)
1144 1144
 
1145 1145
 	// make sure all the containers are up and running
1146 1146
 	for i := 0; i < 10; i++ {
... ...
@@ -155,7 +155,7 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
155 155
 
156 156
 	if d.resolvConfContent != "" {
157 157
 		path := filepath.Join(d.Folder, "resolv.conf")
158
-		if err := os.WriteFile(path, []byte(d.resolvConfContent), 0644); err != nil {
158
+		if err := os.WriteFile(path, []byte(d.resolvConfContent), 0o644); err != nil {
159 159
 			return nil, fmt.Errorf("failed to write docker resolv.conf to %q: %v", path, err)
160 160
 		}
161 161
 		d.extraEnv = append(d.extraEnv, "DOCKER_TEST_RESOLV_CONF_PATH="+path)
... ...
@@ -692,12 +692,8 @@ func (d *Daemon) DumpStackAndQuit() {
692 692
 func (d *Daemon) Stop(t testing.TB) {
693 693
 	t.Helper()
694 694
 	err := d.StopWithError()
695
-	if err != nil {
696
-		if !errors.Is(err, errDaemonNotStarted) {
697
-			t.Fatalf("[%s] error while stopping the daemon: %v", d.id, err)
698
-		} else {
699
-			t.Logf("[%s] daemon is not started", d.id)
700
-		}
695
+	if err != nil && !errors.Is(err, errDaemonNotStarted) {
696
+		t.Fatalf("[%s] error while stopping the daemon: %v", d.id, err)
701 697
 	}
702 698
 }
703 699
 
... ...
@@ -732,7 +728,7 @@ func (d *Daemon) StopWithError() (retErr error) {
732 732
 	d.log.Logf("[%s] stopping daemon", d.id)
733 733
 
734 734
 	if err := d.cmd.Process.Signal(os.Interrupt); err != nil {
735
-		if strings.Contains(err.Error(), "os: process already finished") {
735
+		if errors.Is(err, os.ErrProcessDone) {
736 736
 			return errDaemonNotStarted
737 737
 		}
738 738
 		return errors.Wrapf(err, "[%s] could not send signal", d.id)