Projects
openEuler:Mainline
isula-build
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 204
View file
_service:tar_scm_kernel_repo:isula-build.spec
Changed
@@ -2,7 +2,7 @@ Name: isula-build Version: 0.9.6 -Release: 15 +Release: 16 Summary: A tool to build container images License: Mulan PSL V2 URL: https://gitee.com/openeuler/isula-build @@ -85,6 +85,12 @@ /usr/share/bash-completion/completions/isula-build %changelog +* Thu Dec 22 2022 daisicheng <daisicheng@huawei.com> - 0.9.6-16 +- Type:bugfix +- CVE:NA +- SUG:restart +- DESC:add some DT tests + * Wed Dec 07 2022 jingxiaolu <lujingxiao@huawei.com> - 0.9.6-15 - Type:bugfix - CVE:NA
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0129-add-import_test.go-for-import.go-and-add-TestCleanCo.patch
Added
@@ -0,0 +1,248 @@ +From 374c6ece3d911d8b5bc72f4e04c4483061624e5a Mon Sep 17 00:00:00 2001 +From: daisicheng <daisicheng@huawei.com> +Date: Thu, 20 Oct 2022 14:51:49 +0800 +Subject: [PATCH] add import_test.go for import.go and add TestCleanContainers + function for store.go + +--- + cmd/cli/import_test.go | 134 +++++++++++++++++++++++++++++++++++++++++ + cmd/cli/mock.go | 19 +++++- + store/store_test.go | 27 +++++++++ + 3 files changed, 178 insertions(+), 2 deletions(-) + create mode 100644 cmd/cli/import_test.go + +diff --git a/cmd/cli/import_test.go b/cmd/cli/import_test.go +new file mode 100644 +index 0000000..057bf17 +--- /dev/null ++++ b/cmd/cli/import_test.go +@@ -0,0 +1,134 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: daisicheng ++// Create: 2022-10-20 ++// Description: This file is for image import test. ++ ++// Description: This file is is used for testing import command. ++package main ++ ++import ( ++ "context" ++ "io/ioutil" ++ "os" ++ "path/filepath" ++ "testing" ++ ++ "gotest.tools/v3/assert" ++ "gotest.tools/v3/fs" ++ ++ constant "isula.org/isula-build" ++) ++ ++const ExceededImportFileSize = 2048 * 1024 * 1024 ++ ++func TestImportCommand(t *testing.T) { ++ tmpFile := fs.NewFile(t, t.Name()) ++ exceededFile := fs.NewFile(t, t.Name()) ++ err := ioutil.WriteFile(tmpFile.Path(), []byte("This is test file"), constant.DefaultSharedFileMode) ++ assert.NilError(t, err) ++ err = ioutil.WriteFile(exceededFile.Path(), []byte("This is exceeded test file"), constant.DefaultSharedFileMode) ++ assert.NilError(t, err) ++ err = os.Truncate(exceededFile.Path(), ExceededImportFileSize) ++ assert.NilError(t, err) ++ defer tmpFile.Remove() ++ defer exceededFile.Remove() ++ ++ type testcase struct { ++ name string ++ errString string ++ args []string ++ wantErr bool ++ } ++ var testcases = []testcase{ ++ { ++ name: "TC1 - abnormal case with no args", ++ errString: "requires at least one argument", ++ wantErr: true, ++ }, ++ { ++ name: "TC2 - abnormal case with exceeded limit input", ++ args: []string{exceededFile.Path()}, ++ errString: "exceeds limit 1073741824", ++ wantErr: true, ++ }, ++ { ++ name: "TC3 - normal case", ++ args: []string{tmpFile.Path()}, ++ errString: "isula_build.sock", ++ wantErr: true, ++ }, ++ } ++ ++ for _, tc := range testcases { ++ t.Run(tc.name, func(t *testing.T) { ++ importCmd := NewImportCmd() ++ err = importCommand(importCmd, tc.args) ++ if tc.wantErr { ++ assert.ErrorContains(t, err, tc.errString) ++ } ++ if !tc.wantErr { ++ assert.NilError(t, err) ++ } ++ }) ++ } ++} ++ ++func TestRunImport(t *testing.T) { ++ ctx := context.Background() ++ mockImport := newMockDaemon() ++ cli := newMockClient(&mockGrpcClient{importFunc: mockImport.importImage}) ++ fileEmpty := "empty.tar" ++ fileNormal := "test.tar" ++ exceededFile := fs.NewFile(t, t.Name()) ++ err := ioutil.WriteFile(exceededFile.Path(), []byte("This is exceeded test file"), constant.DefaultSharedFileMode) ++ assert.NilError(t, err) ++ err = os.Truncate(exceededFile.Path(), ExceededImportFileSize) ++ assert.NilError(t, err) ++ ctxDir := fs.NewDir(t, "import", fs.WithFile(fileEmpty, ""), fs.WithFile(fileNormal, "test")) ++ defer ctxDir.Remove() ++ defer exceededFile.Remove() ++ ++ type testcase struct { ++ name string ++ source string ++ wantErr bool ++ errString string ++ } ++ var testcases = []testcase{ ++ { ++ name: "TC1 - abnormal case with empty file", ++ source: filepath.Join(ctxDir.Path(), fileEmpty), ++ wantErr: true, ++ errString: "empty", ++ }, ++ { ++ name: "TC2 - abnormal case with exceeded limit file", ++ source: exceededFile.Path(), ++ wantErr: true, ++ errString: "limit", ++ }, ++ { ++ name: "TC3 - normal case", ++ source: filepath.Join(ctxDir.Path(), fileNormal), ++ wantErr: false, ++ }, ++ } ++ for _, tc := range testcases { ++ t.Run(tc.name, func(t *testing.T) { ++ importOpts.source = tc.source ++ err := runImport(ctx, &cli) ++ assert.Equal(t, err != nil, tc.wantErr, "Failed at [%s], err: %v", tc.name, err) ++ if err != nil { ++ assert.ErrorContains(t, err, tc.errString) ++ } ++ }) ++ } ++} +diff --git a/cmd/cli/mock.go b/cmd/cli/mock.go +index 23a8a03..d201fe0 100644 +--- a/cmd/cli/mock.go ++++ b/cmd/cli/mock.go +@@ -17,12 +17,14 @@ import ( + "context" + "io" + "os" ++ "path/filepath" + "testing" + + "github.com/gogo/protobuf/types" + "github.com/pkg/errors" + "google.golang.org/grpc" + ++ constant "isula.org/isula-build" + pb "isula.org/isula-build/api/services" + ) + +@@ -261,7 +263,7 @@ func (icli *mockImportClient) Recv() (*pb.ImportResponse, error) { + resp := &pb.ImportResponse{ + Log: "Import success with image id: " + imageID, + } +- return resp, nil ++ return resp, io.EOF + } + + func (icli *mockImportClient) Send(*pb.ImportRequest) error { +@@ -313,7 +315,20 @@ func (cli *mockClient) Close() error { + return nil + } + +-func (f *mockDaemon) importImage(_ context.Context, opts ...grpc.CallOption) (pb.Control_ImportClient, error) { ++func (f *mockDaemon) importImage(_ context.Context, in *pb.ImportRequest, opts ...grpc.CallOption) (pb.Control_ImportClient, error) { ++ f.importReq = in ++ source := f.importReq.Source ++ file, err := os.Stat(filepath.Clean(source)) ++ if err != nil { ++ return &mockImportClient{}, err ++ } ++ if file.Size() == 0 { ++ return &mockImportClient{}, errors.Errorf("file %s is empty", file.Name()) ++ } ++ if file.Size() > constant.MaxImportFileSize { ++ return &mockImportClient{}, errors.Errorf("file %s size is: %d, exceeds limit", file.Name(), file.Size()) ++ }
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0130-add-copy-related-unit-tests-in-package-common.patch
Added
@@ -0,0 +1,51 @@ +From bf4d9f5638ab63d5272ccfb2689cdafc7b0adaf5 Mon Sep 17 00:00:00 2001 +From: jingxiaolu <lujingxiao@huawei.com> +Date: Mon, 31 Oct 2022 19:01:17 +0800 +Subject: [PATCH] add copy related unit tests in package common + +Signed-off-by: jingxiaolu <lujingxiao@huawei.com> +--- + util/common_test.go | 27 +++++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + +diff --git a/util/common_test.go b/util/common_test.go +index 7d2444a..263eae2 100644 +--- a/util/common_test.go ++++ b/util/common_test.go +@@ -21,6 +21,33 @@ import ( + "gotest.tools/v3/fs" + ) + ++func TestCopyMapStringString(t *testing.T) { ++ src := map[string]string{"isula": "build"} ++ dst := CopyMapStringString(src) ++ ++ assert.Equal(t, dst != nil, true) ++ assert.Equal(t, dst == nil, false) ++ assert.Equal(t, dst["isula"] == "build", true) ++} ++ ++func TestCopyStrings(t *testing.T) { ++ src := []string{"isula", "build"} ++ dst := CopyStrings(src) ++ ++ assert.Equal(t, dst != nil, true) ++ const dstLen = 2 ++ assert.Equal(t, len(dst) == dstLen, true) ++} ++ ++func TestCopyStringsWithoutSpecificElem(t *testing.T) { ++ src := []string{"isula", "build", "gogogo"} ++ dst := CopyStringsWithoutSpecificElem(src, "go") ++ ++ assert.Equal(t, dst != nil, true) ++ const dstLen = 2 ++ assert.Equal(t, len(dst) == dstLen, true) ++} ++ + func TestCheckFileInfoAndSize(t *testing.T) { + content := ` + ARG testArg +-- +2.33.0 +
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0131-improve-some-error-coverage-of-unit-tests-in-import.patch
Added
@@ -0,0 +1,93 @@ +From 0c1f841e13e4cb70ff07e18ddfb53e8927edbe95 Mon Sep 17 00:00:00 2001 +From: daisicheng <daisicheng@huawei.com> +Date: Tue, 1 Nov 2022 17:11:19 +0800 +Subject: [PATCH] improve some error coverage of unit tests in import_test and + store_test + +--- + cmd/cli/import_test.go | 9 ++++----- + store/store_test.go | 29 ++++++++++++++++++++++++++++- + 2 files changed, 32 insertions(+), 6 deletions(-) + +diff --git a/cmd/cli/import_test.go b/cmd/cli/import_test.go +index 057bf17..82983b0 100644 +--- a/cmd/cli/import_test.go ++++ b/cmd/cli/import_test.go +@@ -85,14 +85,13 @@ func TestRunImport(t *testing.T) { + ctx := context.Background() + mockImport := newMockDaemon() + cli := newMockClient(&mockGrpcClient{importFunc: mockImport.importImage}) +- fileEmpty := "empty.tar" + fileNormal := "test.tar" + exceededFile := fs.NewFile(t, t.Name()) + err := ioutil.WriteFile(exceededFile.Path(), []byte("This is exceeded test file"), constant.DefaultSharedFileMode) + assert.NilError(t, err) + err = os.Truncate(exceededFile.Path(), ExceededImportFileSize) + assert.NilError(t, err) +- ctxDir := fs.NewDir(t, "import", fs.WithFile(fileEmpty, ""), fs.WithFile(fileNormal, "test")) ++ ctxDir := fs.NewDir(t, "import", fs.WithFile(fileNormal, "test")) + defer ctxDir.Remove() + defer exceededFile.Remove() + +@@ -104,10 +103,10 @@ func TestRunImport(t *testing.T) { + } + var testcases = []testcase{ + { +- name: "TC1 - abnormal case with empty file", +- source: filepath.Join(ctxDir.Path(), fileEmpty), ++ name: "TC1 - abnormal case with relative path", ++ source: filepath.Join("./", fileNormal), + wantErr: true, +- errString: "empty", ++ errString: "no such file or directory", + }, + { + name: "TC2 - abnormal case with exceeded limit file", +diff --git a/store/store_test.go b/store/store_test.go +index 77a9353..360e4dd 100644 +--- a/store/store_test.go ++++ b/store/store_test.go +@@ -67,12 +67,39 @@ func TestCleanContainers(t *testing.T) { + + s, err := GetStore() + assert.NilError(t, err) +- s.CreateContainer("", []string{""}, "", "", "", nil) ++ s.CreateContainer("", []string{""}, "", "TC1", "", nil) + s.CleanContainers() + containers, _ := s.Containers() + if len(containers) > 0 { + t.Errorf("Failed to clean containers") + } ++ s.CreateContainer("", []string{""}, "", "TC2", "", nil) ++ err = os.RemoveAll(filepath.Join(storeOpts.DataRoot, "overlay-layers")) ++ assert.NilError(t, err) ++ s.CleanContainers() ++ ++ defer func() { ++ unix.Unmount(filepath.Join(storeOpts.DataRoot, "overlay"), 0) ++ unix.Unmount(filepath.Join(storeOpts.RunRoot, "overlay"), 0) ++ os.RemoveAll(dataDir) ++ os.RemoveAll(runDir) ++ }() ++} ++ ++func TestCleanContainer(t *testing.T) { ++ dataDir := "/tmp/lib" ++ runDir := "/tmp/run" ++ storeOpts.DataRoot = filepath.Join(dataDir, "containers/storage") ++ storeOpts.RunRoot = filepath.Join(runDir, "containers/storage") ++ ++ s, err := GetStore() ++ assert.NilError(t, err) ++ s.CreateContainer("", []string{""}, "", "TC1", "", nil) ++ err = s.CleanContainer("TC1") ++ assert.NilError(t, err) ++ err = s.CleanContainer("TC2") ++ assert.ErrorContains(t, err, "not a container") ++ + defer func() { + unix.Unmount(filepath.Join(storeOpts.DataRoot, "overlay"), 0) + unix.Unmount(filepath.Join(storeOpts.RunRoot, "overlay"), 0) +-- +2.33.0 +
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0132-add-login_test-logout_test-remove_test-and-import_te.patch
Added
@@ -0,0 +1,572 @@ +From 11fbc841b5af5ff4dd5ac228c033a49cac742aad Mon Sep 17 00:00:00 2001 +From: daisicheng <daisicheng@huawei.com> +Date: Fri, 25 Nov 2022 17:40:33 +0800 +Subject: [PATCH] add login_test, logout_test, remove_test and import_test in + daemon + +--- + cmd/cli/build_test.go | 40 ++++++++++++++++ + daemon/import_test.go | 87 +++++++++++++++++++++++++++++++++++ + daemon/login_test.go | 103 ++++++++++++++++++++++++++++++++++++++++++ + daemon/logout_test.go | 75 ++++++++++++++++++++++++++++++ + daemon/pull_test.go | 7 ++- + daemon/remove_test.go | 101 +++++++++++++++++++++++++++++++++++++++++ + daemon/tag_test.go | 73 ++++++++++++++++++++++++++++++ + 7 files changed, 485 insertions(+), 1 deletion(-) + create mode 100644 daemon/import_test.go + create mode 100644 daemon/login_test.go + create mode 100644 daemon/logout_test.go + create mode 100644 daemon/remove_test.go + create mode 100644 daemon/tag_test.go + +diff --git a/cmd/cli/build_test.go b/cmd/cli/build_test.go +index d446801..41cabbe 100644 +--- a/cmd/cli/build_test.go ++++ b/cmd/cli/build_test.go +@@ -29,6 +29,46 @@ import ( + "isula.org/isula-build/util" + ) + ++func TestBuildCommand(t *testing.T) { ++ dockerfile := `` ++ filename := "Dockerfile" ++ tmpDir := fs.NewDir(t, t.Name(), fs.WithFile(filename, dockerfile)) ++ defer tmpDir.Remove() ++ ++ type testcase struct { ++ name string ++ file string ++ args []string ++ wanterr bool ++ errString string ++ } ++ var testcases = []testcase{ ++ { ++ name: "TC1 - normal case", ++ file: tmpDir.Path(), ++ args: []string{tmpDir.Path()}, ++ wanterr: true, ++ errString: "isula_build.sock", ++ }, ++ } ++ ++ for _, tc := range testcases { ++ t.Run(tc.name, func(t *testing.T) { ++ buildCmd := NewBuildCmd() ++ err := buildCmd.Execute() ++ assert.Equal(t, err != nil, true) ++ ++ err = buildCommand(buildCmd, tc.args) ++ if tc.wanterr { ++ assert.ErrorContains(t, err, tc.errString) ++ } ++ if !tc.wanterr { ++ assert.NilError(t, err) ++ } ++ }) ++ } ++} ++ + func TestRunBuildWithLocalDockerfile(t *testing.T) { + dockerfile := ` + FROM alpine:latest +diff --git a/daemon/import_test.go b/daemon/import_test.go +new file mode 100644 +index 0000000..1a24eb4 +--- /dev/null ++++ b/daemon/import_test.go +@@ -0,0 +1,87 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: daisicheng ++// Create: 2022-12-01 ++// Description: This file tests import interface. ++ ++package daemon ++ ++import ( ++ "context" ++ "io/ioutil" ++ "testing" ++ ++ "github.com/pkg/errors" ++ "google.golang.org/grpc" ++ "gotest.tools/v3/assert" ++ "gotest.tools/v3/fs" ++ ++ constant "isula.org/isula-build" ++ pb "isula.org/isula-build/api/services" ++ "isula.org/isula-build/util" ++) ++ ++type controlImportServer struct { ++ grpc.ServerStream ++} ++ ++func (c *controlImportServer) Send(response *pb.ImportResponse) error { ++ if response.Log == "error" { ++ return errors.New("error happened") ++ } ++ return nil ++} ++ ++func (c *controlImportServer) Context() context.Context { ++ return context.Background() ++} ++ ++func TestImport(t *testing.T) { ++ d := prepare(t) ++ defer tmpClean(d) ++ ++ tmpFile := fs.NewFile(t, t.Name()) ++ defer tmpFile.Remove() ++ err := ioutil.WriteFile(tmpFile.Path(), []byte("This is test file"), constant.DefaultSharedFileMode) ++ assert.NilError(t, err) ++ importID := util.GenerateNonCryptoID()[:constant.DefaultIDLen] ++ ++ testcases := []struct { ++ name string ++ req *pb.ImportRequest ++ wantErr bool ++ errString string ++ }{ ++ { ++ name: "TC1 - normal case", ++ req: &pb.ImportRequest{ ++ ImportID: importID, ++ Source: tmpFile.Path(), ++ Reference: "test:image", ++ }, ++ wantErr: true, ++ errString: "Error processing tar file", ++ }, ++ } ++ ++ for _, tc := range testcases { ++ t.Run(tc.name, func(t *testing.T) { ++ stream := &controlImportServer{} ++ err := d.Daemon.backend.Import(tc.req, stream) ++ if tc.wantErr == true { ++ assert.ErrorContains(t, err, tc.errString) ++ } ++ if tc.wantErr == false { ++ assert.NilError(t, err) ++ } ++ }) ++ } ++ ++} +diff --git a/daemon/login_test.go b/daemon/login_test.go +new file mode 100644 +index 0000000..b8ae002 +--- /dev/null ++++ b/daemon/login_test.go +@@ -0,0 +1,103 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: daisicheng ++// Create: 2022-12-01 ++// Description: This file tests login interface. ++ ++package daemon ++ ++import ( ++ "context" ++ "crypto/sha512" ++ "testing" ++ ++ "gotest.tools/v3/assert" ++ ++ pb "isula.org/isula-build/api/services" ++ "isula.org/isula-build/util" ++) ++ ++func TestLogin(t *testing.T) { ++ d := prepare(t)
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0133-cmd-daemon-add-base-test-for-runDaemon-and-before-fu.patch
Added
@@ -0,0 +1,73 @@ +From 5edff01f9bdc001980a1a5423ba4b37a1adce756 Mon Sep 17 00:00:00 2001 +From: xingweizheng <xingweizheng@huawei.com> +Date: Fri, 9 Dec 2022 11:03:12 +0800 +Subject: [PATCH] cmd/daemon: add base test for runDaemon and before function + +--- + cmd/daemon/before_test.go | 8 +++++++- + cmd/daemon/main_test.go | 27 +++++++++++++++++++++++++++ + 2 files changed, 34 insertions(+), 1 deletion(-) + create mode 100644 cmd/daemon/main_test.go + +diff --git a/cmd/daemon/before_test.go b/cmd/daemon/before_test.go +index 19b1bc0..d2a8f41 100644 +--- a/cmd/daemon/before_test.go ++++ b/cmd/daemon/before_test.go +@@ -9,7 +9,7 @@ + // See the Mulan PSL v2 for more details. + // Author: Xiang Li + // Create: 2020-01-20 +-// Description: This file is used for isula-build daemon testing ++// Description: This file is used for isula-build cmd/daemon testing + + package main + +@@ -27,6 +27,12 @@ import ( + "isula.org/isula-build/store" + ) + ++func TestBefor(t *testing.T) { ++ cmd := newDaemonCommand() ++ err := before(cmd) ++ assert.NilError(t, err) ++} ++ + func TestSetupWorkingDirectories(t *testing.T) { + var testDir *fs.Dir + var testcases = []struct { +diff --git a/cmd/daemon/main_test.go b/cmd/daemon/main_test.go +new file mode 100644 +index 0000000..85e7b94 +--- /dev/null ++++ b/cmd/daemon/main_test.go +@@ -0,0 +1,27 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: Weizheng Xing ++// Create: 2022-12-08 ++// Description: This file is used for isula-build cmd/daemon testing ++ ++package main ++ ++import ( ++ "testing" ++ ++ "gotest.tools/v3/assert" ++) ++ ++func TestRunDaemon(t *testing.T) { ++ cmd := newDaemonCommand() ++ daemonOpts.Group = "none" ++ err := runDaemon(cmd, []string{}) ++ assert.ErrorContains(t, err, "create new GRPC socket failed") ++} +-- +2.33.0 +
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0134-add-dt-for-interface-manifest-health-status-in-daemo.patch
Added
@@ -0,0 +1,322 @@ +From 1f5593086dea78c3300b23877db5ebcc7e272127 Mon Sep 17 00:00:00 2001 +From: daisicheng <daisicheng@huawei.com> +Date: Fri, 16 Dec 2022 17:42:56 +0800 +Subject: [PATCH] add dt for interface manifest, health, status in daemon and + main in cli + +--- + cmd/cli/main_test.go | 26 +++++++ + daemon/heath_test.go | 28 +++++++ + daemon/manifest_test.go | 169 ++++++++++++++++++++++++++++++++++++++++ + daemon/status_test.go | 55 +++++++++++++ + 4 files changed, 278 insertions(+) + create mode 100644 cmd/cli/main_test.go + create mode 100644 daemon/heath_test.go + create mode 100644 daemon/manifest_test.go + create mode 100644 daemon/status_test.go + +diff --git a/cmd/cli/main_test.go b/cmd/cli/main_test.go +new file mode 100644 +index 0000000..145d396 +--- /dev/null ++++ b/cmd/cli/main_test.go +@@ -0,0 +1,26 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: daisicheng ++// Create: 2022-12-19 ++// Description: This file is used for isula-build cmd/cli testing ++ ++package main ++ ++import ( ++ "testing" ++ ++ "gotest.tools/v3/assert" ++) ++ ++func TestRuncli(t *testing.T) { ++ cmd := newCliCommand() ++ err := before(cmd) ++ assert.NilError(t, err) ++} +diff --git a/daemon/heath_test.go b/daemon/heath_test.go +new file mode 100644 +index 0000000..c9c6af1 +--- /dev/null ++++ b/daemon/heath_test.go +@@ -0,0 +1,28 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: sicheng Dai ++// Create: 2020-01-20 ++// Description: This is test file for health ++ ++package daemon ++ ++import ( ++ "context" ++ "testing" ++ ++ gogotypes "github.com/gogo/protobuf/types" ++ "gotest.tools/v3/assert" ++) ++ ++func TestHealthCheck(t *testing.T) { ++ backend := Backend{} ++ _, err := backend.HealthCheck(context.Background(), &gogotypes.Empty{}) ++ assert.NilError(t, err) ++} +diff --git a/daemon/manifest_test.go b/daemon/manifest_test.go +new file mode 100644 +index 0000000..9c54045 +--- /dev/null ++++ b/daemon/manifest_test.go +@@ -0,0 +1,169 @@ ++// Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. ++// isula-build licensed under the Mulan PSL v2. ++// You can use this software according to the terms and conditions of the Mulan PSL v2. ++// You may obtain a copy of Mulan PSL v2 at: ++// http://license.coscl.org.cn/MulanPSL2 ++// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++// PURPOSE. ++// See the Mulan PSL v2 for more details. ++// Author: daisicheng ++// Create: 2022-12-15 ++// Description: This file tests manifest interface. ++ ++package daemon ++ ++import ( ++ "context" ++ "fmt" ++ "testing" ++ ++ "github.com/containers/storage" ++ "github.com/containers/storage/pkg/stringid" ++ "github.com/pkg/errors" ++ "golang.org/x/sync/errgroup" ++ "google.golang.org/grpc" ++ "gotest.tools/v3/assert" ++ ++ constant "isula.org/isula-build" ++ pb "isula.org/isula-build/api/services" ++ "isula.org/isula-build/pkg/logger" ++) ++ ++type controlManifestPushServer struct { ++ grpc.ServerStream ++} ++ ++func (c *controlManifestPushServer) Context() context.Context { ++ return context.Background() ++} ++ ++func (c *controlManifestPushServer) Send(response *pb.ManifestPushResponse) error { ++ if response.Result == "error" { ++ return errors.New("error happened") ++ } ++ return nil ++} ++ ++func TestManifestCreate(t *testing.T) { ++ d := prepare(t) ++ defer tmpClean(d) ++ ++ ctx := context.TODO() ++ req := &pb.ManifestCreateRequest{ManifestList: "openeuler", ++ Manifests: []string{"openeuler_arrch64"}} ++ _, err := d.Daemon.backend.ManifestCreate(ctx, req) ++ assert.ErrorContains(t, err, "enable experimental to use manifest feature") ++ ++ d.Daemon.opts.Experimental = true ++ req = &pb.ManifestCreateRequest{ManifestList: "euleros", ++ Manifests: []string{"euleros_x86"}} ++ _, err = d.Daemon.backend.ManifestCreate(ctx, req) ++ assert.ErrorContains(t, err, "failed to get the image") ++ ++} ++ ++func TestManifestAnnotate(t *testing.T) { ++ d := prepare(t) ++ defer tmpClean(d) ++ ++ ctx := context.TODO() ++ req := &pb.ManifestAnnotateRequest{ManifestList: "openeuler", ++ Manifest: "openeuler_arrch64"} ++ _, err := d.Daemon.backend.ManifestAnnotate(ctx, req) ++ assert.ErrorContains(t, err, "enable experimental to use manifest feature") ++ ++ d.Daemon.opts.Experimental = true ++ req = &pb.ManifestAnnotateRequest{ManifestList: "euleros", ++ Manifest: "euleros_x86"} ++ _, err = d.Daemon.backend.ManifestAnnotate(ctx, req) ++ assert.ErrorContains(t, err, "not found in local store") ++ ++ options := &storage.ImageOptions{} ++ _, err = d.Daemon.localStore.CreateImage(stringid.GenerateRandomID(), []string{"image"}, "", "", options) ++ if err != nil { ++ t.Fatalf("create image with error: %v", err) ++ } ++ req = &pb.ManifestAnnotateRequest{ManifestList: "image", ++ Manifest: "euleros_x86"} ++ _, err = d.Daemon.backend.ManifestAnnotate(ctx, req) ++ fmt.Println(err) ++ assert.ErrorContains(t, err, "file does not exist") ++} ++ ++func TestManifestInspect(t *testing.T) { ++ d := prepare(t) ++ defer tmpClean(d) ++ ++ ctx := context.TODO() ++ _, err := d.Daemon.backend.ManifestInspect(ctx, &pb.ManifestInspectRequest{ManifestList: "openeuler"}) ++ assert.ErrorContains(t, err, "enable experimental to use manifest feature") ++ ++ d.Daemon.opts.Experimental = true ++ _, err = d.Daemon.backend.ManifestInspect(ctx, &pb.ManifestInspectRequest{ManifestList: "euleros"}) ++ assert.ErrorContains(t, err, "not found in local store") ++ ++ options := &storage.ImageOptions{} ++ _, err = d.Daemon.localStore.CreateImage(stringid.GenerateRandomID(), []string{"image"}, "", "", options) ++ if err != nil { ++ t.Fatalf("create image with error: %v", err) ++ }
View file
_service:recompress:tar_scm_kernel_repo:patch.tar.gz/0135-fix-the-login_test-in-daemon-for-euleros-and-openeul.patch
Added
@@ -0,0 +1,32 @@ +From 72136fa6d5e08936a5ebced9a69044efa84b1fb3 Mon Sep 17 00:00:00 2001 +From: daisicheng <daisicheng@huawei.com> +Date: Wed, 21 Dec 2022 17:12:36 +0800 +Subject: [PATCH] fix the login_test in daemon for euleros and openeuler + consistency + +--- + daemon/login_test.go | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/daemon/login_test.go b/daemon/login_test.go +index b8ae002..03cbb62 100644 +--- a/daemon/login_test.go ++++ b/daemon/login_test.go +@@ -49,12 +49,11 @@ func TestLogin(t *testing.T) { + { + name: "TC2 - normal case with abnormal registry", + req: &pb.LoginRequest{ +- Server: "testcase.org", ++ Server: "localhost://8080", + Username: "testuser", + Password: encryptKey, + }, +- wantErr: true, +- errString: "no route to host", ++ wantErr: true, + }, + { + name: "TC3 - abnormal case with empty server", +-- +2.33.0 +
View file
_service:tar_scm_kernel_repo:VERSION-vendor
Changed
@@ -1 +1 @@ -0.9.6-15 +0.9.6-16
View file
_service:tar_scm_kernel_repo:git-commit
Changed
@@ -1 +1 @@ -a5b09eac902299ff56b460324b6cb4db18a16a25 +ed2c2b8cd969185451dd4507c4581942b33d5cbe
View file
_service:tar_scm_kernel_repo:series.conf
Changed
@@ -37,3 +37,10 @@ patch/0126-improve-security-compile-option-of-isula-build-binar.patch patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch patch/0128-add-read-lock-in-load-import-and-pull-to-fix-the-pro.patch +patch/0129-add-import_test.go-for-import.go-and-add-TestCleanCo.patch +patch/0130-add-copy-related-unit-tests-in-package-common.patch +patch/0131-improve-some-error-coverage-of-unit-tests-in-import.patch +patch/0132-add-login_test-logout_test-remove_test-and-import_te.patch +patch/0133-cmd-daemon-add-base-test-for-runDaemon-and-before-fu.patch +patch/0134-add-dt-for-interface-manifest-health-status-in-daemo.patch +patch/0135-fix-the-login_test-in-daemon-for-euleros-and-openeul.patch \ No newline at end of file
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.