Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
  • Loading branch information
JasonYangShadow committed Feb 20, 2024
1 parent 1278915 commit 04003e6
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 160 deletions.
260 changes: 130 additions & 130 deletions e2e/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,88 @@ func (c actionTests) RunFromURI(t *testing.T) {
}
}

func (c actionTests) squashCreate(t *testing.T, testdir string) string {
squashfsImage := filepath.Join(testdir, "squashfs.simg")
// create root directory for squashfs image
squashDir, err := os.MkdirTemp(testdir, "root-squash-dir-")
if err != nil {
t.Fatal(err)
}
squashMarkerFile := "squash_marker"
if err := fs.Touch(filepath.Join(squashDir, squashMarkerFile)); err != nil {
t.Fatal(err)
}

// create the squashfs overlay image
cmd := exec.Command("mksquashfs", squashDir, squashfsImage, "-noappend", "-all-root")
if res := cmd.Run(t); res.Error != nil {
t.Fatalf("Unexpected error while running command.\n%s", res)
}

return squashfsImage
}

func (c actionTests) ext3Create(t *testing.T, testdir string) string {
ext3Img := filepath.Join(testdir, "ext3_fs.img")
// create the overlay ext3 image
cmd := exec.Command("dd", "if=/dev/zero", "of="+ext3Img, "bs=1M", "count=64", "status=none")
if res := cmd.Run(t); res.Error != nil {
t.Fatalf("Unexpected error while running command.\n%s", res)
}
cmd = exec.Command("mkfs.ext3", "-q", "-F", ext3Img)
if res := cmd.Run(t); res.Error != nil {
t.Fatalf("Unexpected error while running command.\n%s", res)
}
return ext3Img
}

func (c actionTests) sandboxCreate(t *testing.T, testdir string) string {
sandboxImage := filepath.Join(testdir, "sandbox")
// create a sandbox image from test image
c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("build"),
e2e.WithArgs("--force", "--sandbox", sandboxImage, c.env.ImagePath),
e2e.PostRun(func(t *testing.T) {
if t.Failed() {
t.Fatalf("failed to create sandbox %s from test image %s", sandboxImage, c.env.ImagePath)
}
}),
e2e.ExpectExit(0),
)
return sandboxImage
}

func (c actionTests) centosCreate(t *testing.T, testdir string) string {
centos7Image := filepath.Join(testdir, "centos7.sif")
c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("build"),
e2e.WithArgs("--force", centos7Image, "docker://centos:7"),
e2e.ExpectExit(0),
)

c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("overlay"),
e2e.WithArgs("create", centos7Image),
e2e.ExpectExit(0),
)

return centos7Image
}

func (c actionTests) overlayDirCreate(t *testing.T, testdir string) string {
dir, err := os.MkdirTemp(testdir, "overlay-dir-")
if err != nil {
t.Fatal(err)
}
return dir
}

func (c actionTests) PersistentOverlay(t *testing.T) {
e2e.EnsureImage(t, c.env)

Expand Down Expand Up @@ -726,88 +808,6 @@ func (c actionTests) PersistentOverlay(t *testing.T) {
}
})

squashfsCreate := func(t *testing.T, testdir string) string {
squashfsImage := filepath.Join(testdir, "squashfs.simg")
// create root directory for squashfs image
squashDir, err := os.MkdirTemp(testdir, "root-squash-dir-")
if err != nil {
t.Fatal(err)
}
squashMarkerFile := "squash_marker"
if err := fs.Touch(filepath.Join(squashDir, squashMarkerFile)); err != nil {
t.Fatal(err)
}

// create the squashfs overlay image
cmd := exec.Command("mksquashfs", squashDir, squashfsImage, "-noappend", "-all-root")
if res := cmd.Run(t); res.Error != nil {
t.Fatalf("Unexpected error while running command.\n%s", res)
}

return squashfsImage
}

