Skip to content

Commit

Permalink
Merge pull request containers#7848 from cevich/fix_tests
Browse files Browse the repository at this point in the history
Fix two e2e tests
  • Loading branch information
openshift-merge-robot authored Oct 1, 2020
2 parents c0dac6c + d4ca13f commit 556117c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
35 changes: 24 additions & 11 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,19 +599,21 @@ func (p *PodmanTestIntegration) CreateSeccompJson(in []byte) (string, error) {
return jsonFile, nil
}

func SkipIfRootlessCgroupsV1(reason string) {
func checkReason(reason string) {
if len(reason) < 5 {
panic("SkipIfRootlessCgroupsV1 must specify a reason to skip")
panic("Test must specify a reason to skip")
}
}

func SkipIfRootlessCgroupsV1(reason string) {
checkReason(reason)
if os.Geteuid() != 0 && !CGROUPSV2 {
Skip("[rootless]: " + reason)
}
}

func SkipIfRootless(reason string) {
if len(reason) < 5 {
panic("SkipIfRootless must specify a reason to skip")
}
checkReason(reason)
if os.Geteuid() != 0 {
ginkgo.Skip("[rootless]: " + reason)
}
Expand All @@ -629,23 +631,34 @@ func isRootless() bool {
}

func SkipIfCgroupV1(reason string) {
if len(reason) < 5 {
panic("SkipIfCgroupV1 must specify a reason to skip")
}
checkReason(reason)
if !CGROUPSV2 {
Skip(reason)
}
}

func SkipIfCgroupV2(reason string) {
if len(reason) < 5 {
panic("SkipIfCgroupV2 must specify a reason to skip")
}
checkReason(reason)
if CGROUPSV2 {
Skip(reason)
}
}

func isContainerized() bool {
// This is set to "podman" by podman automatically
if os.Getenv("container") != "" {
return true
}
return false
}

func SkipIfContainerized(reason string) {
checkReason(reason)
if isContainerized() {
Skip(reason)
}
}

// PodmanAsUser is the exec call to podman on the filesystem with the specified uid/gid and environment
func (p *PodmanTestIntegration) PodmanAsUser(args []string, uid, gid uint32, cwd string, env []string) *PodmanSessionIntegration {
podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false, false, nil)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ var _ = Describe("Podman exec", func() {
It("podman exec preserves container groups with --user and --group-add", func() {
SkipIfRemote("FIXME: This is broken SECCOMP Failues?")

dockerfile := `FROM fedora-minimal
dockerfile := `FROM registry.fedoraproject.org/fedora-minimal
RUN groupadd -g 4000 first
RUN groupadd -g 4001 second
RUN useradd -u 1000 auser`
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/systemd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ WantedBy=multi-user.target

It("podman start container by systemd", func() {
SkipIfRootless("rootless can not write to /etc")
if os.Getenv("SKIP_USERNS") != "" {
Skip("Skip userns tests.")
}
SkipIfContainerized("test does not have systemd as pid 1")

sys_file := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemd_unit_file), 0644)
Expect(sys_file).To(BeNil())
Expand Down

0 comments on commit 556117c

Please sign in to comment.