Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/alibaba/sealer into main
Browse files Browse the repository at this point in the history
  • Loading branch information
fanux committed Jun 4, 2021
2 parents fe7882d + 25147ec commit 9143e60
Show file tree
Hide file tree
Showing 103 changed files with 1,598 additions and 6,895 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
- name: Make linux
shell: bash
run: |
export GIT_VERSION=${GIT_TAG#v}
export MULTI_PLATFORM_BUILD=true
make build
working-directory: src/github.com/alibaba/sealer
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
GitTag=$(version)
Dirs=$(shell ls)

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand All @@ -10,7 +9,7 @@ endif

build: clean ## build binaries by default
@echo "build sealer and sealutil bin"
hack/build.sh $(GitTag)
hack/build.sh

linux: clean ## build binaries for linux
@echo "build sealer and sealutil bin for linux"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/sealyun/lvscare v1.1.2-alpha.2
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
github.com/vbauerster/mpb/v6 v6.0.3
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
k8s.io/api v0.20.4
Expand Down
13 changes: 1 addition & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down Expand Up @@ -301,9 +297,8 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
Expand Down Expand Up @@ -401,9 +396,6 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4=
github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down Expand Up @@ -460,8 +452,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/vbauerster/mpb/v6 v6.0.3 h1:j+twHHhSUe8aXWaT/27E98G5cSBeqEuJSVCMjmLg0PI=
github.com/vbauerster/mpb/v6 v6.0.3/go.mod h1:5luBx4rDLWxpA4t6I5sdeeQuZhqDxc+wr5Nqf35+tnM=
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
Expand Down Expand Up @@ -619,7 +609,6 @@ golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
Expand Down
9 changes: 4 additions & 5 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ get_version_vars() {
}

ldflags() {
get_version_vars

local -a ldflags
function add_ldflag() {
local key=${1}
Expand Down Expand Up @@ -83,10 +81,11 @@ readonly SEALER_SUPPORTED_PLATFORMS=(
)

build_binaries() {
get_version_vars
goldflags="${GOLDFLAGS=-s -w} $(ldflags)"
osarch=${1-}_${2-}
mkdir -p $THIS_PLATFORM_ASSETS
tarFile="${3-}-${1-}-${2-}.tar.gz"
tarFile="${GIT_VERSION}-${1-}-${2-}.tar.gz"

debug "!!! build $osarch sealer"
GOOS=${1-} GOARCH=${2-} go build -o $THIS_PLATFORM_BIN/sealer/$osarch/sealer -mod vendor -ldflags "$goldflags" $SEALER_ROOT/sealer/main.go
Expand Down Expand Up @@ -118,9 +117,9 @@ if [[ $MULTI_PLATFORM_BUILD ]]; then
for platform in "${SEALER_SUPPORTED_PLATFORMS[@]}"; do
OS=${platform%/*}
ARCH=${platform##*/}
build_binaries $OS $ARCH ${1-0.0.0}
build_binaries $OS $ARCH
done;
else
build_binaries `go env GOOS` `go env GOARCH` ${1-0.0.0}
build_binaries `go env GOOS` `go env GOARCH`
fi

1 change: 1 addition & 0 deletions logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func NewLogger(depth ...int) *LocalLogger {
}
l.appName = "[" + appSn + "]"
l.callDepth = dep
l.usePath = true
l.SetLogger(AdapterConsole)
l.timeFormat = logTimeDefaultFormat
return l
Expand Down
1 change: 1 addition & 0 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
output, err := exec.LookPath("sealer")
Expect(err).NotTo(HaveOccurred(), output)
SetDefaultEventuallyTimeout(settings.DefaultWaiteTime)
settings.DefaultSealerBin = output
return nil
}, func(data []byte) {
SetDefaultEventuallyTimeout(settings.DefaultWaiteTime)
Expand Down
4 changes: 2 additions & 2 deletions test/sealer_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package test

import (
/*import (
"fmt"
"github.com/alibaba/sealer/test/suites/apply"
Expand Down Expand Up @@ -48,4 +48,4 @@ var _ = Describe("sealer apply", func() {
})
})
})*/
158 changes: 122 additions & 36 deletions test/sealer_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,153 @@
package test

import (
"fmt"
"os"
"path/filepath"

"github.com/alibaba/sealer/test/suites/build"
"github.com/alibaba/sealer/common"
"github.com/alibaba/sealer/test/suites/apply"
"github.com/alibaba/sealer/test/suites/image"
"github.com/alibaba/sealer/test/suites/registry"

"github.com/alibaba/sealer/test/suites/build"
"github.com/alibaba/sealer/test/testhelper"
"github.com/alibaba/sealer/test/testhelper/settings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("sealer build", func() {
Context("start build", func() {

BeforeEach(func() {
registry.Login()
})
AfterEach(func() {
registry.Logout()
})

Context("cloud build", func() {
Context("build with only copy cmd", func() {
imageName := settings.GetTestImageName()
context := build.GetOnlyCopyDir()
Context("test build args", func() {
Context("build kube file", func() {
Context("testing the abnormal scenario ", func() {
var tempFile string
BeforeEach(func() {
err := os.Chdir(context)
Expect(err).NotTo(HaveOccurred())
tempFile = testhelper.CreateTempFile()
})

AfterEach(func() {
// run delete test image
testhelper.RemoveTempFile(tempFile)
})
It("only copy", func() {
sess, err := testhelper.Start(fmt.Sprintf("sealer build -t %s .", imageName))
It("specific the base rootfs that do not exist", func() {
//base rootfs not exist
err := testhelper.WriteFile(tempFile, []byte("from abc\ncopy . ."))
Expect(err).NotTo(HaveOccurred())
Eventually(sess, settings.MaxWaiteTime).Should(Exit(0))
cmd := build.NewArgsOfBuild().
SetKubeFile(tempFile).
SetImageName(build.GetTestImageName()).
SetContext(".").
SetBuildType(common.LocalBuild).
Build()
sess, err := testhelper.Start(cmd)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(Exit(2))
})
})

Context("build with all cmd", func() {
imageName := settings.GetTestImageName()
context := build.GetBuildTestDir()
BeforeEach(func() {
err := os.Chdir(context)
It("copy src that do not exist", func() {
//copy: copy src not exist;
err := testhelper.WriteFile(tempFile, []byte("from sealer-io/kubernetes:v1.19.9\ncopy abc123 ."))
Expect(err).NotTo(HaveOccurred())
cmd := build.NewArgsOfBuild().
SetKubeFile(tempFile).
SetImageName(build.GetTestImageName()).
SetContext(".").
SetBuildType(common.LocalBuild).
Build()
sess, err := testhelper.Start(cmd)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(Exit(2))
})
AfterEach(func() {
// run delete test image
})
It("all build cmd", func() {
sess, err := testhelper.Start(fmt.Sprintf("sealer build -t %s .", imageName))

It("exec cmd that do not exist in system", func() {
//run&cmd: exec cmd not exist
err := testhelper.WriteFile(tempFile, []byte("from sealer-io/kubernetes:v1.19.9\ncmd abc ."))
Expect(err).NotTo(HaveOccurred())
Eventually(sess, settings.MaxWaiteTime).Should(Exit(0))
cmd := build.NewArgsOfBuild().
SetKubeFile(tempFile).
SetImageName(build.GetTestImageName()).
SetContext(".").
SetBuildType(common.LocalBuild).
Build()
sess, err := testhelper.Start(cmd)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(Exit(2))
})
})

})
Context("testing the content of kube file", func() {
Context("testing local build scenario", func() {
err := os.Chdir(filepath.Join(build.GetFixtures(), build.GetLocalBuildDir()))
Expect(err).NotTo(HaveOccurred())

Context("local build", func() {
})
It("with all build instruct", func() {
imageName := build.GetTestImageName()
cmd := build.NewArgsOfBuild().
SetKubeFile("Kubefile").
SetImageName(imageName).
SetContext(".").
SetBuildType(settings.LocalBuild).
Build()
sess, err := testhelper.Start(cmd)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(Exit(0))
// check: sealer images whether image exist
Expect(build.CheckIsImageExist(imageName)).Should(BeTrue())
Expect(build.CheckClusterFile(imageName)).Should(BeTrue())
})

It("only copy instruct", func() {
imageName := build.GetTestImageName()
cmd := build.NewArgsOfBuild().
SetKubeFile("Kubefile_only_copy").
SetImageName(imageName).
SetContext(".").
SetBuildType(settings.LocalBuild).
Build()
sess, err := testhelper.Start(cmd)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(Exit(0))
// check: sealer images whether image exist
Expect(build.CheckIsImageExist(imageName)).Should(BeTrue())
Expect(build.CheckClusterFile(imageName)).Should(BeTrue())
})

})
Context("testing cloud build scenario", func() {
BeforeEach(func() {
registry.Login()
err := os.Chdir(filepath.Join("..", build.GetCloudBuildDir()))
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
registry.Logout()
})

It("with all build instruct", func() {
imageName := build.GetTestImageName()
cmd := build.NewArgsOfBuild().
SetKubeFile("Kubefile").
SetImageName(imageName).
SetContext(".").
SetBuildType("cloud").
Build()
sess, err := testhelper.Start(cmd)
Expect(err).NotTo(HaveOccurred())
defer func() {
apply.CleanUpAliCloudInfraByClusterFile(settings.TMPClusterFile)
}()
Eventually(sess, settings.MaxWaiteTime).Should(Exit(0))
// check: need to pull build image and check whether image exist
image.DoImageOps(settings.SubCmdPullOfSealer, imageName)
Expect(build.CheckIsImageExist(imageName)).Should(BeTrue())
Expect(build.CheckClusterFile(imageName)).Should(BeTrue())
})

})

})

})
})
})
4 changes: 2 additions & 2 deletions test/sealer_login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package test

import (
/*import (
"fmt"
"github.com/alibaba/sealer/test/suites/registry"
Expand All @@ -40,4 +40,4 @@ var _ = Describe("sealer login", func() {
Eventually(sess).Should(Exit(0))
})
})
})
})*/
Loading

0 comments on commit 9143e60

Please sign in to comment.