Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: move aside existing remote.yaml files in remoteUseExclusive() #393

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion e2e/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/apptainer/apptainer/e2e/internal/e2e"
"github.com/apptainer/apptainer/e2e/internal/testhelper"
"github.com/apptainer/apptainer/internal/pkg/util/fs"
"github.com/apptainer/apptainer/pkg/syfs"
)

Expand Down Expand Up @@ -570,6 +571,40 @@ func (c ctx) remoteUseExclusive(t *testing.T) {
testRemote = "e2e"
)

// Move the user's and root's remote.yaml files aside for the purposes of this test
origRelPath := filepath.Join(".apptainer", "remote.yaml")
asideRelPath := fmt.Sprintf("%s.aside-remoteUseExclusive", origRelPath)
moveAsideRemoteYAML := func(t *testing.T) {
homeDir := e2e.CurrentUser(t).Dir
origRemoteYAML := filepath.Join(homeDir, origRelPath)
asideRemoteYAML := filepath.Join(homeDir, asideRelPath)
if !fs.IsReadable(origRemoteYAML) {
return
}
if err := os.Rename(origRemoteYAML, asideRemoteYAML); err != nil {
t.Fatalf("While trying to mv %q to %q: %v", origRemoteYAML, asideRemoteYAML, err)
}
}
restoreRemoteYAML := func(t *testing.T) {
homeDir := e2e.CurrentUser(t).Dir
origRemoteYAML := filepath.Join(homeDir, origRelPath)
asideRemoteYAML := filepath.Join(homeDir, asideRelPath)
if !fs.IsReadable(asideRemoteYAML) {
return
}
if err := os.Rename(asideRemoteYAML, origRemoteYAML); err != nil {
t.Fatalf("While trying to mv %q to %q: %v", asideRemoteYAML, origRemoteYAML, err)
}
}

moveAsideRemoteYAML(t)
e2e.Privileged(moveAsideRemoteYAML)(t)

t.Cleanup(func() {
restoreRemoteYAML(t)
e2e.Privileged(restoreRemoteYAML)(t)
})

tests := []struct {
name string
command string
Expand Down Expand Up @@ -665,7 +700,7 @@ func (c ctx) remoteUseExclusive(t *testing.T) {
name: "no default remote set",
command: "key search",
args: []string{"@"},
expectExit: 2,
expectExit: 255,
profile: e2e.RootProfile,
},
{
Expand Down
Loading