Skip to content

Commit

Permalink
Add new requirements (HyperV, RootfulOrCGroupV2)
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Oct 22, 2024
1 parent 07cb00b commit eebd4e6
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/testutil/nerdtest/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ var CGroup = &test.Requirement{
},
}

var RootfulOrCGroupV2 = &test.Requirement{
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
isRootLess := getTarget() == targetNerdctl && rootlessutil.IsRootless()
if isRootLess {
stdout := helpers.Capture("info", "--format", "{{ json . }}")
var dinf dockercompat.Info
err := json.Unmarshal([]byte(stdout), &dinf)
assert.NilError(helpers.T(), err, "failed to parse docker info")
return dinf.CgroupVersion == "2", "we are rootless, and cgroup version is not 2"
}
return true, ""
},
}

// Soci requires that the soci snapshotter is enabled
var Soci = &test.Requirement{
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
Expand Down
29 changes: 29 additions & 0 deletions pkg/testutil/nerdtest/requirements_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//go:build !windows

/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package nerdtest

import (
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
)

var HyperV = &test.Requirement{
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
return false, "HyperV is a windows-only feature"
},
}
28 changes: 28 additions & 0 deletions pkg/testutil/nerdtest/requirements_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package nerdtest

import (
"github.com/containerd/nerdctl/v2/pkg/testutil"
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
)

var HyperV = &test.Requirement{
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
return testutil.HyperVSupported(), "HyperV is not enabled, skipping test"
},
}

0 comments on commit eebd4e6

Please sign in to comment.