github.com/midokura/kubeedge@v1.2.0-mido.0/tests/performance/nodedensity/nodedensity_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 package nodedensity 17 18 import ( 19 "strconv" 20 "strings" 21 "testing" 22 "time" 23 24 . "github.com/onsi/ginkgo" 25 . "github.com/onsi/gomega" 26 metav1 "k8s.io/api/core/v1" 27 28 "github.com/kubeedge/kubeedge/tests/e2e/utils" 29 . "github.com/kubeedge/kubeedge/tests/performance/common" 30 "github.com/kubeedge/viaduct/pkg/api" 31 ) 32 33 //context to load config and access across the package 34 var ( 35 ctx *utils.TestContext 36 cfg utils.Config 37 cloudHubURL string 38 wsscloudHubURL string 39 quiccloudHubURL string 40 ) 41 42 func TestEdgecoreK8sDeployment(t *testing.T) { 43 var cloudCoreHostIP string 44 var podlist metav1.PodList 45 //var toTaint bool 46 RegisterFailHandler(Fail) 47 var _ = BeforeSuite(func() { 48 utils.Infof("Kubeedge deployment Load test Begin !!") 49 cfg = utils.LoadConfig() 50 ctx = utils.NewTestContext(cfg) 51 //apply label to all cluster nodes, use the selector to deploy all edgenodes to cluster nodes 52 err := ApplyLabel(ctx.Cfg.K8SMasterForProvisionEdgeNodes + NodeHandler) 53 Expect(err).Should(BeNil()) 54 //Create configMap for CloudCore 55 CloudConfigMap = "cloudcore-configmap-" + utils.GetRandomString(5) 56 CloudCoreDeployment = "cloudcore-deployment-" + utils.GetRandomString(5) 57 //protocol to be used for test between edge and cloud 58 if ctx.Cfg.Protocol == api.ProtocolTypeQuic { 59 IsQuicProtocol = true 60 } else { 61 IsQuicProtocol = false 62 } 63 //Deploye cloudcore as a k8s resource to cluster-1 64 err = HandleCloudDeployment(CloudConfigMap, CloudCoreDeployment, ctx.Cfg.K8SMasterForKubeEdge, 65 ctx.Cfg.K8SMasterForKubeEdge+ConfigmapHandler, ctx.Cfg.K8SMasterForKubeEdge+DeploymentHandler, ctx.Cfg.CloudImageUrl, ctx.Cfg.NumOfNodes) 66 Expect(err).Should(BeNil()) 67 time.Sleep(1 * time.Second) 68 //Get the cloudCore pod Node name and IP 69 podlist, err = utils.GetPods(ctx.Cfg.K8SMasterForKubeEdge+AppHandler, "") 70 Expect(err).To(BeNil()) 71 for _, pod := range podlist.Items { 72 if strings.Contains(pod.Name, "cloudcore-deployment") { 73 cloudCoreHostIP = pod.Status.HostIP 74 } 75 break 76 } 77 utils.CheckPodRunningState(ctx.Cfg.K8SMasterForKubeEdge+AppHandler, podlist) 78 time.Sleep(300 * time.Second) 79 //Create service for cloud 80 err = utils.ExposeCloudService(CloudCoreDeployment, ctx.Cfg.K8SMasterForKubeEdge+ServiceHandler) 81 Expect(err).Should(BeNil()) 82 //Create a nodePort Service to access the cloud Service from the cluster nodes 83 wsPort, quicPort := utils.GetServicePort(CloudCoreDeployment, ctx.Cfg.K8SMasterForKubeEdge+ServiceHandler) 84 wsNodePort := strconv.FormatInt(int64(wsPort), 10) 85 quicNodePort := strconv.FormatInt(int64(quicPort), 10) 86 quiccloudHubURL = cloudCoreHostIP + ":" + quicNodePort 87 cloudHubURL = quiccloudHubURL 88 wsscloudHubURL = "wss://" + cloudCoreHostIP + ":" + wsNodePort 89 cloudHubURL = wsscloudHubURL 90 }) 91 AfterSuite(func() { 92 By("Kubeedge deployment Load test End !!....!") 93 94 DeleteCloudDeployment(ctx.Cfg.K8SMasterForKubeEdge) 95 utils.CheckPodDeleteState(ctx.Cfg.K8SMasterForKubeEdge+AppHandler, podlist) 96 97 }) 98 99 RunSpecs(t, "kubeedge Performace Load test Suite") 100 }