1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
Copyright 2019 The KubeEdge Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package loadtest
import (
"net"
"net/url"
"strconv"
"strings"
"testing"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/api/core/v1"
"github.com/kubeedge/kubeedge/tests/e2e/utils"
. "github.com/kubeedge/kubeedge/tests/performance/common"
"github.com/kubeedge/viaduct/pkg/api"
)
//context to load config and access across the package
var (
ctx *utils.TestContext
cfg utils.Config
nodeSelector string
cloudHubURL string
wsscloudHubURL string
quiccloudHubURL string
cloudCoreNodeName string
)
func TestEdgecoreK8sDeployment(t *testing.T) {
var cloudCoreHostIP string
var podlist metav1.PodList
//var toTaint bool
RegisterFailHandler(Fail)
var _ = BeforeSuite(func() {
utils.Infof("Kubeedge deployment Load test Begin !!")
cfg = utils.LoadConfig()
ctx = utils.NewTestContext(cfg)
//apply label to all cluster nodes, use the selector to deploy all edgenodes to cluster nodes
err := ApplyLabel(ctx.Cfg.K8SMasterForProvisionEdgeNodes + NodeHandler)
Expect(err).Should(BeNil())
//Create configMap for CloudCore
CloudConfigMap = "cloudcore-configmap-" + utils.GetRandomString(5)
CloudCoreDeployment = "cloudcore-deployment-" + utils.GetRandomString(5)
//protocol to be used for test between edge and cloud
if ctx.Cfg.Protocol == api.ProtocolTypeQuic {
IsQuicProtocol = true
} else {
IsQuicProtocol = false
}
//Deploye cloudcore as a k8s resource to cluster-1
err = HandleCloudDeployment(CloudConfigMap, CloudCoreDeployment, ctx.Cfg.K8SMasterForKubeEdge,
ctx.Cfg.K8SMasterForKubeEdge+ConfigmapHandler, ctx.Cfg.K8SMasterForKubeEdge+DeploymentHandler, ctx.Cfg.CloudImageURL, ctx.Cfg.NumOfNodes)
Expect(err).Should(BeNil())
time.Sleep(1 * time.Second)
//Get the cloudCore pod Node name and IP
podlist, err = utils.GetPods(ctx.Cfg.K8SMasterForKubeEdge+AppHandler, "")
Expect(err).To(BeNil())
for _, pod := range podlist.Items {
if strings.Contains(pod.Name, "cloudcore-deployment") {
cloudCoreHostIP = pod.Status.HostIP
cloudCoreNodeName = pod.Spec.NodeName
break
}
}
utils.CheckPodRunningState(ctx.Cfg.K8SMasterForKubeEdge+AppHandler, podlist)
time.Sleep(5 * time.Second)
//Create service for cloud
err = utils.ExposeCloudService(CloudCoreDeployment, ctx.Cfg.K8SMasterForKubeEdge+ServiceHandler)
Expect(err).Should(BeNil())
//Create a nodePort Service to access the cloud Service from the cluster nodes
wsPort, quicPort := utils.GetServicePort(CloudCoreDeployment, ctx.Cfg.K8SMasterForKubeEdge+ServiceHandler)
wsNodePort := strconv.FormatInt(int64(wsPort), 10)
quicNodePort := strconv.FormatInt(int64(quicPort), 10)
quiccloudHubURL = net.JoinHostPort(cloudCoreHostIP, quicNodePort)
cloudHubURL = quiccloudHubURL
wsscloudHubURL = (&url.URL{
Scheme: "wss",
Host: net.JoinHostPort(cloudCoreHostIP, wsNodePort),
}).String()
cloudHubURL = wsscloudHubURL
//Deploye edgecore as a k8s resource to cluster-2
podlist = HandleEdgeDeployment(cloudHubURL, ctx.Cfg.K8SMasterForProvisionEdgeNodes+DeploymentHandler, ctx.Cfg.K8SMasterForKubeEdge+NodeHandler,
ctx.Cfg.K8SMasterForProvisionEdgeNodes+ConfigmapHandler, ctx.Cfg.EdgeImageURL, ctx.Cfg.K8SMasterForProvisionEdgeNodes+AppHandler, ctx.Cfg.NumOfNodes)
//skip the pod scheduling in k8s node while kubeedge nodes are available to schedule
ToTaint = true
err = utils.TaintEdgeDeployedNode(ToTaint, ctx.Cfg.K8SMasterForKubeEdge+NodeHandler+"/"+cloudCoreNodeName)
Expect(err).Should(BeNil())
ToTaint = false
})
AfterSuite(func() {
By("Kubeedge deployment Load test End !!....!")
DeleteEdgeDeployments(ctx.Cfg.K8SMasterForKubeEdge, ctx.Cfg.K8SMasterForProvisionEdgeNodes, ctx.Cfg.NumOfNodes)
utils.CheckDeploymentPodDeleteState(ctx.Cfg.K8SMasterForProvisionEdgeNodes, podlist)
//untaint Node
err := utils.TaintEdgeDeployedNode(ToTaint, ctx.Cfg.K8SMasterForKubeEdge+NodeHandler+"/"+cloudCoreNodeName)
Expect(err).Should(BeNil())
DeleteCloudDeployment(ctx.Cfg.K8SMasterForKubeEdge)
})
RunSpecs(t, "kubeedge Performance Load test Suite")
}
|