ext3Create := func(t *testing.T, testdir string) string {
ext3Img := filepath.Join(testdir, "ext3_fs.img")
// create the overlay ext3 image
cmd := exec.Command("dd", "if=/dev/zero", "of="+ext3Img, "bs=1M", "count=64", "status=none")
if res := cmd.Run(t); res.Error != nil {
t.Fatalf("Unexpected error while running command.\n%s", res)
}
cmd = exec.Command("mkfs.ext3", "-q", "-F", ext3Img)
if res := cmd.Run(t); res.Error != nil {
t.Fatalf("Unexpected error while running command.\n%s", res)
}
return ext3Img
}

sandboxCreate := func(t *testing.T, testdir string) string {
sandboxImage := filepath.Join(testdir, "sandbox")
// create a sandbox image from test image
c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("build"),
e2e.WithArgs("--force", "--sandbox", sandboxImage, c.env.ImagePath),
e2e.PostRun(func(t *testing.T) {
if t.Failed() {
t.Fatalf("failed to create sandbox %s from test image %s", sandboxImage, c.env.ImagePath)
}
}),
e2e.ExpectExit(0),
)
return sandboxImage
}

centos7Create := func(t *testing.T, testdir string) string {
centos7Image := filepath.Join(testdir, "centos7.sif")
c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("build"),
e2e.WithArgs("--force", centos7Image, "docker://centos:7"),
e2e.ExpectExit(0),
)

c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("overlay"),
e2e.WithArgs("create", centos7Image),
e2e.ExpectExit(0),
)

return centos7Image
}

overlayDirCreate := func(t *testing.T, testdir string) string {
dir, err := os.MkdirTemp(testdir, "overlay-dir-")
if err != nil {
t.Fatal(err)
}
return dir
}

