Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
#
project:
name: Project Checks
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 5

steps:
Expand All @@ -42,7 +42,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-12, windows-2019, windows-2022]
os: [ubuntu-24.04, macos-12, windows-2019, windows-2022]

steps:
- name: Set up Go
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
working-directory: src/github.com/containerd/continuity
cross:
name: Cross-compile
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 10
needs: [project]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

timeout-minutes: 30

Expand Down
3 changes: 2 additions & 1 deletion fs/copy_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func TestCopyReflinkWithXFS(t *testing.T) {
t.Fatal(err)
}
t.Logf("Loopback file size (after copying a %d-byte file): %d", aSize, loopbackSize)
allowedSize := int64(120 << 20) // 120MB
// 170 MiB is needed since Ubuntu 24.04. 120 MiB was enough for Ubuntu 22.04.
allowedSize := int64(170 << 20)
if loopbackSize > allowedSize {
t.Fatalf("expected <= %d, got %d", allowedSize, loopbackSize)
}
Expand Down
73 changes: 39 additions & 34 deletions fs/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,50 +204,55 @@ func TestDiffDirChangeWithOverlayfs(t *testing.T) {
skipDiffTestOnNonLinux(t)
testutil.RequiresRoot(t)

l1 := fstest.Apply(
fstest.CreateDir("/dir1", 0700),
fstest.CreateFile("/dir1/f", []byte("/dir1/f"), 0644),
fstest.CreateDir("/dir1/d", 0700),
fstest.CreateFile("/dir1/d/f", []byte("/dir1/d/f"), 0644),
f := func() {
l1 := fstest.Apply(
fstest.CreateDir("/dir1", 0700),
fstest.CreateFile("/dir1/f", []byte("/dir1/f"), 0644),
fstest.CreateDir("/dir1/d", 0700),
fstest.CreateFile("/dir1/d/f", []byte("/dir1/d/f"), 0644),

fstest.CreateDir("/dir2", 0700),
fstest.CreateDir("/dir2/d", 0700),
fstest.CreateFile("/dir2/d/f", []byte("/dir2/d/f"), 0644),
fstest.CreateDir("/dir2", 0700),
fstest.CreateDir("/dir2/d", 0700),
fstest.CreateFile("/dir2/d/f", []byte("/dir2/d/f"), 0644),

fstest.CreateDir("/dir3", 0700),
fstest.CreateFile("/dir3/f", []byte("/dir3/f"), 0644),
)
fstest.CreateDir("/dir3", 0700),
fstest.CreateFile("/dir3/f", []byte("/dir3/f"), 0644),
)

l2 := fstest.Apply(
fstest.CreateDir("/dir1", 0700),
fstest.CreateFile("/dir1/f", []byte("/dir1/f-diff"), 0644),
fstest.CreateDeviceFile("/dir1/d", os.ModeDevice|os.ModeCharDevice, 0, 0),
l2 := fstest.Apply(
fstest.CreateDir("/dir1", 0700),
fstest.CreateFile("/dir1/f", []byte("/dir1/f-diff"), 0644),
fstest.CreateDeviceFile("/dir1/d", os.ModeDevice|os.ModeCharDevice, 0, 0),

fstest.CreateDir("/dir2", 0700),
fstest.CreateDir("/dir2/d", 0700),
fstest.CreateFile("/dir2/d/f", []byte("/dir2/d/f-diff"), 0644),
fstest.CreateDir("/dir2", 0700),
fstest.CreateDir("/dir2/d", 0700),
fstest.CreateFile("/dir2/d/f", []byte("/dir2/d/f-diff"), 0644),

fstest.CreateDir("/dir3", 0700),
// TODO(fuweid): check kernel version before apply
fstest.SetXAttr("/dir3", "user.overlay.opaque", "y"),
)
fstest.CreateDir("/dir3", 0700),
// TODO(fuweid): check kernel version before apply
fstest.SetXAttr("/dir3", "user.overlay.opaque", "y"),
)

diff := []TestChange{
Modify("/dir1"),
Modify("/dir1/f"),
Delete("/dir1/d"),
diff := []TestChange{
Modify("/dir1"),
Modify("/dir1/f"),
Delete("/dir1/d"),

Modify("/dir2"),
Modify("/dir2/d"),
Modify("/dir2/d/f"),
Modify("/dir2"),
Modify("/dir2/d"),
Modify("/dir2/d/f"),

Modify("/dir3"),
Delete("/dir3/.wh..opq"),
}
Modify("/dir3"),
Delete("/dir3/.wh..opq"),
}

if err := testDiffDirChange(l1, l2, DiffSourceOverlayFS, diff); err != nil {
t.Fatalf("failed diff dir change: %+v", err)
if err := testDiffDirChange(l1, l2, DiffSourceOverlayFS, diff); err != nil {
t.Fatalf("failed diff dir change: %+v", err)
}
}
// the test assumes ext4
// https://github.com/containerd/continuity/issues/247#issuecomment-2437014104
fstest.WithMkfs(t, f, "mkfs.ext4", "-F")
}

func TestParentDirectoryPermission(t *testing.T) {
Expand Down
44 changes: 44 additions & 0 deletions fs/fstest/mkfs_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
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 fstest

import (
"os/exec"
"testing"

"github.com/containerd/continuity/testutil"
"github.com/containerd/continuity/testutil/loopback"
)

func WithMkfs(t *testing.T, f func(), mkfs ...string) {
testutil.RequiresRoot(t)
mnt := t.TempDir()
loop, err := loopback.New(100 << 20) // 100 MB
if err != nil {
t.Fatal(err)
}
defer loop.Close()
if out, err := exec.Command(mkfs[0], append(mkfs[1:], loop.Device)...).CombinedOutput(); err != nil {
t.Fatalf("could not mkfs (%v) %s: %v (out: %q)", mkfs, loop.Device, err, string(out))
}
if out, err := exec.Command("mount", loop.Device, mnt).CombinedOutput(); err != nil {
t.Fatalf("could not mount %s: %v (out: %q)", loop.Device, err, string(out))
}
defer testutil.Unmount(t, mnt)
t.Setenv("TMPDIR", mnt)
f()
}
25 changes: 25 additions & 0 deletions fs/fstest/mkfs_others.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:build !linux

/*
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 fstest

import "testing"

func WithMkfs(t *testing.T, f func(), mkfs ...string) {
t.Fatal("WithMkfs requires Linux")
}