github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/test/sealer_build_test.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package test 16 17 import ( 18 "os" 19 "path/filepath" 20 21 "github.com/alibaba/sealer/test/suites/image" 22 23 "github.com/alibaba/sealer/test/suites/build" 24 "github.com/alibaba/sealer/test/suites/registry" 25 "github.com/alibaba/sealer/test/testhelper" 26 "github.com/alibaba/sealer/test/testhelper/settings" 27 . "github.com/onsi/ginkgo" 28 ) 29 30 var _ = Describe("sealer build", func() { 31 Context("testing the content of kube file", func() { 32 Context("testing lite build scenario", func() { 33 34 BeforeEach(func() { 35 registry.Login() 36 liteBuildPath := filepath.Join(build.GetFixtures(), build.GetLiteBuildDir()) 37 err := os.Chdir(liteBuildPath) 38 testhelper.CheckErr(err) 39 //add From custom image name 40 build.UpdateKubeFromImage(settings.TestImageName, filepath.Join(liteBuildPath, "Kubefile")) 41 }) 42 AfterEach(func() { 43 registry.Logout() 44 err := os.Chdir(settings.DefaultTestEnvDir) 45 testhelper.CheckErr(err) 46 }) 47 48 It("with all build instruct", func() { 49 imageName := build.GetTestImageName() 50 cmd := build.NewArgsOfBuild(). 51 SetKubeFile("Kubefile"). 52 SetImageName(imageName). 53 SetContext("."). 54 SetBuildType(settings.LiteBuild). 55 Build() 56 sess, err := testhelper.Start(cmd) 57 testhelper.CheckErr(err) 58 testhelper.CheckExit0(sess, settings.MaxWaiteTime) 59 // check: sealer images whether image exist 60 testhelper.CheckBeTrue(build.CheckIsImageExist(imageName)) 61 image.DoImageOps(settings.SubCmdPushOfSealer, imageName) 62 }) 63 }) 64 }) 65 66 })