replaceTemplate := func(overlay, squash, ext3, sandbox, centos7 string, argvs []string) []string {
baseOverlayDir := filepath.Base(overlay)
var ret []string
Expand Down Expand Up @@ -932,13 +932,13 @@ func (c actionTests) PersistentOverlay(t *testing.T) {
}

// centos7 img will only create one time
centos7Dir := centos7Create(t, testdir)
centos7Dir := c.centosCreate(t, testdir)
for _, profile := range profiles {
// create an overlay directory
overlayDir := overlayDirCreate(t, testdir)
squashDir := squashfsCreate(t, testdir)
ext3Dir := ext3Create(t, testdir)
sandboxDir := sandboxCreate(t, testdir)
overlayDir := c.overlayDirCreate(t, testdir)
squashDir := c.squashCreate(t, testdir)
ext3Dir := c.ext3Create(t, testdir)
sandboxDir := c.sandboxCreate(t, testdir)

for _, tt := range tests {
var args []string
Expand Down Expand Up @@ -3050,50 +3050,50 @@ func E2ETests(env e2e.TestEnv) testhelper.Tests {
env: env,
}

// np := testhelper.NoParallel
np := testhelper.NoParallel

return testhelper.Tests{
// "action URI": c.RunFromURI, // action_URI
// "singularity link": c.singularityLink, // singularity symlink
// "exec": c.actionExec, // apptainer exec
// "exec under multiple profiles": c.actionExecMultiProfile, // apptainer exec
// "run": c.actionRun, // apptainer run
// "shell": c.actionShell, // shell interaction
// "STDPIPE": c.STDPipe, // stdin/stdout pipe
"persistent overlay": c.PersistentOverlay,
// "action basic profiles": c.actionBasicProfiles, // run basic action under different profiles
// "issue 4488": c.issue4488, // https://github.com/apptainer/singularity/issues/4488
// "issue 4587": c.issue4587, // https://github.com/apptainer/singularity/issues/4587
// "issue 4755": c.issue4755, // https://github.com/apptainer/singularity/issues/4755
// "issue 4768": c.issue4768, // https://github.com/apptainer/singularity/issues/4768
// "issue 4797": c.issue4797, // https://github.com/apptainer/singularity/issues/4797
// "issue 4823": c.issue4823, // https://github.com/apptainer/singularity/issues/4823
// "issue 4836": c.issue4836, // https://github.com/apptainer/singularity/issues/4836
// "issue 5211": c.issue5211, // https://github.com/apptainer/singularity/issues/5211
// "issue 5228": c.issue5228, // https://github.com/apptainer/singularity/issues/5228
// "issue 5271": c.issue5271, // https://github.com/apptainer/singularity/issues/5271
// "issue 5399": c.issue5399, // https://github.com/apptainer/singularity/issues/5399
// "issue 5455": c.issue5455, // https://github.com/apptainer/singularity/issues/5455
// "issue 5465": c.issue5465, // https://github.com/apptainer/singularity/issues/5465
// "issue 5599": c.issue5599, // https://github.com/apptainer/singularity/issues/5599
// "issue 5631": c.issue5631, // https://github.com/apptainer/singularity/issues/5631
// "issue 5690": c.issue5690, // https://github.com/apptainer/singularity/issues/5690
// "issue 6165": c.issue6165, // https://github.com/apptainer/singularity/issues/6165
// "issue 619": c.issue619, // https://github.com/apptainer/apptainer/issues/619
// "issue 1097": c.issue1097, // https://github.com/apptainer/apptainer/issues/1097
// "issue 1848": c.issue1848, // https://github.com/apptainer/apptainer/issues/1848
// "network": c.actionNetwork, // test basic networking
// "binds": c.actionBinds, // test various binds with --bind and --mount
// "layerType": c.actionLayerType, // verify the various layer types
// "exit and signals": c.exitSignals, // test exit and signals propagation
// "fuse mount": c.fuseMount, // test fusemount option
// "bind image": c.bindImage, // test bind image with --bind and --mount
// "unsquash": c.actionUnsquash, // test --unsquash
// "no-mount": c.actionNoMount, // test --no-mount
// "compat": np(c.actionCompat), // test --compat
// "umask": np(c.actionUmask), // test umask propagation
// "invalidRemote": np(c.invalidRemote), // GHSA-5mv9-q7fq-9394
// "fakeroot home": c.actionFakerootHome, // test home dir in fakeroot
// "relWorkdirScratch": np(c.relWorkdirScratch), // test relative --workdir with --scratch
"action URI": c.RunFromURI, // action_URI
"singularity link": c.singularityLink, // singularity symlink
"exec": c.actionExec, // apptainer exec
"exec under multiple profiles": c.actionExecMultiProfile, // apptainer exec
"run": c.actionRun, // apptainer run
"shell": c.actionShell, // shell interaction
"STDPIPE": c.STDPipe, // stdin/stdout pipe
"persistent overlay": c.PersistentOverlay,
"action basic profiles": c.actionBasicProfiles, // run basic action under different profiles
"issue 4488": c.issue4488, // https://github.com/apptainer/singularity/issues/4488
"issue 4587": c.issue4587, // https://github.com/apptainer/singularity/issues/4587
"issue 4755": c.issue4755, // https://github.com/apptainer/singularity/issues/4755
"issue 4768": c.issue4768, // https://github.com/apptainer/singularity/issues/4768
"issue 4797": c.issue4797, // https://github.com/apptainer/singularity/issues/4797
"issue 4823": c.issue4823, // https://github.com/apptainer/singularity/issues/4823
"issue 4836": c.issue4836, // https://github.com/apptainer/singularity/issues/4836
"issue 5211": c.issue5211, // https://github.com/apptainer/singularity/issues/5211
"issue 5228": c.issue5228, // https://github.com/apptainer/singularity/issues/5228
"issue 5271": c.issue5271, // https://github.com/apptainer/singularity/issues/5271
"issue 5399": c.issue5399, // https://github.com/apptainer/singularity/issues/5399
"issue 5455": c.issue5455, // https://github.com/apptainer/singularity/issues/5455
"issue 5465": c.issue5465, // https://github.com/apptainer/singularity/issues/5465
"issue 5599": c.issue5599, // https://github.com/apptainer/singularity/issues/5599
"issue 5631": c.issue5631, // https://github.com/apptainer/singularity/issues/5631
"issue 5690": c.issue5690, // https://github.com/apptainer/singularity/issues/5690
"issue 6165": c.issue6165, // https://github.com/apptainer/singularity/issues/6165
"issue 619": c.issue619, // https://github.com/apptainer/apptainer/issues/619
"issue 1097": c.issue1097, // https://github.com/apptainer/apptainer/issues/1097
"issue 1848": c.issue1848, // https://github.com/apptainer/apptainer/issues/1848
"network": c.actionNetwork, // test basic networking
"binds": c.actionBinds, // test various binds with --bind and --mount
"layerType": c.actionLayerType, // verify the various layer types
"exit and signals": c.exitSignals, // test exit and signals propagation
"fuse mount": c.fuseMount, // test fusemount option
"bind image": c.bindImage, // test bind image with --bind and --mount
"unsquash": c.actionUnsquash, // test --unsquash
"no-mount": c.actionNoMount, // test --no-mount
"compat": np(c.actionCompat), // test --compat
"umask": np(c.actionUmask), // test umask propagation
"invalidRemote": np(c.invalidRemote), // GHSA-5mv9-q7fq-9394
"fakeroot home": c.actionFakerootHome, // test home dir in fakeroot
"relWorkdirScratch": np(c.relWorkdirScratch), // test relative --workdir with --scratch
}
}
90 changes: 60 additions & 30 deletions e2e/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@ import (

// Tests imports
"github.com/apptainer/apptainer/e2e/actions"
e2ebuildcfg "github.com/apptainer/apptainer/e2e/buildcfg"
"github.com/apptainer/apptainer/e2e/cache"
"github.com/apptainer/apptainer/e2e/cgroups"
"github.com/apptainer/apptainer/e2e/cmdenvvars"
"github.com/apptainer/apptainer/e2e/config"
"github.com/apptainer/apptainer/e2e/delete"
"github.com/apptainer/apptainer/e2e/docker"
"github.com/apptainer/apptainer/e2e/ecl"
apptainerenv "github.com/apptainer/apptainer/e2e/env"
"github.com/apptainer/apptainer/e2e/gpu"
"github.com/apptainer/apptainer/e2e/help"
"github.com/apptainer/apptainer/e2e/imgbuild"
"github.com/apptainer/apptainer/e2e/inspect"
"github.com/apptainer/apptainer/e2e/instance"
"github.com/apptainer/apptainer/e2e/key"
"github.com/apptainer/apptainer/e2e/keyserver"
"github.com/apptainer/apptainer/e2e/legacy"
"github.com/apptainer/apptainer/e2e/oci"
"github.com/apptainer/apptainer/e2e/overlay"
"github.com/apptainer/apptainer/e2e/plugin"
"github.com/apptainer/apptainer/e2e/pull"
"github.com/apptainer/apptainer/e2e/push"
"github.com/apptainer/apptainer/e2e/registry"
"github.com/apptainer/apptainer/e2e/remote"
"github.com/apptainer/apptainer/e2e/run"
"github.com/apptainer/apptainer/e2e/runhelp"
"github.com/apptainer/apptainer/e2e/security"
"github.com/apptainer/apptainer/e2e/sign"
"github.com/apptainer/apptainer/e2e/verify"
"github.com/apptainer/apptainer/e2e/version"

"github.com/apptainer/apptainer/e2e/internal/e2e"
"github.com/apptainer/apptainer/e2e/internal/testhelper"
Expand Down Expand Up @@ -170,35 +200,35 @@ func Run(t *testing.T) {
suite := testhelper.NewSuite(t, testenv)

suite.AddGroup("ACTIONS", actions.E2ETests)
// suite.AddGroup("BUILDCFG", e2ebuildcfg.E2ETests)
// suite.AddGroup("BUILD", imgbuild.E2ETests)
// suite.AddGroup("CACHE", cache.E2ETests)
// suite.AddGroup("CGROUPS", cgroups.E2ETests)
// suite.AddGroup("CMDENVVARS", cmdenvvars.E2ETests)
// suite.AddGroup("CONFIG", config.E2ETests)
// suite.AddGroup("DELETE", delete.E2ETests)
// suite.AddGroup("DOCKER", docker.E2ETests)
// suite.AddGroup("ECL", ecl.E2ETests)
// suite.AddGroup("ENV", apptainerenv.E2ETests)
// suite.AddGroup("GPU", gpu.E2ETests)
// suite.AddGroup("HELP", help.E2ETests)
// suite.AddGroup("INSPECT", inspect.E2ETests)
// suite.AddGroup("INSTANCE", instance.E2ETests)
// suite.AddGroup("KEY", key.E2ETests)
// suite.AddGroup("KEYSERVER", keyserver.E2ETests)
// suite.AddGroup("LEGACY", legacy.E2ETests)
// suite.AddGroup("OCI", oci.E2ETests)
// suite.AddGroup("OVERLAY", overlay.E2ETests)
// suite.AddGroup("PLUGIN", plugin.E2ETests)
// suite.AddGroup("PULL", pull.E2ETests)
// suite.AddGroup("PUSH", push.E2ETests)
// suite.AddGroup("REGISTRY", registry.E2ETests)
// suite.AddGroup("REMOTE", remote.E2ETests)
// suite.AddGroup("RUN", run.E2ETests)
// suite.AddGroup("RUNHELP", runhelp.E2ETests)
// suite.AddGroup("SECURITY", security.E2ETests)
// suite.AddGroup("SIGN", sign.E2ETests)
// suite.AddGroup("VERIFY", verify.E2ETests)
// suite.AddGroup("VERSION", version.E2ETests)
suite.AddGroup("BUILDCFG", e2ebuildcfg.E2ETests)
suite.AddGroup("BUILD", imgbuild.E2ETests)
suite.AddGroup("CACHE", cache.E2ETests)
suite.AddGroup("CGROUPS", cgroups.E2ETests)
suite.AddGroup("CMDENVVARS", cmdenvvars.E2ETests)
suite.AddGroup("CONFIG", config.E2ETests)
suite.AddGroup("DELETE", delete.E2ETests)
suite.AddGroup("DOCKER", docker.E2ETests)
suite.AddGroup("ECL", ecl.E2ETests)
suite.AddGroup("ENV", apptainerenv.E2ETests)
suite.AddGroup("GPU", gpu.E2ETests)
suite.AddGroup("HELP", help.E2ETests)
suite.AddGroup("INSPECT", inspect.E2ETests)
suite.AddGroup("INSTANCE", instance.E2ETests)
suite.AddGroup("KEY", key.E2ETests)
suite.AddGroup("KEYSERVER", keyserver.E2ETests)
suite.AddGroup("LEGACY", legacy.E2ETests)
suite.AddGroup("OCI", oci.E2ETests)
suite.AddGroup("OVERLAY", overlay.E2ETests)
suite.AddGroup("PLUGIN", plugin.E2ETests)
suite.AddGroup("PULL", pull.E2ETests)
suite.AddGroup("PUSH", push.E2ETests)
suite.AddGroup("REGISTRY", registry.E2ETests)
suite.AddGroup("REMOTE", remote.E2ETests)
suite.AddGroup("RUN", run.E2ETests)
suite.AddGroup("RUNHELP", runhelp.E2ETests)
suite.AddGroup("SECURITY", security.E2ETests)
suite.AddGroup("SIGN", sign.E2ETests)
suite.AddGroup("VERIFY", verify.E2ETests)
suite.AddGroup("VERSION", version.E2ETests)
suite.Run()
}

0 comments on commit 04003e6

Please sign in to comment.