Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
45a8b5f9
Commit
45a8b5f9
authored
Sep 22, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14286 from ArtfulCoder/split-KP-Tests
Make KubeProxy test faster
parents
f59a4431
a64dad04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
46 deletions
+57
-46
e2e.sh
hack/jenkins/e2e.sh
+0
-1
kubeproxy.go
test/e2e/kubeproxy.go
+57
-45
No files found.
hack/jenkins/e2e.sh
View file @
45a8b5f9
...
@@ -132,7 +132,6 @@ GCE_FLAKY_TESTS=(
...
@@ -132,7 +132,6 @@ GCE_FLAKY_TESTS=(
GCE_SLOW_TESTS
=(
GCE_SLOW_TESTS
=(
"SchedulerPredicates
\s
validates
\s
MaxPods
\s
limit "
# 8 min, file: scheduler_predicates.go, PR: #13315
"SchedulerPredicates
\s
validates
\s
MaxPods
\s
limit "
# 8 min, file: scheduler_predicates.go, PR: #13315
"Nodes
\s
Resize"
# 3 min 30 sec, file: resize_nodes.go, issue: #13323
"Nodes
\s
Resize"
# 3 min 30 sec, file: resize_nodes.go, issue: #13323
"KubeProxy
\s
should
\s
test
\s
kube-proxy"
# 15 min, file: kubeproxy.go, issue: #14204
)
)
# Tests which are not able to be run in parallel.
# Tests which are not able to be run in parallel.
...
...
test/e2e/kubeproxy.go
View file @
45a8b5f9
...
@@ -49,6 +49,7 @@ const (
...
@@ -49,6 +49,7 @@ const (
testPodName
=
"test-container-pod"
testPodName
=
"test-container-pod"
nodePortServiceName
=
"node-port-service"
nodePortServiceName
=
"node-port-service"
loadBalancerServiceName
=
"load-balancer-service"
loadBalancerServiceName
=
"load-balancer-service"
enableLoadBalancerTest
=
false
)
)
type
KubeProxyTestConfig
struct
{
type
KubeProxyTestConfig
struct
{
...
@@ -70,32 +71,8 @@ var _ = Describe("KubeProxy", func() {
...
@@ -70,32 +71,8 @@ var _ = Describe("KubeProxy", func() {
By
(
"cleaning up any pre-existing namespaces used by this test"
)
By
(
"cleaning up any pre-existing namespaces used by this test"
)
config
.
cleanup
()
config
.
cleanup
()
By
(
"creating a selector"
)
By
(
"Setting up for the tests"
)
selectorName
:=
"selector-"
+
string
(
util
.
NewUUID
())
config
.
setup
()
serviceSelector
:=
map
[
string
]
string
{
selectorName
:
"true"
,
}
By
(
"Getting ssh-able hosts"
)
hosts
,
err
:=
NodeSSHHosts
(
f
.
Client
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
if
len
(
hosts
)
==
0
{
Failf
(
"No ssh-able nodes"
)
}
config
.
nodes
=
hosts
By
(
"Creating the service pods in kubernetes"
)
podName
:=
"netserver"
config
.
endpointPods
=
config
.
createNetProxyPods
(
podName
,
serviceSelector
,
testContext
.
CloudConfig
.
NumNodes
)
By
(
"Creating the service on top of the pods in kubernetes"
)
config
.
createNodePortService
(
serviceSelector
)
By
(
"Creating the LoadBalancer Service on top of the pods in kubernetes"
)
config
.
createLoadBalancerService
(
serviceSelector
)
By
(
"Creating test pods"
)
config
.
createTestPod
()
//TODO Need to add hit externalIPs test
//TODO Need to add hit externalIPs test
By
(
"TODO: Need to add hit externalIPs test"
)
By
(
"TODO: Need to add hit externalIPs test"
)
...
@@ -111,9 +88,11 @@ var _ = Describe("KubeProxy", func() {
...
@@ -111,9 +88,11 @@ var _ = Describe("KubeProxy", func() {
config
.
deleteNodePortService
()
config
.
deleteNodePortService
()
config
.
hitNodePort
(
0
)
// expect 0 endpoints to be hit
config
.
hitNodePort
(
0
)
// expect 0 endpoints to be hit
By
(
"Deleting loadBalancerService and ensuring that service cannot be hit"
)
if
enableLoadBalancerTest
{
config
.
deleteLoadBalancerService
()
By
(
"Deleting loadBalancerService and ensuring that service cannot be hit"
)
config
.
hitLoadBalancer
(
0
)
config
.
deleteLoadBalancerService
()
config
.
hitLoadBalancer
(
0
)
// expect 0 endpoints to be hit
}
})
})
})
})
...
@@ -127,17 +106,20 @@ func (config *KubeProxyTestConfig) hitAll() {
...
@@ -127,17 +106,20 @@ func (config *KubeProxyTestConfig) hitAll() {
By
(
"Hitting nodePort from host and container"
)
By
(
"Hitting nodePort from host and container"
)
config
.
hitNodePort
(
len
(
config
.
endpointPods
))
config
.
hitNodePort
(
len
(
config
.
endpointPods
))
By
(
"Waiting for LoadBalancer Ingress Setup"
)
if
enableLoadBalancerTest
{
config
.
waitForLoadBalancerIngressSetup
()
By
(
"Waiting for LoadBalancer Ingress Setup"
)
config
.
waitForLoadBalancerIngressSetup
()
By
(
"Hitting LoadBalancer"
)
By
(
"Hitting LoadBalancer"
)
config
.
hitLoadBalancer
(
len
(
config
.
endpointPods
))
config
.
hitLoadBalancer
(
len
(
config
.
endpointPods
))
}
}
}
func
(
config
*
KubeProxyTestConfig
)
hitLoadBalancer
(
epCount
int
)
{
func
(
config
*
KubeProxyTestConfig
)
hitLoadBalancer
(
epCount
int
)
{
lbIP
:=
config
.
loadBalancerService
.
Status
.
LoadBalancer
.
Ingress
[
0
]
.
IP
lbIP
:=
config
.
loadBalancerService
.
Status
.
LoadBalancer
.
Ingress
[
0
]
.
IP
hostNames
:=
make
(
map
[
string
]
bool
)
hostNames
:=
make
(
map
[
string
]
bool
)
for
i
:=
0
;
i
<
50
;
i
++
{
tries
:=
epCount
*
epCount
+
5
for
i
:=
0
;
i
<
tries
;
i
++
{
transport
:=
&
http
.
Transport
{}
transport
:=
&
http
.
Transport
{}
httpClient
:=
createHTTPClient
(
transport
)
httpClient
:=
createHTTPClient
(
transport
)
resp
,
err
:=
httpClient
.
Get
(
fmt
.
Sprintf
(
"http://%s:%d/hostName"
,
lbIP
,
loadBalancerHttpPort
))
resp
,
err
:=
httpClient
.
Get
(
fmt
.
Sprintf
(
"http://%s:%d/hostName"
,
lbIP
,
loadBalancerHttpPort
))
...
@@ -163,7 +145,7 @@ func createHTTPClient(transport *http.Transport) *http.Client {
...
@@ -163,7 +145,7 @@ func createHTTPClient(transport *http.Transport) *http.Client {
func
(
config
*
KubeProxyTestConfig
)
hitClusterIP
(
epCount
int
)
{
func
(
config
*
KubeProxyTestConfig
)
hitClusterIP
(
epCount
int
)
{
clusterIP
:=
config
.
nodePortService
.
Spec
.
ClusterIP
clusterIP
:=
config
.
nodePortService
.
Spec
.
ClusterIP
tries
:=
epCount
*
5
+
1
0
tries
:=
epCount
*
epCount
+
5
// if epCount ==
0
By
(
"dialing(udp) node1 --> clusterIP:clusterUdpPort"
)
By
(
"dialing(udp) node1 --> clusterIP:clusterUdpPort"
)
config
.
dialFromNode
(
"udp"
,
clusterIP
,
clusterUdpPort
,
tries
,
epCount
)
config
.
dialFromNode
(
"udp"
,
clusterIP
,
clusterUdpPort
,
tries
,
epCount
)
By
(
"dialing(http) node1 --> clusterIP:clusterHttpPort"
)
By
(
"dialing(http) node1 --> clusterIP:clusterHttpPort"
)
...
@@ -182,7 +164,7 @@ func (config *KubeProxyTestConfig) hitClusterIP(epCount int) {
...
@@ -182,7 +164,7 @@ func (config *KubeProxyTestConfig) hitClusterIP(epCount int) {
func
(
config
*
KubeProxyTestConfig
)
hitNodePort
(
epCount
int
)
{
func
(
config
*
KubeProxyTestConfig
)
hitNodePort
(
epCount
int
)
{
node1_IP
:=
strings
.
TrimSuffix
(
config
.
nodes
[
0
],
":22"
)
node1_IP
:=
strings
.
TrimSuffix
(
config
.
nodes
[
0
],
":22"
)
tries
:=
epCount
*
5
+
10
// + 10 incase epCount is
0
tries
:=
epCount
*
epCount
+
5
// + 10 if epCount ==
0
By
(
"dialing(udp) node1 --> node1:nodeUdpPort"
)
By
(
"dialing(udp) node1 --> node1:nodeUdpPort"
)
config
.
dialFromNode
(
"udp"
,
node1_IP
,
nodeUdpPort
,
tries
,
epCount
)
config
.
dialFromNode
(
"udp"
,
node1_IP
,
nodeUdpPort
,
tries
,
epCount
)
By
(
"dialing(http) node1 --> node1:nodeHttpPort"
)
By
(
"dialing(http) node1 --> node1:nodeHttpPort"
)
...
@@ -255,9 +237,9 @@ func (config *KubeProxyTestConfig) dialFromContainer(protocol, containerIP, targ
...
@@ -255,9 +237,9 @@ func (config *KubeProxyTestConfig) dialFromContainer(protocol, containerIP, targ
func
(
config
*
KubeProxyTestConfig
)
dialFromNode
(
protocol
,
targetIP
string
,
targetPort
,
tries
,
expectedCount
int
)
{
func
(
config
*
KubeProxyTestConfig
)
dialFromNode
(
protocol
,
targetIP
string
,
targetPort
,
tries
,
expectedCount
int
)
{
var
cmd
string
var
cmd
string
if
protocol
==
"udp"
{
if
protocol
==
"udp"
{
cmd
=
fmt
.
Sprintf
(
"echo 'hostName' | nc -w
2
-u %s %d"
,
targetIP
,
targetPort
)
cmd
=
fmt
.
Sprintf
(
"echo 'hostName' | nc -w
1
-u %s %d"
,
targetIP
,
targetPort
)
}
else
{
}
else
{
cmd
=
fmt
.
Sprintf
(
"curl -s --connect-timeout
2
http://%s:%d/hostName"
,
targetIP
,
targetPort
)
cmd
=
fmt
.
Sprintf
(
"curl -s --connect-timeout
1
http://%s:%d/hostName"
,
targetIP
,
targetPort
)
}
}
forLoop
:=
fmt
.
Sprintf
(
"for i in $(seq 1 %d); do %s; echo; done | grep -v '^
\\
s*$' |sort | uniq -c | wc -l"
,
tries
,
cmd
)
forLoop
:=
fmt
.
Sprintf
(
"for i in $(seq 1 %d); do %s; echo; done | grep -v '^
\\
s*$' |sort | uniq -c | wc -l"
,
tries
,
cmd
)
By
(
fmt
.
Sprintf
(
"Dialing from node. command:%s"
,
forLoop
))
By
(
fmt
.
Sprintf
(
"Dialing from node. command:%s"
,
forLoop
))
...
@@ -369,7 +351,7 @@ func (config *KubeProxyTestConfig) createNodePortService(selector map[string]str
...
@@ -369,7 +351,7 @@ func (config *KubeProxyTestConfig) createNodePortService(selector map[string]str
func
(
config
*
KubeProxyTestConfig
)
deleteNodePortService
()
{
func
(
config
*
KubeProxyTestConfig
)
deleteNodePortService
()
{
err
:=
config
.
getServiceClient
()
.
Delete
(
config
.
nodePortService
.
Name
)
err
:=
config
.
getServiceClient
()
.
Delete
(
config
.
nodePortService
.
Name
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"error while deleting NodePortService. err:%v)"
,
err
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"error while deleting NodePortService. err:%v)"
,
err
)
time
.
Sleep
(
5
*
time
.
Second
)
// wait for kube-proxy to catch up with the service being deleted.
time
.
Sleep
(
1
5
*
time
.
Second
)
// wait for kube-proxy to catch up with the service being deleted.
}
}
func
(
config
*
KubeProxyTestConfig
)
createLoadBalancerService
(
selector
map
[
string
]
string
)
{
func
(
config
*
KubeProxyTestConfig
)
createLoadBalancerService
(
selector
map
[
string
]
string
)
{
...
@@ -389,13 +371,12 @@ func (config *KubeProxyTestConfig) createLoadBalancerService(selector map[string
...
@@ -389,13 +371,12 @@ func (config *KubeProxyTestConfig) createLoadBalancerService(selector map[string
}
}
func
(
config
*
KubeProxyTestConfig
)
deleteLoadBalancerService
()
{
func
(
config
*
KubeProxyTestConfig
)
deleteLoadBalancerService
()
{
err
:=
config
.
getServiceClient
()
.
Delete
(
config
.
loadBalancerService
.
Name
)
go
func
()
{
config
.
getServiceClient
()
.
Delete
(
config
.
loadBalancerService
.
Name
)
}()
Expect
(
err
)
.
NotTo
(
HaveOccurred
(),
"error while deleting LoadBalancerService. err:%v)"
,
err
)
time
.
Sleep
(
15
*
time
.
Second
)
// wait for kube-proxy to catch up with the service being deleted.
time
.
Sleep
(
10
*
time
.
Second
)
// wait for kube-proxy to catch up with the service being deleted.
}
}
func
(
config
*
KubeProxyTestConfig
)
waitForLoadBalancerIngressSetup
()
{
func
(
config
*
KubeProxyTestConfig
)
waitForLoadBalancerIngressSetup
()
{
err
:=
wait
.
Poll
(
5
*
time
.
Second
,
45
*
time
.
Second
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
(
2
*
time
.
Second
,
120
*
time
.
Second
,
func
()
(
bool
,
error
)
{
service
,
err
:=
config
.
getServiceClient
()
.
Get
(
loadBalancerServiceName
)
service
,
err
:=
config
.
getServiceClient
()
.
Get
(
loadBalancerServiceName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
...
@@ -429,8 +410,39 @@ func (config *KubeProxyTestConfig) createService(serviceSpec *api.Service) *api.
...
@@ -429,8 +410,39 @@ func (config *KubeProxyTestConfig) createService(serviceSpec *api.Service) *api.
return
createdService
return
createdService
}
}
func
(
config
*
KubeProxyTestConfig
)
setup
()
{
By
(
"creating a selector"
)
selectorName
:=
"selector-"
+
string
(
util
.
NewUUID
())
serviceSelector
:=
map
[
string
]
string
{
selectorName
:
"true"
,
}
By
(
"Getting ssh-able hosts"
)
hosts
,
err
:=
NodeSSHHosts
(
config
.
f
.
Client
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
if
len
(
hosts
)
==
0
{
Failf
(
"No ssh-able nodes"
)
}
config
.
nodes
=
hosts
if
enableLoadBalancerTest
{
By
(
"Creating the LoadBalancer Service on top of the pods in kubernetes"
)
config
.
createLoadBalancerService
(
serviceSelector
)
}
By
(
"Creating the service pods in kubernetes"
)
podName
:=
"netserver"
config
.
endpointPods
=
config
.
createNetProxyPods
(
podName
,
serviceSelector
,
testContext
.
CloudConfig
.
NumNodes
)
By
(
"Creating the service on top of the pods in kubernetes"
)
config
.
createNodePortService
(
serviceSelector
)
By
(
"Creating test pods"
)
config
.
createTestPod
()
}
func
(
config
*
KubeProxyTestConfig
)
cleanup
()
{
func
(
config
*
KubeProxyTestConfig
)
cleanup
()
{
nsClient
:=
config
.
getNamespaceClient
()
nsClient
:=
config
.
getNamespace
s
Client
()
nsList
,
err
:=
nsClient
.
List
(
nil
,
nil
)
nsList
,
err
:=
nsClient
.
List
(
nil
,
nil
)
if
err
==
nil
{
if
err
==
nil
{
for
_
,
ns
:=
range
nsList
.
Items
{
for
_
,
ns
:=
range
nsList
.
Items
{
...
@@ -483,7 +495,7 @@ func (config *KubeProxyTestConfig) getServiceClient() client.ServiceInterface {
...
@@ -483,7 +495,7 @@ func (config *KubeProxyTestConfig) getServiceClient() client.ServiceInterface {
return
config
.
f
.
Client
.
Services
(
config
.
f
.
Namespace
.
Name
)
return
config
.
f
.
Client
.
Services
(
config
.
f
.
Namespace
.
Name
)
}
}
func
(
config
*
KubeProxyTestConfig
)
getNamespaceClient
()
client
.
NamespaceInterface
{
func
(
config
*
KubeProxyTestConfig
)
getNamespace
s
Client
()
client
.
NamespaceInterface
{
return
config
.
f
.
Client
.
Namespaces
()
return
config
.
f
.
Client
.
Namespaces
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment