diff --git a/VERSION-openeuler b/VERSION-openeuler index 9e72237..4ff14f9 100644 --- a/VERSION-openeuler +++ b/VERSION-openeuler @@ -1 +1 @@ -0.9.4-8 +0.9.4-9 diff --git a/git-commit b/git-commit index 6859fe0..922607b 100644 --- a/git-commit +++ b/git-commit @@ -1 +1 @@ -3a1cd37f4440574b44b5c1c85f7e4172209237e8 +28cc46e7793fb6bb3a97f0e969e3dc914faa3b3e diff --git a/isula-build.spec b/isula-build.spec index 6dad85d..f9fa02e 100644 --- a/isula-build.spec +++ b/isula-build.spec @@ -2,7 +2,7 @@ Name: isula-build Version: 0.9.4 -Release: 8 +Release: 9 Summary: A tool to build container images License: Mulan PSL V2 URL: https://gitee.com/openeuler/isula-build @@ -85,6 +85,9 @@ fi /usr/share/bash-completion/completions/isula-build %changelog +* Fir Nov 27 2020 caihaomin - 0.9.4-9 +- Imporve daemon push and pull unit test + * Fir Nov 27 2020 lixiang - 0.9.4-8 - Add compile flag ftrapv and enable debuginfo diff --git a/patch/0071-imporve-daemon-push-and-pull-unit-test.patch b/patch/0071-imporve-daemon-push-and-pull-unit-test.patch new file mode 100644 index 0000000..f0721d7 --- /dev/null +++ b/patch/0071-imporve-daemon-push-and-pull-unit-test.patch @@ -0,0 +1,138 @@ +From fa98d546f9ced2552c6df203cb049c6570b202b8 Mon Sep 17 00:00:00 2001 +From: xingweizheng 00591739 +Date: Thu, 26 Nov 2020 16:19:43 +0800 +Subject: [PATCH 2/5] imporve daemon push and pull unit test + +--- + daemon/pull_test.go | 18 ++++++++++++++ + daemon/push_test.go | 60 +++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 71 insertions(+), 7 deletions(-) + +diff --git a/daemon/pull_test.go b/daemon/pull_test.go +index 7a77c44c..43c011be 100644 +--- a/daemon/pull_test.go ++++ b/daemon/pull_test.go +@@ -21,6 +21,7 @@ import ( + + "github.com/containers/storage/pkg/reexec" + "github.com/containers/storage/pkg/stringid" ++ "golang.org/x/sync/errgroup" + "golang.org/x/sys/unix" + "google.golang.org/grpc" + "gotest.tools/assert" +@@ -28,6 +29,7 @@ import ( + + constant "isula.org/isula-build" + pb "isula.org/isula-build/api/services" ++ "isula.org/isula-build/pkg/logger" + "isula.org/isula-build/store" + ) + +@@ -100,3 +102,19 @@ func TestPull(t *testing.T) { + assert.ErrorContains(t, err, "failed to get the image") + tmpClean(d) + } ++ ++func TestPullHandler(t *testing.T) { ++ stream := &controlPullServer{} ++ cliLogger := logger.NewCliLogger(constant.CliLogBufferLen) ++ ++ ctx := context.TODO() ++ eg, _ := errgroup.WithContext(ctx) ++ eg.Go(pullMessageHandler(stream, cliLogger)) ++ eg.Go(func() error { ++ cliLogger.Print("Pull Response") ++ cliLogger.CloseContent() ++ return nil ++ }) ++ ++ eg.Wait() ++} +diff --git a/daemon/push_test.go b/daemon/push_test.go +index 3fc363ec..97040b86 100644 +--- a/daemon/push_test.go ++++ b/daemon/push_test.go +@@ -17,13 +17,16 @@ import ( + "context" + "testing" + ++ "github.com/containers/storage" + "github.com/containers/storage/pkg/reexec" + "github.com/containers/storage/pkg/stringid" ++ "golang.org/x/sync/errgroup" + "google.golang.org/grpc" + "gotest.tools/assert" + + constant "isula.org/isula-build" + pb "isula.org/isula-build/api/services" ++ "isula.org/isula-build/pkg/logger" + ) + + type controlPushServer struct { +@@ -45,13 +48,56 @@ func init() { + + func TestPush(t *testing.T) { + d := prepare(t) +- pushID := stringid.GenerateNonCryptoID()[:constant.DefaultIDLen] +- req := &pb.PushRequest{ +- PushID: pushID, +- ImageName: "255.255.255.255/no-repository/no-name", +- } + stream := &controlPushServer{} +- err := d.Daemon.backend.Push(req, stream) +- assert.ErrorContains(t, err, "error: locating image") ++ ++ testCases := []struct { ++ testName string ++ pushRequest *pb.PushRequest ++ }{ ++ { ++ testName: "localNotExist", ++ pushRequest: &pb.PushRequest{ ++ PushID: stringid.GenerateNonCryptoID()[:constant.DefaultIDLen], ++ ImageName: "255.255.255.255/no-repository/no-name", ++ }, ++ }, ++ { ++ testName: "manifestNotExist", ++ pushRequest: &pb.PushRequest{ ++ PushID: stringid.GenerateNonCryptoID()[:constant.DefaultIDLen], ++ ImageName: "127.0.0.1/no-repository/no-name:latest", ++ }, ++ }, ++ } ++ ++ options := &storage.ImageOptions{} ++ d.Daemon.localStore.CreateImage(stringid.GenerateRandomID(), []string{"127.0.0.1/no-repository/no-name:latest"}, "", "", options) ++ ++ for _, tc := range testCases { ++ err := d.Daemon.backend.Push(tc.pushRequest, stream) ++ if tc.testName == "localNotExist" { ++ assert.ErrorContains(t, err, "error: locating image") ++ } ++ if tc.testName == "manifestNotExist" { ++ assert.ErrorContains(t, err, "file does not exist") ++ } ++ } ++ + tmpClean(d) + } ++ ++func TestPushHandler(t *testing.T) { ++ stream := &controlPushServer{} ++ cliLogger := logger.NewCliLogger(constant.CliLogBufferLen) ++ ++ ctx := context.TODO() ++ eg, _ := errgroup.WithContext(ctx) ++ eg.Go(pushMessageHandler(stream, cliLogger)) ++ eg.Go(func() error { ++ cliLogger.Print("Push Response") ++ cliLogger.CloseContent() ++ return nil ++ }) ++ ++ eg.Wait() ++} +-- +2.27.0 + diff --git a/series.conf b/series.conf index ee2a148..9a0e683 100644 --- a/series.conf +++ b/series.conf @@ -8,3 +8,4 @@ patch/0067-bugfix-fix-unsuitable-filemode-for-isula-build-er.patch patch/0068-isula-build-support-build-Dockerfile-only-have-FROM-.patch patch/0069-isula-build-mask-proc-pin_memory.patch patch/0070-hack-add-compile-flag-ftrapv.patch +patch/0071-imporve-daemon-push-and-pull-unit-test.patch