mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
e2e test: check exit codes for pull, save, inspect
Check the exit codes of pull, save and inspect to avoid masking those errors. We've hit a case where a corrupted/broken image has been pulled which then surfaced for some tests later. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -111,10 +111,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, image := range CACHE_IMAGES {
|
for _, image := range CACHE_IMAGES {
|
||||||
if err := podman.CreateArtifact(image); err != nil {
|
podman.createArtifact(image)
|
||||||
fmt.Printf("%q\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If running localized tests, the cache dir is created and populated. if the
|
// If running localized tests, the cache dir is created and populated. if the
|
||||||
@ -287,25 +284,26 @@ func (p *PodmanTestIntegration) RestoreAllArtifacts() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateArtifact creates a cached image in the artifact dir
|
// createArtifact creates a cached image in the artifact dir
|
||||||
func (p *PodmanTestIntegration) CreateArtifact(image string) error {
|
func (p *PodmanTestIntegration) createArtifact(image string) {
|
||||||
if os.Getenv("NO_TEST_CACHE") != "" {
|
if os.Getenv("NO_TEST_CACHE") != "" {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("Caching %s...", image)
|
|
||||||
dest := strings.Split(image, "/")
|
dest := strings.Split(image, "/")
|
||||||
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
|
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
|
||||||
|
fmt.Printf("Caching %s at %s...", image, destName)
|
||||||
if _, err := os.Stat(destName); os.IsNotExist(err) {
|
if _, err := os.Stat(destName); os.IsNotExist(err) {
|
||||||
pull := p.PodmanNoCache([]string{"pull", image})
|
pull := p.PodmanNoCache([]string{"pull", image})
|
||||||
pull.Wait(90)
|
pull.Wait(90)
|
||||||
|
Expect(pull.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
save := p.PodmanNoCache([]string{"save", "-o", destName, image})
|
save := p.PodmanNoCache([]string{"save", "-o", destName, image})
|
||||||
save.Wait(90)
|
save.Wait(90)
|
||||||
|
Expect(save.ExitCode()).To(Equal(0))
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf(" already exists.\n")
|
fmt.Printf(" already exists.\n")
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InspectImageJSON takes the session output of an inspect
|
// InspectImageJSON takes the session output of an inspect
|
||||||
@ -322,6 +320,7 @@ func (p *PodmanTestIntegration) InspectContainer(name string) []libpod.InspectCo
|
|||||||
cmd := []string{"inspect", name}
|
cmd := []string{"inspect", name}
|
||||||
session := p.Podman(cmd)
|
session := p.Podman(cmd)
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
return session.InspectContainerToJSON()
|
return session.InspectContainerToJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user