Skip to content

Commit

Permalink
Update restart monitor test to output daemon logs on failure
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
dmcgowan committed Dec 9, 2021
1 parent 753f95e commit 807213f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions integration/client/restart_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/testutil"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/sys"
exec "golang.org/x/sys/execabs"
)

Expand Down Expand Up @@ -97,21 +98,25 @@ func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, fun

cleanup := func() {
if err := client.Close(); err != nil {
t.Fatalf("failed to close client: %v", err)
t.Errorf("failed to close client: %v", err)
}
if err := ctrd.Stop(); err != nil {
if err := ctrd.Kill(); err != nil {
t.Fatalf("failed to signal containerd: %v", err)
t.Errorf("failed to signal containerd: %v", err)
}
}
if err := ctrd.Wait(); err != nil {
if _, ok := err.(*exec.ExitError); !ok {
t.Fatalf("failed to wait for: %v", err)
t.Errorf("failed to wait for: %v", err)
}
}
if err := os.RemoveAll(tempDir); err != nil {
t.Fatalf("failed to remove %s: %v", tempDir, err)
if err := sys.ForceRemoveAll(tempDir); err != nil {
t.Errorf("failed to remove %s: %v", tempDir, err)
}
if t.Failed() {
t.Log("Daemon output:\n", buf.String())
}

// cleaning config-specific resources is up to the caller
}
return client, &ctrd, cleanup
Expand Down

0 comments on commit 807213f

Please sign in to comment.