diff --git a/pkg/machine/e2e/basic_test.go b/pkg/machine/e2e/basic_test.go index 1f915528a7..63acf3710b 100644 --- a/pkg/machine/e2e/basic_test.go +++ b/pkg/machine/e2e/basic_test.go @@ -22,6 +22,7 @@ var _ = Describe("run basic podman commands", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/info_test.go b/pkg/machine/e2e/info_test.go index b016e3e1e1..dec494b6e9 100644 --- a/pkg/machine/e2e/info_test.go +++ b/pkg/machine/e2e/info_test.go @@ -20,6 +20,7 @@ var _ = Describe("podman machine info", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/init_test.go b/pkg/machine/e2e/init_test.go index 4aab924466..2023a0064e 100644 --- a/pkg/machine/e2e/init_test.go +++ b/pkg/machine/e2e/init_test.go @@ -27,6 +27,7 @@ var _ = Describe("podman machine init", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/inspect_test.go b/pkg/machine/e2e/inspect_test.go index 9645b42efb..6b3eb8c57b 100644 --- a/pkg/machine/e2e/inspect_test.go +++ b/pkg/machine/e2e/inspect_test.go @@ -19,6 +19,7 @@ var _ = Describe("podman inspect stop", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/list_test.go b/pkg/machine/e2e/list_test.go index 4cdef055e9..7063b22118 100644 --- a/pkg/machine/e2e/list_test.go +++ b/pkg/machine/e2e/list_test.go @@ -22,6 +22,7 @@ var _ = Describe("podman machine list", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 5c2a0f30db..97794101f9 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -102,6 +102,11 @@ func setup() (string, *machineTestBuilder) { if err := os.MkdirAll(filepath.Join(homeDir, ".ssh"), 0700); err != nil { Fail(fmt.Sprintf("failed to create ssh dir: %q", err)) } + cConfDir := filepath.Join(homeDir, "containers") + if err := os.MkdirAll(cConfDir, 0755); err != nil { + Fail(fmt.Sprintf("failed to create %q: %s", cConfDir, err.Error())) + } + sshConfig, err := os.Create(filepath.Join(homeDir, ".ssh", "config")) if err != nil { Fail(fmt.Sprintf("failed to create ssh config: %q", err)) @@ -115,12 +120,44 @@ func setup() (string, *machineTestBuilder) { if err := os.Setenv("HOME", homeDir); err != nil { Fail("failed to set home dir") } + + fmt.Println("Set HOME to:", homeDir) + if err := os.Setenv("USERPROFILE", homeDir); err != nil { + Fail("failed to set USERPROFILE dir") + } + + fmt.Println("Set USERPROFILE to:", homeDir) + if err := os.Setenv("XDG_RUNTIME_DIR", homeDir); err != nil { - Fail("failed to set xdg_runtime dir") + Fail("failed to set xdg_runtime_dir") + } + + if err := os.Setenv("XDG_CONFIG_HOME", homeDir); err != nil { + Fail("failed to set xdg_CONFIG_HOME") + } + + fmt.Println("Set XDG_CONFIG_HOME to ", homeDir) + + cConf := filepath.Join(cConfDir, "containers.conf") + cc, err := os.Create(cConf) + if err != nil { + Fail("failed to create test container.conf") + } + + if err := cc.Close(); err != nil { + Fail(fmt.Sprintf("unable to close file %q: %s", cConf, err.Error())) } + + if err := os.Setenv("CONTAINERS_CONF", cConf); err != nil { + Fail("failed to set CONTAINERS_CONF environment var") + } + + fmt.Println("set CONTAINERS_CONF to ", cConf) + if err := os.Unsetenv("SSH_AUTH_SOCK"); err != nil { Fail("unable to unset SSH_AUTH_SOCK") } + mb, err := newMB() if err != nil { Fail(fmt.Sprintf("failed to create machine test: %q", err)) @@ -140,6 +177,7 @@ func setup() (string, *machineTestBuilder) { if err := n.Close(); err != nil { Fail(fmt.Sprintf("failed to close image copy handler: %q", err)) } + return homeDir, mb } @@ -158,3 +196,18 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) { Fail("failed to set home dir") } } + +// dumpDebug is called after each test and can be used to display useful debug information +// about the environment +func dumpDebug(mb *machineTestBuilder, testDir string, sr SpecReport) { + if !sr.Failed() { + return + } + fmt.Println("///////// DEBUG FOR FAILURE") + fmt.Println("test dir was: ", testDir) + debugMachine := basicMachine{} + // List connections + _, _ = mb.setCmd(debugMachine.withPodmanCommand([]string{"system", "connection", "ls"})).run() + // List machines + _, _ = mb.setCmd(debugMachine.withPodmanCommand([]string{"machine", "ls"})).run() +} diff --git a/pkg/machine/e2e/proxy_test.go b/pkg/machine/e2e/proxy_test.go index 020fad5b0b..2d4e42353c 100644 --- a/pkg/machine/e2e/proxy_test.go +++ b/pkg/machine/e2e/proxy_test.go @@ -19,6 +19,7 @@ var _ = Describe("podman machine proxy settings propagation", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/rm_test.go b/pkg/machine/e2e/rm_test.go index 35f3f8cc2c..8b78438f83 100644 --- a/pkg/machine/e2e/rm_test.go +++ b/pkg/machine/e2e/rm_test.go @@ -20,6 +20,7 @@ var _ = Describe("podman machine rm", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/set_test.go b/pkg/machine/e2e/set_test.go index a7f7602d77..d9847fc8e6 100644 --- a/pkg/machine/e2e/set_test.go +++ b/pkg/machine/e2e/set_test.go @@ -22,6 +22,7 @@ var _ = Describe("podman machine set", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/ssh_test.go b/pkg/machine/e2e/ssh_test.go index 5fedfea0f7..abaf600232 100644 --- a/pkg/machine/e2e/ssh_test.go +++ b/pkg/machine/e2e/ssh_test.go @@ -17,6 +17,7 @@ var _ = Describe("podman machine ssh", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/start_test.go b/pkg/machine/e2e/start_test.go index d1001a45d2..b59dd4d7b8 100644 --- a/pkg/machine/e2e/start_test.go +++ b/pkg/machine/e2e/start_test.go @@ -16,6 +16,7 @@ var _ = Describe("podman machine start", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) }) diff --git a/pkg/machine/e2e/stop_test.go b/pkg/machine/e2e/stop_test.go index 11c308e51b..22bd0c0f64 100644 --- a/pkg/machine/e2e/stop_test.go +++ b/pkg/machine/e2e/stop_test.go @@ -19,6 +19,7 @@ var _ = Describe("podman machine stop", func() { testDir, mb = setup() }) AfterEach(func() { + dumpDebug(mb, testDir, CurrentSpecReport()) teardown(originalHomeDir, testDir, mb) })