Skip to content

Commit 6f64236

Browse files
authored
Merge pull request #3592 from apostasie/series-5
Add new requirements (HyperV, CgroupsAccessible)
2 parents 4d64f29 + bbb5b30 commit 6f64236

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

pkg/testutil/nerdtest/requirements.go

+17
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@ var CGroup = &test.Requirement{
171171
},
172172
}
173173

174+
var CgroupsAccessible = test.Require(
175+
CGroup,
176+
&test.Requirement{
177+
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
178+
isRootLess := getTarget() == targetNerdctl && rootlessutil.IsRootless()
179+
if isRootLess {
180+
stdout := helpers.Capture("info", "--format", "{{ json . }}")
181+
var dinf dockercompat.Info
182+
err := json.Unmarshal([]byte(stdout), &dinf)
183+
assert.NilError(helpers.T(), err, "failed to parse docker info")
184+
return dinf.CgroupVersion == "2", "we are rootless, and cgroup version is not 2"
185+
}
186+
return true, ""
187+
},
188+
},
189+
)
190+
174191
// Soci requires that the soci snapshotter is enabled
175192
var Soci = &test.Requirement{
176193
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build !windows
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package nerdtest
20+
21+
import (
22+
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
23+
)
24+
25+
var HyperV = &test.Requirement{
26+
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
27+
return false, "HyperV is a windows-only feature"
28+
},
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package nerdtest
18+
19+
import (
20+
"github.com/containerd/nerdctl/v2/pkg/testutil"
21+
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
22+
)
23+
24+
var HyperV = &test.Requirement{
25+
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
26+
return testutil.HyperVSupported(), "HyperV is not enabled, skipping test"
27+
},
28+
}

0 commit comments

Comments
 (0)