!44 isula-build:imporve daemon push and pull unit test
From: @caihaomin Reviewed-by: @jingxiaolu Signed-off-by: @jingxiaolu
This commit is contained in:
commit
5b0edc17e1
@ -1 +1 @@
|
||||
0.9.4-8
|
||||
0.9.4-9
|
||||
|
||||
@ -1 +1 @@
|
||||
3a1cd37f4440574b44b5c1c85f7e4172209237e8
|
||||
28cc46e7793fb6bb3a97f0e969e3dc914faa3b3e
|
||||
|
||||
@ -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<caihaomin@huawei.com> - 0.9.4-9
|
||||
- Imporve daemon push and pull unit test
|
||||
|
||||
* Fir Nov 27 2020 lixiang <lixiang172@huawei.com> - 0.9.4-8
|
||||
- Add compile flag ftrapv and enable debuginfo
|
||||
|
||||
|
||||
138
patch/0071-imporve-daemon-push-and-pull-unit-test.patch
Normal file
138
patch/0071-imporve-daemon-push-and-pull-unit-test.patch
Normal file
@ -0,0 +1,138 @@
|
||||
From fa98d546f9ced2552c6df203cb049c6570b202b8 Mon Sep 17 00:00:00 2001
|
||||
From: xingweizheng 00591739 <xingweizheng@huawei.com>
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user