From 5025b5370446173221ab0e0474d4dbf0fe8c89e4 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 14 Nov 2017 16:34:42 -0500 Subject: [PATCH 1/4] Re-enable unit tests on appveyor Signed-off-by: Daniel Nephin --- .appveyor.yml | 14 ++++---------- .travis.yml | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6e2494ccb..71fc13951 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -20,24 +20,18 @@ before_build: - appveyor DownloadFile https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.zip - 7z x go%GO_VERSION%.windows-amd64.zip -oC:\ >nul - go version - # TODO: re-enable once the content unit-test have been updated to pass on windows - #- choco install codecov + - choco install codecov build_script: - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe setup check" - - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build" - - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe binaries" + - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build binaries" test_script: # TODO: need an equivalent of TRAVIS_COMMIT_RANGE # - GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" C:\MinGW\bin\mingw32-make.exe dco + - bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe coverage root-coverage" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration-parallel" - # TODO: re-enable once the content unit-test have been updated to pass on windows - #- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe coverage" - #- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe root-coverage" on_success: - # Note that, a Codecov upload token is not required. - # TODO: re-enable once the content unit-test have been updated to pass on windows - #- codecov -f coverage.txt + codecov --flag windows diff --git a/.travis.yml b/.travis.yml index 8351057aa..a33fc828e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ script: - if [ "$GOOS" = "linux" ]; then sudo PATH=$PATH GOPATH=$GOPATH make integration-parallel ; fi after_success: - - bash <(curl -s https://codecov.io/bash) + - bash <(curl -s https://codecov.io/bash) -F linux before_deploy: - make release From 666d946455d06b07fdfe7d0f4dc026b8f295dffe Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 14 Nov 2017 17:41:43 -0500 Subject: [PATCH 2/4] Implement diff.compareSysStat on windows and update diff tests to work with slash paths on windows Signed-off-by: Daniel Nephin --- fs/diff_test.go | 6 +++--- fs/diff_windows.go | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/diff_test.go b/fs/diff_test.go index 327cab724..d9c6d34e2 100644 --- a/fs/diff_test.go +++ b/fs/diff_test.go @@ -322,20 +322,20 @@ func changesString(c []TestChange) string { func Add(p string) TestChange { return TestChange{ Kind: ChangeKindAdd, - Path: p, + Path: filepath.FromSlash(p), } } func Delete(p string) TestChange { return TestChange{ Kind: ChangeKindDelete, - Path: p, + Path: filepath.FromSlash(p), } } func Modify(p string) TestChange { return TestChange{ Kind: ChangeKindModify, - Path: p, + Path: filepath.FromSlash(p), } } diff --git a/fs/diff_windows.go b/fs/diff_windows.go index 7bbd66284..8eed36507 100644 --- a/fs/diff_windows.go +++ b/fs/diff_windows.go @@ -1,14 +1,25 @@ package fs -import "os" +import ( + "os" + + "golang.org/x/sys/windows" +) func detectDirDiff(upper, lower string) *diffDirOptions { return nil } func compareSysStat(s1, s2 interface{}) (bool, error) { - // TODO: Use windows specific sys type - return false, nil + f1, ok := s1.(windows.Win32FileAttributeData) + if !ok { + return false, nil + } + f2, ok := s2.(windows.Win32FileAttributeData) + if !ok { + return false, nil + } + return f1.FileAttributes == f2.FileAttributes, nil } func compareCapabilities(p1, p2 string) (bool, error) { From fe5bb4a0fcb74ad1a73afcdfe501982ff0ae0808 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 15 Nov 2017 13:27:35 -0500 Subject: [PATCH 3/4] Update platform tests to use the defaultOS fix tests on windows Signed-off-by: Daniel Nephin --- platforms/platforms_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platforms/platforms_test.go b/platforms/platforms_test.go index a88dfbf42..b4148c9d0 100644 --- a/platforms/platforms_test.go +++ b/platforms/platforms_test.go @@ -87,7 +87,7 @@ func TestParseSelector(t *testing.T) { OS: defaultOS, Architecture: "arm", }, - formatted: "linux/arm", + formatted: joinNotEmpty(defaultOS, "arm"), }, { input: "armel", @@ -96,7 +96,7 @@ func TestParseSelector(t *testing.T) { Architecture: "arm", Variant: "v6", }, - formatted: "linux/arm/v6", + formatted: joinNotEmpty(defaultOS, "arm/v6"), }, { input: "armhf", @@ -104,7 +104,7 @@ func TestParseSelector(t *testing.T) { OS: defaultOS, Architecture: "arm", }, - formatted: "linux/arm", + formatted: joinNotEmpty(defaultOS, "arm"), }, { input: "Aarch64", From a72279e53df5d212b5f03e5b0293aaffbeab9141 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 14 Nov 2017 18:13:11 -0500 Subject: [PATCH 4/4] Skip some tests on windows where the implementation is missing Signed-off-by: Daniel Nephin --- .appveyor.yml | 2 +- content/testsuite/testsuite.go | 6 +++++- fs/diff_test.go | 11 +++++++++++ metadata/snapshot_test.go | 4 ++++ snapshot/naive/naive_test.go | 4 ++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 71fc13951..e916b8e65 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -34,4 +34,4 @@ test_script: - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration-parallel" on_success: - codecov --flag windows + codecov --flag windows -f coverage.txt diff --git a/content/testsuite/testsuite.go b/content/testsuite/testsuite.go index d5d4fa3a9..6a4fd2043 100644 --- a/content/testsuite/testsuite.go +++ b/content/testsuite/testsuite.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "math/rand" "os" + "runtime" "testing" "time" @@ -329,7 +330,10 @@ func checkInfo(ctx context.Context, cs content.Store, d digest.Digest, expected if info.CreatedAt.After(c2) || info.CreatedAt.Before(c1) { return errors.Errorf("unexpected created at time %s, expected between %s and %s", info.CreatedAt, c1, c2) } - if info.UpdatedAt.After(u2) || info.UpdatedAt.Before(u1) { + // FIXME: broken on windows: unexpected updated at time 2017-11-14 13:43:22.178013 -0800 PST, + // expected between 2017-11-14 13:43:22.1790195 -0800 PST m=+1.022137300 and + // 2017-11-14 13:43:22.1790195 -0800 PST m=+1.022137300 + if runtime.GOOS != "windows" && (info.UpdatedAt.After(u2) || info.UpdatedAt.Before(u1)) { return errors.Errorf("unexpected updated at time %s, expected between %s and %s", info.UpdatedAt, u1, u2) } diff --git a/fs/diff_test.go b/fs/diff_test.go index d9c6d34e2..f6b4590d7 100644 --- a/fs/diff_test.go +++ b/fs/diff_test.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "testing" "time" @@ -20,7 +21,14 @@ import ( // - symlink test // - hardlink test +func skipDiffTestOnWindows(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("diff implementation is incomplete on windows") + } +} + func TestSimpleDiff(t *testing.T) { + skipDiffTestOnWindows(t) l1 := fstest.Apply( fstest.CreateDir("/etc", 0755), fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644), @@ -49,6 +57,7 @@ func TestSimpleDiff(t *testing.T) { } func TestDirectoryReplace(t *testing.T) { + skipDiffTestOnWindows(t) l1 := fstest.Apply( fstest.CreateDir("/dir1", 0755), fstest.CreateFile("/dir1/f1", []byte("#####"), 0644), @@ -109,6 +118,7 @@ func TestFileReplace(t *testing.T) { } func TestParentDirectoryPermission(t *testing.T) { + skipDiffTestOnWindows(t) l1 := fstest.Apply( fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/dir2", 0751), @@ -134,6 +144,7 @@ func TestParentDirectoryPermission(t *testing.T) { } } func TestUpdateWithSameTime(t *testing.T) { + skipDiffTestOnWindows(t) tt := time.Now().Truncate(time.Second) t1 := tt.Add(5 * time.Nanosecond) t2 := tt.Add(6 * time.Nanosecond) diff --git a/metadata/snapshot_test.go b/metadata/snapshot_test.go index ad4a5d8b5..050063791 100644 --- a/metadata/snapshot_test.go +++ b/metadata/snapshot_test.go @@ -4,6 +4,7 @@ import ( "context" "os" "path/filepath" + "runtime" "testing" "github.com/boltdb/bolt" @@ -39,6 +40,9 @@ func newTestSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, } func TestMetadata(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("snapshotter not implemented on windows") + } // Snapshot tests require mounting, still requires root testutil.RequiresRoot(t) testsuite.SnapshotterSuite(t, "Metadata", newTestSnapshotter) diff --git a/snapshot/naive/naive_test.go b/snapshot/naive/naive_test.go index f8111f5d0..0da3e848d 100644 --- a/snapshot/naive/naive_test.go +++ b/snapshot/naive/naive_test.go @@ -2,6 +2,7 @@ package naive import ( "context" + "runtime" "testing" "github.com/containerd/containerd/snapshot" @@ -19,6 +20,9 @@ func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, fun } func TestNaive(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("snapshotter not implemented on windows") + } testutil.RequiresRoot(t) testsuite.SnapshotterSuite(t, "Naive", newSnapshotter) }