Skip to content

Commit 2190587

Browse files
Grant needed privileges for snapshotter tests
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent 96fbe5b commit 2190587

3 files changed

Lines changed: 74 additions & 5 deletions

File tree

integration/client/snapshot_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
. "github.com/containerd/containerd"
2424
"github.com/containerd/containerd/snapshots"
25-
"github.com/containerd/containerd/snapshots/testsuite"
2625
)
2726

2827
func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
@@ -40,8 +39,5 @@ func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, fu
4039
}
4140

4241
func TestSnapshotterClient(t *testing.T) {
43-
if testing.Short() {
44-
t.Skip()
45-
}
46-
testsuite.SnapshotterSuite(t, "SnapshotterClient", newSnapshotter)
42+
runTestSnapshotterClient(t)
4743
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//go:build !windows
2+
// +build !windows
3+
4+
/*
5+
Copyright The containerd Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package client
21+
22+
import (
23+
"testing"
24+
25+
"github.com/containerd/containerd/snapshots/testsuite"
26+
)
27+
28+
func runTestSnapshotterClient(t *testing.T) {
29+
if testing.Short() {
30+
t.Skip()
31+
}
32+
33+
testsuite.SnapshotterSuite(t, "SnapshotterClient", newSnapshotter)
34+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//go:build windows
2+
// +build windows
3+
4+
/*
5+
Copyright The containerd Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
package client
20+
21+
import (
22+
"testing"
23+
24+
winio "github.com/Microsoft/go-winio"
25+
"github.com/containerd/containerd/snapshots/testsuite"
26+
)
27+
28+
func runTestSnapshotterClient(t *testing.T) {
29+
if testing.Short() {
30+
t.Skip()
31+
}
32+
// The SeBackupPrivilege and SeRestorePrivilege gives us access to system files inside the container mount points
33+
// (and everywhere on the system), without having to explicitly set DACLs on each location inside the mount point.
34+
if err := winio.EnableProcessPrivileges([]string{winio.SeBackupPrivilege, winio.SeRestorePrivilege}); err != nil {
35+
t.Error(err)
36+
}
37+
defer winio.DisableProcessPrivileges([]string{winio.SeBackupPrivilege, winio.SeRestorePrivilege})
38+
testsuite.SnapshotterSuite(t, "SnapshotterClient", newSnapshotter)
39+
}

0 commit comments

Comments
 (0)