From bd0582dd3407a1f1ad5c38753d84243dcdf63102 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 6 May 2019 06:11:10 -0600 Subject: [PATCH 1/2] BATS tests - get working again Various small fixes to get BATS tests working again. Split from #2947 because that one keeps getting stalled, and I'm hoping these separate changes get approved. I consider these changes urgent because RHEL8 gating tests are failing, and will fail even more if/when #2272 gets picked up and packaged for RHEL8, and I consider it important to have clean passing tests for RHEL8. * info test: 'insecure registries' is gone. A recent commit (d1a7378aa) changed the format of 'podman info', removing the 'insecure registries' key. Deal with it. * info test: remove check for .host.{Conmon,OCIRuntime}.package; the value on f28 and f29 is 'Unknown' (instead of an NVR). We can live without this check. * 'load' test: skip when running in CI, because stdin is not a tty. * container restore: fix arg processing. #2272 broke argument processing: 'podman container restore', with no args, should exit with 'argument required' error. Root cause is that the new --import option takes the place of an argument, so the checkAllAndLatest() call had to be changed to not exit on error. Workaround is (sigh) to copy/paste the skipped checkAllAndLatest() code, with minor tweaks to accommodate --import. Signed-off-by: Ed Santiago --- cmd/podman/restore.go | 9 +++++++++ test/system/005-info.bats | 4 +--- test/system/120-load.bats | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go index 9c77d4a5e3..4d715ad4f8 100644 --- a/cmd/podman/restore.go +++ b/cmd/podman/restore.go @@ -79,5 +79,14 @@ func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error { if (c.Import != "") && (c.All || c.Latest) { return errors.Errorf("Cannot use --import and --all or --latest at the same time") } + + argLen := len(c.InputArgs) + if (c.All || c.Latest) && argLen > 0 { + return errors.Errorf("no arguments are needed with --all or --latest") + } + if argLen < 1 && !c.All && !c.Latest && c.Import == "" { + return errors.Errorf("you must provide at least one name or id") + } + return runtime.Restore(getContext(), c, options) } diff --git a/test/system/005-info.bats b/test/system/005-info.bats index 47c7a52fcc..0068e35a92 100644 --- a/test/system/005-info.bats +++ b/test/system/005-info.bats @@ -14,7 +14,7 @@ Distribution: OCIRuntime:\\\s\\\+package: os: rootless: -insecure registries: +registries: store: GraphDriverName: GraphRoot: @@ -37,9 +37,7 @@ RunRoot: tests=" host.BuildahVersion | [0-9.] -host.Conmon.package | $expr_nvr host.Conmon.path | $expr_path -host.OCIRuntime.package | $expr_nvr host.OCIRuntime.path | $expr_path store.ConfigFile | $expr_path store.GraphDriverName | [a-z0-9]\\\+\\\$ diff --git a/test/system/120-load.bats b/test/system/120-load.bats index dedfe61720..f2dedb73f3 100644 --- a/test/system/120-load.bats +++ b/test/system/120-load.bats @@ -87,6 +87,10 @@ verify_iid_and_name() { @test "podman load - will not read from tty" { + if [ ! -t 0 ]; then + skip "STDIN is not a tty" + fi + run_podman 125 load is "$output" \ "Error: cannot read from terminal. Use command-line redirection" \ From 9f49c1af46f9272c25db44c6e3e6ff9ec96aad4c Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 11 Jun 2019 05:55:16 -0600 Subject: [PATCH 2/2] Prohibit use of positional args with --import I took the liberty of combining related checks together so as to avoid a little duplication; if this is not a Go best practice, I will revert. I also made a minor wording adjustment to an error message for clarity. Also: update wording of man page. Signed-off-by: Ed Santiago --- cmd/podman/restore.go | 11 ++++++++--- docs/podman-container-restore.1.md | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go index 4d715ad4f8..6e445e5dfc 100644 --- a/cmd/podman/restore.go +++ b/cmd/podman/restore.go @@ -76,11 +76,16 @@ func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error { return errors.Errorf("--tcp-established cannot be used with --name") } - if (c.Import != "") && (c.All || c.Latest) { - return errors.Errorf("Cannot use --import and --all or --latest at the same time") + argLen := len(c.InputArgs) + if c.Import != "" { + if c.All || c.Latest { + return errors.Errorf("Cannot use --import with --all or --latest") + } + if argLen > 0 { + return errors.Errorf("Cannot use --import with positional arguments") + } } - argLen := len(c.InputArgs) if (c.All || c.Latest) && argLen > 0 { return errors.Errorf("no arguments are needed with --all or --latest") } diff --git a/docs/podman-container-restore.1.md b/docs/podman-container-restore.1.md index 5b94cd2fa2..c96a37f800 100644 --- a/docs/podman-container-restore.1.md +++ b/docs/podman-container-restore.1.md @@ -45,8 +45,8 @@ connections. **--import, -i** Import a checkpoint tar.gz file, which was exported by Podman. This can be used -to import a checkpointed container from another host. It is not necessary to specify -a container when restoring from an exported checkpoint. +to import a checkpointed container from another host. Do not specify a *container* +argument when using this option. **--name, -n**