github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/test/sealer_run_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 "strings" 19 20 . "github.com/onsi/ginkgo" 21 22 "github.com/alibaba/sealer/test/suites/apply" 23 "github.com/alibaba/sealer/test/testhelper" 24 "github.com/alibaba/sealer/test/testhelper/settings" 25 ) 26 27 var _ = Describe("sealer run", func() { 28 29 Context("run on bareMetal", func() { 30 var tempFile string 31 BeforeEach(func() { 32 tempFile = testhelper.CreateTempFile() 33 }) 34 35 AfterEach(func() { 36 testhelper.RemoveTempFile(tempFile) 37 }) 38 39 It("bareMetal run", func() { 40 rawCluster := apply.LoadClusterFileFromDisk(apply.GetRawClusterFilePath()) 41 By("start to prepare infra") 42 usedCluster := apply.CreateAliCloudInfraAndSave(rawCluster, tempFile) 43 //defer to delete cluster 44 defer func() { 45 apply.CleanUpAliCloudInfra(usedCluster) 46 }() 47 sshClient := testhelper.NewSSHClientByCluster(usedCluster) 48 testhelper.CheckFuncBeTrue(func() bool { 49 err := sshClient.SSH.Copy(sshClient.RemoteHostIP, settings.DefaultSealerBin, settings.DefaultSealerBin) 50 return err == nil 51 }, settings.MaxWaiteTime) 52 53 By("start to init cluster", func() { 54 masters := strings.Join(usedCluster.Spec.Masters.IPList, ",") 55 nodes := strings.Join(usedCluster.Spec.Nodes.IPList, ",") 56 apply.SendAndRunCluster(sshClient, tempFile, masters, nodes, usedCluster.Spec.SSH.Passwd) 57 apply.CheckNodeNumWithSSH(sshClient, 2) 58 }) 59 60 }) 61 }) 62 })