github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/tests/e2e/deployment/deployment_suite_test.go (about) 1 /* 2 Copyright 2019 The KubeEdge Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package deployment 18 19 import ( 20 "net/http" 21 "testing" 22 23 . "github.com/onsi/ginkgo" 24 . "github.com/onsi/gomega" 25 26 "github.com/kubeedge/kubeedge/tests/e2e/constants" 27 "github.com/kubeedge/kubeedge/tests/e2e/utils" 28 ) 29 30 var ( 31 nodeName string 32 nodeSelector string 33 //context to load config and access across the package 34 ctx *utils.TestContext 35 ) 36 37 //Function to run the Ginkgo Test 38 func TestEdgecoreAppDeployment(t *testing.T) { 39 RegisterFailHandler(Fail) 40 var _ = BeforeSuite(func() { 41 utils.Infof("Before Suite Execution") 42 //cfg = utils.LoadConfig() 43 ctx = utils.NewTestContext(utils.LoadConfig()) 44 nodeName = "integration-node-" + utils.GetRandomString(10) 45 nodeSelector = "node-" + utils.GetRandomString(3) 46 47 //Generate Cerificates for Edge and Cloud nodes copy to respective folders 48 Expect(utils.GenerateCerts()).Should(BeNil()) 49 //Do the neccessary config changes in Cloud and Edge nodes 50 Expect(utils.DeploySetup(ctx, nodeName, "deployment")).Should(BeNil()) 51 //Run ./cloudcore binary 52 Expect(utils.StartCloudCore()).Should(BeNil()) 53 //Register the Edge Node to Master 54 Expect(utils.RegisterNodeToMaster(nodeName, ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, nodeSelector)).Should(BeNil()) 55 //Run ./edgecore after node registration 56 Expect(utils.StartEdgeCore()).Should(BeNil()) 57 //Check node successfully registered or not 58 Eventually(func() string { 59 status := utils.CheckNodeReadyStatus(ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, nodeName) 60 utils.Infof("Node Name: %v, Node Status: %v", nodeName, status) 61 return status 62 }, "60s", "4s").Should(Equal("Running"), "Node register to the k8s master is unsuccessfull !!") 63 err := utils.MqttConnect() 64 Expect(err).To(BeNil()) 65 }) 66 AfterSuite(func() { 67 By("After Suite Execution....!") 68 //Deregister the edge node from master 69 Expect(utils.DeRegisterNodeFromMaster(ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, nodeName)).Should(BeNil()) 70 Eventually(func() int { 71 statuscode := utils.CheckNodeDeleteStatus(ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, nodeName) 72 utils.Infof("Node Name: %v, Node Statuscode: %v", nodeName, statuscode) 73 return statuscode 74 }, "60s", "4s").Should(Equal(http.StatusNotFound), "Node register to the k8s master is unsuccessfull !!") 75 76 //Run the Cleanup steps to kill edgecore and cloudcore binaries 77 Expect(utils.CleanUp("deployment")).Should(BeNil()) 78 //time.Sleep(2 * time.Second) 79 utils.Infof("Cleanup is Successfull !!") 80 }) 81 82 RunSpecs(t, "kubeedge App Deploymet Suite") 83 }