mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Merge pull request #2477 from rhatdan/test
Add tests to make sure podman container and podman image commands work
This commit is contained in:
@ -55,9 +55,6 @@ func getImageSubCommands() []*cobra.Command {
|
|||||||
// Commands that the local client implements
|
// Commands that the local client implements
|
||||||
func getContainerSubCommands() []*cobra.Command {
|
func getContainerSubCommands() []*cobra.Command {
|
||||||
|
|
||||||
var _listSubCommand = _psCommand
|
|
||||||
_listSubCommand.Use = "list"
|
|
||||||
|
|
||||||
return []*cobra.Command{
|
return []*cobra.Command{
|
||||||
_attachCommand,
|
_attachCommand,
|
||||||
_checkpointCommand,
|
_checkpointCommand,
|
||||||
@ -68,7 +65,6 @@ func getContainerSubCommands() []*cobra.Command {
|
|||||||
_execCommand,
|
_execCommand,
|
||||||
_exportCommand,
|
_exportCommand,
|
||||||
_killCommand,
|
_killCommand,
|
||||||
&_listSubCommand,
|
|
||||||
_logsCommand,
|
_logsCommand,
|
||||||
_mountCommand,
|
_mountCommand,
|
||||||
_pauseCommand,
|
_pauseCommand,
|
||||||
|
@ -1,27 +1,49 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var containerDescription = "Manage containers"
|
var (
|
||||||
var containerCommand = cliconfig.PodmanCommand{
|
containerDescription = "Manage containers"
|
||||||
Command: &cobra.Command{
|
containerCommand = cliconfig.PodmanCommand{
|
||||||
Use: "container",
|
Command: &cobra.Command{
|
||||||
Short: "Manage Containers",
|
Use: "container",
|
||||||
Long: containerDescription,
|
Short: "Manage Containers",
|
||||||
TraverseChildren: true,
|
Long: containerDescription,
|
||||||
},
|
TraverseChildren: true,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Commands that are universally implemented.
|
listSubCommand cliconfig.PsValues
|
||||||
var containerCommands = []*cobra.Command{
|
_listSubCommand = &cobra.Command{
|
||||||
_containerExistsCommand,
|
Use: strings.Replace(_psCommand.Use, "ps", "list", 1),
|
||||||
_inspectCommand,
|
Short: _psCommand.Short,
|
||||||
}
|
Long: _psCommand.Long,
|
||||||
|
Aliases: []string{"ls"},
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
listSubCommand.InputArgs = args
|
||||||
|
listSubCommand.GlobalFlags = MainGlobalOpts
|
||||||
|
return psCmd(&listSubCommand)
|
||||||
|
},
|
||||||
|
Example: strings.Replace(_psCommand.Example, "podman ps", "podman container list", -1),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commands that are universally implemented.
|
||||||
|
containerCommands = []*cobra.Command{
|
||||||
|
_containerExistsCommand,
|
||||||
|
_inspectCommand,
|
||||||
|
_listSubCommand,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
listSubCommand.Command = _listSubCommand
|
||||||
|
psInit(&listSubCommand)
|
||||||
|
|
||||||
containerCommand.AddCommand(containerCommands...)
|
containerCommand.AddCommand(containerCommands...)
|
||||||
containerCommand.AddCommand(getContainerSubCommands()...)
|
containerCommand.AddCommand(getContainerSubCommands()...)
|
||||||
containerCommand.SetUsageTemplate(UsageTemplate())
|
containerCommand.SetUsageTemplate(UsageTemplate())
|
||||||
|
@ -16,14 +16,39 @@ var (
|
|||||||
Long: imageDescription,
|
Long: imageDescription,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_imagesSubCommand = _imagesCommand
|
imagesSubCommand cliconfig.ImagesValues
|
||||||
_rmSubCommand = _rmiCommand
|
_imagesSubCommand = &cobra.Command{
|
||||||
|
Use: strings.Replace(_imagesCommand.Use, "images", "list", 1),
|
||||||
|
Short: _imagesCommand.Short,
|
||||||
|
Long: _imagesCommand.Long,
|
||||||
|
Aliases: []string{"ls"},
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
imagesSubCommand.InputArgs = args
|
||||||
|
imagesSubCommand.GlobalFlags = MainGlobalOpts
|
||||||
|
return imagesCmd(&imagesSubCommand)
|
||||||
|
},
|
||||||
|
Example: strings.Replace(_imagesCommand.Example, "podman images", "podman image list", -1),
|
||||||
|
}
|
||||||
|
|
||||||
|
rmSubCommand cliconfig.RmiValues
|
||||||
|
_rmSubCommand = &cobra.Command{
|
||||||
|
Use: strings.Replace(_rmiCommand.Use, "rmi", "rm", 1),
|
||||||
|
Short: _rmiCommand.Short,
|
||||||
|
Long: _rmiCommand.Long,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
rmSubCommand.InputArgs = args
|
||||||
|
rmSubCommand.GlobalFlags = MainGlobalOpts
|
||||||
|
return rmiCmd(&rmSubCommand)
|
||||||
|
},
|
||||||
|
Example: strings.Replace(_rmiCommand.Example, "podman rmi", "podman image rm", -1),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//imageSubCommands are implemented both in local and remote clients
|
//imageSubCommands are implemented both in local and remote clients
|
||||||
var imageSubCommands = []*cobra.Command{
|
var imageSubCommands = []*cobra.Command{
|
||||||
_buildCommand,
|
_buildCommand,
|
||||||
_historyCommand,
|
_historyCommand,
|
||||||
|
_imagesSubCommand,
|
||||||
_imageExistsCommand,
|
_imageExistsCommand,
|
||||||
_importCommand,
|
_importCommand,
|
||||||
_inspectCommand,
|
_inspectCommand,
|
||||||
@ -31,23 +56,20 @@ var imageSubCommands = []*cobra.Command{
|
|||||||
_pruneImagesCommand,
|
_pruneImagesCommand,
|
||||||
_pullCommand,
|
_pullCommand,
|
||||||
_pushCommand,
|
_pushCommand,
|
||||||
|
_rmSubCommand,
|
||||||
_saveCommand,
|
_saveCommand,
|
||||||
_tagCommand,
|
_tagCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
rmSubCommand.Command = _rmSubCommand
|
||||||
|
rmiInit(&rmSubCommand)
|
||||||
|
|
||||||
|
imagesSubCommand.Command = _imagesSubCommand
|
||||||
|
imagesInit(&imagesSubCommand)
|
||||||
|
|
||||||
imageCommand.SetUsageTemplate(UsageTemplate())
|
imageCommand.SetUsageTemplate(UsageTemplate())
|
||||||
imageCommand.AddCommand(imageSubCommands...)
|
imageCommand.AddCommand(imageSubCommands...)
|
||||||
imageCommand.AddCommand(getImageSubCommands()...)
|
imageCommand.AddCommand(getImageSubCommands()...)
|
||||||
|
|
||||||
// Setup of "images" to appear as "list"
|
|
||||||
_imagesSubCommand.Use = strings.Replace(_imagesSubCommand.Use, "images", "list", 1)
|
|
||||||
_imagesSubCommand.Aliases = []string{"ls"}
|
|
||||||
_imagesSubCommand.Example = strings.Replace(_imagesSubCommand.Example, "podman images", "podman image list", -1)
|
|
||||||
imageCommand.AddCommand(&_imagesSubCommand)
|
|
||||||
|
|
||||||
// It makes no sense to keep 'podman images rmi'; just use 'rm'
|
|
||||||
_rmSubCommand.Use = strings.Replace(_rmSubCommand.Use, "rmi", "rm", 1)
|
|
||||||
_rmSubCommand.Example = strings.Replace(_rmSubCommand.Example, "podman rmi", "podman image rm", -1)
|
|
||||||
imageCommand.AddCommand(&_rmSubCommand)
|
|
||||||
}
|
}
|
||||||
|
@ -102,24 +102,28 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func imagesInit(command *cliconfig.ImagesValues) {
|
||||||
imagesCommand.Command = &_imagesCommand
|
command.SetUsageTemplate(UsageTemplate())
|
||||||
imagesCommand.SetUsageTemplate(UsageTemplate())
|
|
||||||
|
|
||||||
flags := imagesCommand.Flags()
|
flags := command.Flags()
|
||||||
flags.BoolVarP(&imagesCommand.All, "all", "a", false, "Show all images (default hides intermediate images)")
|
flags.BoolVarP(&command.All, "all", "a", false, "Show all images (default hides intermediate images)")
|
||||||
flags.BoolVar(&imagesCommand.Digests, "digests", false, "Show digests")
|
flags.BoolVar(&command.Digests, "digests", false, "Show digests")
|
||||||
flags.StringSliceVarP(&imagesCommand.Filter, "filter", "f", []string{}, "Filter output based on conditions provided (default [])")
|
flags.StringSliceVarP(&command.Filter, "filter", "f", []string{}, "Filter output based on conditions provided (default [])")
|
||||||
flags.StringVar(&imagesCommand.Format, "format", "", "Change the output format to JSON or a Go template")
|
flags.StringVar(&command.Format, "format", "", "Change the output format to JSON or a Go template")
|
||||||
flags.BoolVarP(&imagesCommand.Noheading, "noheading", "n", false, "Do not print column headings")
|
flags.BoolVarP(&command.Noheading, "noheading", "n", false, "Do not print column headings")
|
||||||
// TODO Need to learn how to deal with second name being a string instead of a char.
|
// TODO Need to learn how to deal with second name being a string instead of a char.
|
||||||
// This needs to be "no-trunc, notruncate"
|
// This needs to be "no-trunc, notruncate"
|
||||||
flags.BoolVar(&imagesCommand.NoTrunc, "no-trunc", false, "Do not truncate output")
|
flags.BoolVar(&command.NoTrunc, "no-trunc", false, "Do not truncate output")
|
||||||
flags.BoolVarP(&imagesCommand.Quiet, "quiet", "q", false, "Display only image IDs")
|
flags.BoolVarP(&command.Quiet, "quiet", "q", false, "Display only image IDs")
|
||||||
flags.StringVar(&imagesCommand.Sort, "sort", "created", "Sort by created, id, repository, size, or tag")
|
flags.StringVar(&command.Sort, "sort", "created", "Sort by created, id, repository, size, or tag")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
imagesCommand.Command = &_imagesCommand
|
||||||
|
imagesInit(&imagesCommand)
|
||||||
|
}
|
||||||
|
|
||||||
func imagesCmd(c *cliconfig.ImagesValues) error {
|
func imagesCmd(c *cliconfig.ImagesValues) error {
|
||||||
var (
|
var (
|
||||||
filterFuncs []imagefilters.ResultFilter
|
filterFuncs []imagefilters.ResultFilter
|
||||||
|
@ -173,27 +173,31 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func psInit(command *cliconfig.PsValues) {
|
||||||
psCommand.Command = &_psCommand
|
command.SetUsageTemplate(UsageTemplate())
|
||||||
psCommand.SetUsageTemplate(UsageTemplate())
|
flags := command.Flags()
|
||||||
flags := psCommand.Flags()
|
flags.BoolVarP(&command.All, "all", "a", false, "Show all the containers, default is only running containers")
|
||||||
flags.BoolVarP(&psCommand.All, "all", "a", false, "Show all the containers, default is only running containers")
|
flags.StringSliceVarP(&command.Filter, "filter", "f", []string{}, "Filter output based on conditions given")
|
||||||
flags.StringSliceVarP(&psCommand.Filter, "filter", "f", []string{}, "Filter output based on conditions given")
|
flags.StringVar(&command.Format, "format", "", "Pretty-print containers to JSON or using a Go template")
|
||||||
flags.StringVar(&psCommand.Format, "format", "", "Pretty-print containers to JSON or using a Go template")
|
flags.IntVarP(&command.Last, "last", "n", -1, "Print the n last created containers (all states)")
|
||||||
flags.IntVarP(&psCommand.Last, "last", "n", -1, "Print the n last created containers (all states)")
|
flags.BoolVarP(&command.Latest, "latest", "l", false, "Show the latest container created (all states)")
|
||||||
flags.BoolVarP(&psCommand.Latest, "latest", "l", false, "Show the latest container created (all states)")
|
flags.BoolVar(&command.Namespace, "namespace", false, "Display namespace information")
|
||||||
flags.BoolVar(&psCommand.Namespace, "namespace", false, "Display namespace information")
|
flags.BoolVar(&command.Namespace, "ns", false, "Display namespace information")
|
||||||
flags.BoolVar(&psCommand.Namespace, "ns", false, "Display namespace information")
|
flags.BoolVar(&command.NoTrunct, "no-trunc", false, "Display the extended information")
|
||||||
flags.BoolVar(&psCommand.NoTrunct, "no-trunc", false, "Display the extended information")
|
flags.BoolVarP(&command.Pod, "pod", "p", false, "Print the ID and name of the pod the containers are associated with")
|
||||||
flags.BoolVarP(&psCommand.Pod, "pod", "p", false, "Print the ID and name of the pod the containers are associated with")
|
flags.BoolVarP(&command.Quiet, "quiet", "q", false, "Print the numeric IDs of the containers only")
|
||||||
flags.BoolVarP(&psCommand.Quiet, "quiet", "q", false, "Print the numeric IDs of the containers only")
|
flags.BoolVarP(&command.Size, "size", "s", false, "Display the total file sizes")
|
||||||
flags.BoolVarP(&psCommand.Size, "size", "s", false, "Display the total file sizes")
|
flags.StringVar(&command.Sort, "sort", "created", "Sort output by command, created, id, image, names, runningfor, size, or status")
|
||||||
flags.StringVar(&psCommand.Sort, "sort", "created", "Sort output by command, created, id, image, names, runningfor, size, or status")
|
flags.BoolVar(&command.Sync, "sync", false, "Sync container state with OCI runtime")
|
||||||
flags.BoolVar(&psCommand.Sync, "sync", false, "Sync container state with OCI runtime")
|
|
||||||
|
|
||||||
markFlagHiddenForRemoteClient("latest", flags)
|
markFlagHiddenForRemoteClient("latest", flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
psCommand.Command = &_psCommand
|
||||||
|
psInit(&psCommand)
|
||||||
|
}
|
||||||
|
|
||||||
func psCmd(c *cliconfig.PsValues) error {
|
func psCmd(c *cliconfig.PsValues) error {
|
||||||
if c.Bool("trace") {
|
if c.Bool("trace") {
|
||||||
span, _ := opentracing.StartSpanFromContext(Ctx, "psCmd")
|
span, _ := opentracing.StartSpanFromContext(Ctx, "psCmd")
|
||||||
|
@ -29,12 +29,16 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func rmiInit(command *cliconfig.RmiValues) {
|
||||||
|
command.SetUsageTemplate(UsageTemplate())
|
||||||
|
flags := command.Flags()
|
||||||
|
flags.BoolVarP(&command.All, "all", "a", false, "Remove all images")
|
||||||
|
flags.BoolVarP(&command.Force, "force", "f", false, "Force Removal of the image")
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rmiCommand.Command = &_rmiCommand
|
rmiCommand.Command = &_rmiCommand
|
||||||
rmiCommand.SetUsageTemplate(UsageTemplate())
|
rmiInit(&rmiCommand)
|
||||||
flags := rmiCommand.Flags()
|
|
||||||
flags.BoolVarP(&rmiCommand.All, "all", "a", false, "Remove all images")
|
|
||||||
flags.BoolVarP(&rmiCommand.Force, "force", "f", false, "Force Removal of the image")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func rmiCmd(c *cliconfig.RmiValues) error {
|
func rmiCmd(c *cliconfig.RmiValues) error {
|
||||||
|
@ -51,6 +51,16 @@ var _ = Describe("Podman attach", func() {
|
|||||||
Expect(results.ExitCode()).To(Equal(125))
|
Expect(results.ExitCode()).To(Equal(125))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container attach to non-running container", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-d", "-i", ALPINE, "ls"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
results := podmanTest.Podman([]string{"container", "attach", "test1"})
|
||||||
|
results.WaitWithDefaultTimeout()
|
||||||
|
Expect(results.ExitCode()).To(Equal(125))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman attach to multiple containers", func() {
|
It("podman attach to multiple containers", func() {
|
||||||
session := podmanTest.RunTopContainer("test1")
|
session := podmanTest.RunTopContainer("test1")
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -50,6 +50,21 @@ var _ = Describe("Podman commit", func() {
|
|||||||
Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue())
|
Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container commit container", func() {
|
||||||
|
_, ec, _ := podmanTest.RunLsContainer("test1")
|
||||||
|
Expect(ec).To(Equal(0))
|
||||||
|
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"container", "commit", "test1", "foobar.com/test1-image:latest"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
check := podmanTest.Podman([]string{"container", "inspect", "foobar.com/test1-image:latest"})
|
||||||
|
check.WaitWithDefaultTimeout()
|
||||||
|
data := check.InspectImageJSON()
|
||||||
|
Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
It("podman commit container with message", func() {
|
It("podman commit container with message", func() {
|
||||||
_, ec, _ := podmanTest.RunLsContainer("test1")
|
_, ec, _ := podmanTest.RunLsContainer("test1")
|
||||||
Expect(ec).To(Equal(0))
|
Expect(ec).To(Equal(0))
|
||||||
|
@ -56,6 +56,13 @@ var _ = Describe("Podman create", func() {
|
|||||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container create container based on a remote image", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "create", BB_GLIBC, "ls"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman create using short options", func() {
|
It("podman create using short options", func() {
|
||||||
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -43,6 +43,13 @@ var _ = Describe("Podman diff", func() {
|
|||||||
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))
|
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container diff of image", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "diff", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman diff bogus image", func() {
|
It("podman diff bogus image", func() {
|
||||||
session := podmanTest.Podman([]string{"diff", "1234"})
|
session := podmanTest.Podman([]string{"diff", "1234"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -57,6 +57,16 @@ var _ = Describe("Podman exec", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container exec simple command", func() {
|
||||||
|
setup := podmanTest.RunTopContainer("test1")
|
||||||
|
setup.WaitWithDefaultTimeout()
|
||||||
|
Expect(setup.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"container", "exec", "test1", "ls"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman exec simple command using latest", func() {
|
It("podman exec simple command using latest", func() {
|
||||||
setup := podmanTest.RunTopContainer("test1")
|
setup := podmanTest.RunTopContainer("test1")
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
|
@ -50,6 +50,22 @@ var _ = Describe("Podman export", func() {
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container export output flag", func() {
|
||||||
|
SkipIfRemote()
|
||||||
|
_, ec, cid := podmanTest.RunLsContainer("")
|
||||||
|
Expect(ec).To(Equal(0))
|
||||||
|
|
||||||
|
outfile := filepath.Join(podmanTest.TempDir, "container.tar")
|
||||||
|
result := podmanTest.Podman([]string{"container", "export", "-o", outfile, cid})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
_, err := os.Stat(outfile)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
err = os.Remove(outfile)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
})
|
||||||
|
|
||||||
It("podman export bad filename", func() {
|
It("podman export bad filename", func() {
|
||||||
_, ec, cid := podmanTest.RunLsContainer("")
|
_, ec, cid := podmanTest.RunLsContainer("")
|
||||||
Expect(ec).To(Equal(0))
|
Expect(ec).To(Equal(0))
|
||||||
|
@ -43,6 +43,15 @@ var _ = Describe("Podman images", func() {
|
|||||||
Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue())
|
Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman image List", func() {
|
||||||
|
session := podmanTest.Podman([]string{"image", "list"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
|
||||||
|
Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue())
|
||||||
|
Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
It("podman images with multiple tags", func() {
|
It("podman images with multiple tags", func() {
|
||||||
// tag "docker.io/library/alpine:latest" to "foo:{a,b,c}"
|
// tag "docker.io/library/alpine:latest" to "foo:{a,b,c}"
|
||||||
session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"})
|
session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"})
|
||||||
@ -135,6 +144,23 @@ var _ = Describe("Podman images", func() {
|
|||||||
Expect(len(result.OutputToStringArray())).To(Equal(1))
|
Expect(len(result.OutputToStringArray())).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman image list filter after image", func() {
|
||||||
|
if podmanTest.RemoteTest {
|
||||||
|
Skip("Does not work on remote client")
|
||||||
|
}
|
||||||
|
rmi := podmanTest.Podman([]string{"image", "rm", "busybox"})
|
||||||
|
rmi.WaitWithDefaultTimeout()
|
||||||
|
Expect(rmi.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
dockerfile := `FROM docker.io/library/alpine:latest
|
||||||
|
`
|
||||||
|
podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
|
||||||
|
result := podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=docker.io/library/alpine:latest"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).To(Equal(1))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman images filter dangling", func() {
|
It("podman images filter dangling", func() {
|
||||||
if podmanTest.RemoteTest {
|
if podmanTest.RemoteTest {
|
||||||
Skip("Does not work on remote client")
|
Skip("Does not work on remote client")
|
||||||
@ -164,6 +190,21 @@ var _ = Describe("Podman images", func() {
|
|||||||
Expect(result.ExitCode()).To(Equal(0))
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman check for image with sha256: prefix", func() {
|
||||||
|
if podmanTest.RemoteTest {
|
||||||
|
Skip("Does not work on remote client")
|
||||||
|
}
|
||||||
|
session := podmanTest.Podman([]string{"image", "inspect", "--format=json", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
||||||
|
imageData := session.InspectImageJSON()
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"image", "ls", fmt.Sprintf("sha256:%s", imageData[0].ID)})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman images sort by tag", func() {
|
It("podman images sort by tag", func() {
|
||||||
session := podmanTest.Podman([]string{"images", "--sort", "tag", "--format={{.Tag}}"})
|
session := podmanTest.Podman([]string{"images", "--sort", "tag", "--format={{.Tag}}"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -41,6 +41,19 @@ var _ = Describe("Podman kill", func() {
|
|||||||
Expect(session.ExitCode()).To(Not(Equal(0)))
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container kill a running container by id", func() {
|
||||||
|
session := podmanTest.RunTopContainer("")
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid := session.OutputToString()
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "kill", cid})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman kill a running container by id", func() {
|
It("podman kill a running container by id", func() {
|
||||||
session := podmanTest.RunTopContainer("")
|
session := podmanTest.RunTopContainer("")
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -49,6 +49,21 @@ var _ = Describe("Podman mount", func() {
|
|||||||
Expect(umount.ExitCode()).To(Equal(0))
|
Expect(umount.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container mount", func() {
|
||||||
|
setup := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"})
|
||||||
|
setup.WaitWithDefaultTimeout()
|
||||||
|
Expect(setup.ExitCode()).To(Equal(0))
|
||||||
|
cid := setup.OutputToString()
|
||||||
|
|
||||||
|
mount := podmanTest.Podman([]string{"container", "mount", cid})
|
||||||
|
mount.WaitWithDefaultTimeout()
|
||||||
|
Expect(mount.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
umount := podmanTest.Podman([]string{"container", "umount", cid})
|
||||||
|
umount.WaitWithDefaultTimeout()
|
||||||
|
Expect(umount.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman mount with json format", func() {
|
It("podman mount with json format", func() {
|
||||||
setup := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
setup := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
|
@ -80,6 +80,23 @@ var _ = Describe("Podman pause", func() {
|
|||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container pause a running container by id", func() {
|
||||||
|
session := podmanTest.RunTopContainer("")
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid := session.OutputToString()
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "pause", cid})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||||
|
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring(pausedState))
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"container", "unpause", cid})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
})
|
||||||
|
|
||||||
It("podman unpause a running container by id", func() {
|
It("podman unpause a running container by id", func() {
|
||||||
session := podmanTest.RunTopContainer("")
|
session := podmanTest.RunTopContainer("")
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -60,6 +60,19 @@ var _ = Describe("Podman port", func() {
|
|||||||
Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue())
|
Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container port -l nginx", func() {
|
||||||
|
podmanTest.RestoreArtifact(nginx)
|
||||||
|
session := podmanTest.Podman([]string{"container", "run", "-dt", "-P", nginx})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "port", "-l"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
port := strings.Split(result.OutputToStringArray()[0], ":")[1]
|
||||||
|
Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
It("podman port -l port nginx", func() {
|
It("podman port -l port nginx", func() {
|
||||||
podmanTest.RestoreArtifact(nginx)
|
podmanTest.RestoreArtifact(nginx)
|
||||||
session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx})
|
session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx})
|
||||||
|
@ -65,6 +65,21 @@ var _ = Describe("Podman ps", func() {
|
|||||||
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0))
|
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container list all", func() {
|
||||||
|
_, ec, _ := podmanTest.RunLsContainer("")
|
||||||
|
Expect(ec).To(Equal(0))
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "list", "-a"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0))
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"container", "ls", "-a"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman ps size flag", func() {
|
It("podman ps size flag", func() {
|
||||||
_, ec, _ := podmanTest.RunLsContainer("")
|
_, ec, _ := podmanTest.RunLsContainer("")
|
||||||
Expect(ec).To(Equal(0))
|
Expect(ec).To(Equal(0))
|
||||||
|
@ -90,6 +90,21 @@ var _ = Describe("Podman restart", func() {
|
|||||||
Expect(restartTime.OutputToString()).To(Not(Equal(startTime.OutputToString())))
|
Expect(restartTime.OutputToString()).To(Not(Equal(startTime.OutputToString())))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("Podman container restart running container", func() {
|
||||||
|
_ = podmanTest.RunTopContainer("test1")
|
||||||
|
ok := WaitForContainer(podmanTest)
|
||||||
|
Expect(ok).To(BeTrue())
|
||||||
|
startTime := podmanTest.Podman([]string{"container", "inspect", "--format='{{.State.StartedAt}}'", "test1"})
|
||||||
|
startTime.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"container", "restart", "test1"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
restartTime := podmanTest.Podman([]string{"container", "inspect", "--format='{{.State.StartedAt}}'", "test1"})
|
||||||
|
restartTime.WaitWithDefaultTimeout()
|
||||||
|
Expect(restartTime.OutputToString()).To(Not(Equal(startTime.OutputToString())))
|
||||||
|
})
|
||||||
|
|
||||||
It("Podman restart multiple containers", func() {
|
It("Podman restart multiple containers", func() {
|
||||||
_, exitCode, _ := podmanTest.RunLsContainer("test1")
|
_, exitCode, _ := podmanTest.RunLsContainer("test1")
|
||||||
Expect(exitCode).To(Equal(0))
|
Expect(exitCode).To(Equal(0))
|
||||||
|
@ -65,6 +65,17 @@ var _ = Describe("Podman rm", func() {
|
|||||||
Expect(result.ExitCode()).To(Equal(0))
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container rm created container", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid := session.OutputToString()
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "rm", cid})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman rm running container with -f", func() {
|
It("podman rm running container with -f", func() {
|
||||||
session := podmanTest.RunTopContainer("")
|
session := podmanTest.RunTopContainer("")
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -68,6 +68,20 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container run a container based on on a short name with localhost", func() {
|
||||||
|
podmanTest.RestoreArtifact(nginx)
|
||||||
|
tag := podmanTest.Podman([]string{"image", "tag", nginx, "localhost/libpod/alpine_nginx:latest"})
|
||||||
|
tag.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
rmi := podmanTest.Podman([]string{"image", "rm", nginx})
|
||||||
|
rmi.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"container", "run", "libpod/alpine_nginx:latest", "ls"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull"))
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman run a container based on local image with short options", func() {
|
It("podman run a container based on local image with short options", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -50,6 +50,16 @@ var _ = Describe("Podman start", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container start single container by id", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "create", "-d", ALPINE, "ls"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid := session.OutputToString()
|
||||||
|
session = podmanTest.Podman([]string{"container", "start", cid})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman start single container by name", func() {
|
It("podman start single container by name", func() {
|
||||||
session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -59,6 +59,15 @@ var _ = Describe("Podman stop", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman stop container by name", func() {
|
||||||
|
session := podmanTest.RunTopContainer("test1")
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
session = podmanTest.Podman([]string{"container", "stop", "test1"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman stop stopped container", func() {
|
It("podman stop stopped container", func() {
|
||||||
session := podmanTest.RunTopContainer("test1")
|
session := podmanTest.RunTopContainer("test1")
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -65,6 +65,17 @@ var _ = Describe("Podman top", func() {
|
|||||||
Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1))
|
Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container top on container", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "top", "-d", "2"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
result := podmanTest.Podman([]string{"container", "top", "-l"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman top with options", func() {
|
It("podman top with options", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"})
|
session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -66,4 +66,11 @@ var _ = Describe("Podman wait", func() {
|
|||||||
session = podmanTest.Podman([]string{"wait", "-l"})
|
session = podmanTest.Podman([]string{"wait", "-l"})
|
||||||
session.Wait(20)
|
session.Wait(20)
|
||||||
})
|
})
|
||||||
|
It("podman container wait on latest container", func() {
|
||||||
|
session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"})
|
||||||
|
session.Wait(20)
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
session = podmanTest.Podman([]string{"container", "wait", "-l"})
|
||||||
|
session.Wait(20)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user