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
e07a9c4c
Commit
e07a9c4c
authored
Nov 05, 2017
by
MrHohn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't share nodePort service in session affinity tests
parent
aed9ad4b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
networking_utils.go
test/e2e/framework/networking_utils.go
+21
-4
networking.go
test/e2e/network/networking.go
+6
-21
No files found.
test/e2e/framework/networking_utils.go
View file @
e07a9c4c
...
@@ -53,6 +53,7 @@ const (
...
@@ -53,6 +53,7 @@ const (
testPodName
=
"test-container-pod"
testPodName
=
"test-container-pod"
hostTestPodName
=
"host-test-container-pod"
hostTestPodName
=
"host-test-container-pod"
nodePortServiceName
=
"node-port-service"
nodePortServiceName
=
"node-port-service"
sessionAffinityServiceName
=
"session-affinity-service"
// wait time between poll attempts of a Service vip and/or nodePort.
// wait time between poll attempts of a Service vip and/or nodePort.
// coupled with testTries to produce a net timeout value.
// coupled with testTries to produce a net timeout value.
hitEndpointRetryDelay
=
2
*
time
.
Second
hitEndpointRetryDelay
=
2
*
time
.
Second
...
@@ -110,6 +111,9 @@ type NetworkingTestConfig struct {
...
@@ -110,6 +111,9 @@ type NetworkingTestConfig struct {
// NodePortService is a Service with Type=NodePort spanning over all
// NodePortService is a Service with Type=NodePort spanning over all
// endpointPods.
// endpointPods.
NodePortService
*
v1
.
Service
NodePortService
*
v1
.
Service
// SessionAffinityService is a Service with SessionAffinity=ClientIP
// spanning over all endpointPods.
SessionAffinityService
*
v1
.
Service
// ExternalAddrs is a list of external IPs of nodes in the cluster.
// ExternalAddrs is a list of external IPs of nodes in the cluster.
ExternalAddrs
[]
string
ExternalAddrs
[]
string
// Nodes is a list of nodes in the cluster.
// Nodes is a list of nodes in the cluster.
...
@@ -463,10 +467,14 @@ func (config *NetworkingTestConfig) createTestPodSpec() *v1.Pod {
...
@@ -463,10 +467,14 @@ func (config *NetworkingTestConfig) createTestPodSpec() *v1.Pod {
return
pod
return
pod
}
}
func
(
config
*
NetworkingTestConfig
)
createNodePortService
(
selector
map
[
string
]
string
)
{
func
(
config
*
NetworkingTestConfig
)
createNodePortServiceSpec
(
svcName
string
,
selector
map
[
string
]
string
,
enableSessionAffinity
bool
)
*
v1
.
Service
{
serviceSpec
:=
&
v1
.
Service
{
sessionAffinity
:=
v1
.
ServiceAffinityNone
if
enableSessionAffinity
{
sessionAffinity
=
v1
.
ServiceAffinityClientIP
}
return
&
v1
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
nodePortService
Name
,
Name
:
svc
Name
,
},
},
Spec
:
v1
.
ServiceSpec
{
Spec
:
v1
.
ServiceSpec
{
Type
:
v1
.
ServiceTypeNodePort
,
Type
:
v1
.
ServiceTypeNodePort
,
...
@@ -475,9 +483,17 @@ func (config *NetworkingTestConfig) createNodePortService(selector map[string]st
...
@@ -475,9 +483,17 @@ func (config *NetworkingTestConfig) createNodePortService(selector map[string]st
{
Port
:
ClusterUdpPort
,
Name
:
"udp"
,
Protocol
:
v1
.
ProtocolUDP
,
TargetPort
:
intstr
.
FromInt
(
EndpointUdpPort
)},
{
Port
:
ClusterUdpPort
,
Name
:
"udp"
,
Protocol
:
v1
.
ProtocolUDP
,
TargetPort
:
intstr
.
FromInt
(
EndpointUdpPort
)},
},
},
Selector
:
selector
,
Selector
:
selector
,
SessionAffinity
:
sessionAffinity
,
},
},
}
}
config
.
NodePortService
=
config
.
createService
(
serviceSpec
)
}
func
(
config
*
NetworkingTestConfig
)
createNodePortService
(
selector
map
[
string
]
string
)
{
config
.
NodePortService
=
config
.
createService
(
config
.
createNodePortServiceSpec
(
nodePortServiceName
,
selector
,
false
))
}
func
(
config
*
NetworkingTestConfig
)
createSessionAffinityService
(
selector
map
[
string
]
string
)
{
config
.
SessionAffinityService
=
config
.
createService
(
config
.
createNodePortServiceSpec
(
sessionAffinityServiceName
,
selector
,
true
))
}
}
func
(
config
*
NetworkingTestConfig
)
DeleteNodePortService
()
{
func
(
config
*
NetworkingTestConfig
)
DeleteNodePortService
()
{
...
@@ -549,6 +565,7 @@ func (config *NetworkingTestConfig) setup(selector map[string]string) {
...
@@ -549,6 +565,7 @@ func (config *NetworkingTestConfig) setup(selector map[string]string) {
By
(
"Creating the service on top of the pods in kubernetes"
)
By
(
"Creating the service on top of the pods in kubernetes"
)
config
.
createNodePortService
(
selector
)
config
.
createNodePortService
(
selector
)
config
.
createSessionAffinityService
(
selector
)
for
_
,
p
:=
range
config
.
NodePortService
.
Spec
.
Ports
{
for
_
,
p
:=
range
config
.
NodePortService
.
Spec
.
Ports
{
switch
p
.
Protocol
{
switch
p
.
Protocol
{
...
...
test/e2e/network/networking.go
View file @
e07a9c4c
...
@@ -20,7 +20,6 @@ import (
...
@@ -20,7 +20,6 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
...
@@ -201,19 +200,12 @@ var _ = SIGDescribe("Networking", func() {
...
@@ -201,19 +200,12 @@ var _ = SIGDescribe("Networking", func() {
config
.
DialFromNode
(
"udp"
,
config
.
NodeIP
,
config
.
NodeUdpPort
,
config
.
MaxTries
,
config
.
MaxTries
,
sets
.
NewString
())
config
.
DialFromNode
(
"udp"
,
config
.
NodeIP
,
config
.
NodeUdpPort
,
config
.
MaxTries
,
config
.
MaxTries
,
sets
.
NewString
())
})
})
It
(
"should function for client IP based session affinity: http
[Slow]
"
,
func
()
{
It
(
"should function for client IP based session affinity: http"
,
func
()
{
config
:=
framework
.
NewNetworkingTestConfig
(
f
)
config
:=
framework
.
NewNetworkingTestConfig
(
f
)
By
(
fmt
.
Sprintf
(
"dialing(http) %v --> %v:%v (config.clusterIP)"
,
config
.
TestContainerPod
.
Name
,
config
.
ClusterIP
,
framework
.
ClusterHttpPort
))
By
(
fmt
.
Sprintf
(
"dialing(http) %v --> %v:%v"
,
config
.
TestContainerPod
.
Name
,
config
.
SessionAffinityService
.
Spec
.
ClusterIP
,
framework
.
ClusterHttpPort
))
updateSessionAffinity
:=
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityClientIP
}
_
,
err
:=
framework
.
UpdateService
(
f
.
ClientSet
,
config
.
NodePortService
.
Namespace
,
config
.
NodePortService
.
Name
,
updateSessionAffinity
)
if
err
!=
nil
{
framework
.
Failf
(
"Failed to update service session affinity, error: %v"
,
err
)
}
// Check if number of endpoints returned are exactly one.
// Check if number of endpoints returned are exactly one.
eps
,
err
:=
config
.
GetEndpointsFromTestContainer
(
"http"
,
config
.
ClusterIP
,
framework
.
ClusterHttpPort
,
framework
.
SessionAffinityChecks
)
eps
,
err
:=
config
.
GetEndpointsFromTestContainer
(
"http"
,
config
.
SessionAffinityService
.
Spec
.
ClusterIP
,
framework
.
ClusterHttpPort
,
framework
.
SessionAffinityChecks
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"Failed to get endpoints from test container, error: %v"
,
err
)
framework
.
Failf
(
"Failed to get endpoints from test container, error: %v"
,
err
)
}
}
...
@@ -225,19 +217,12 @@ var _ = SIGDescribe("Networking", func() {
...
@@ -225,19 +217,12 @@ var _ = SIGDescribe("Networking", func() {
}
}
})
})
It
(
"should function for client IP based session affinity: udp
[Slow]
"
,
func
()
{
It
(
"should function for client IP based session affinity: udp"
,
func
()
{
config
:=
framework
.
NewNetworkingTestConfig
(
f
)
config
:=
framework
.
NewNetworkingTestConfig
(
f
)
By
(
fmt
.
Sprintf
(
"dialing(udp) %v --> %v:%v (config.clusterIP)"
,
config
.
TestContainerPod
.
Name
,
config
.
ClusterIP
,
framework
.
ClusterUdpPort
))
By
(
fmt
.
Sprintf
(
"dialing(udp) %v --> %v:%v"
,
config
.
TestContainerPod
.
Name
,
config
.
SessionAffinityService
.
Spec
.
ClusterIP
,
framework
.
ClusterUdpPort
))
updateSessionAffinity
:=
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityClientIP
}
_
,
err
:=
framework
.
UpdateService
(
f
.
ClientSet
,
config
.
NodePortService
.
Namespace
,
config
.
NodePortService
.
Name
,
updateSessionAffinity
)
if
err
!=
nil
{
framework
.
Failf
(
"Failed to update service session affinity, error: %v"
,
err
)
}
// Check if number of endpoints returned are exactly one.
// Check if number of endpoints returned are exactly one.
eps
,
err
:=
config
.
GetEndpointsFromTestContainer
(
"udp"
,
config
.
ClusterIP
,
framework
.
ClusterUdpPort
,
framework
.
SessionAffinityChecks
)
eps
,
err
:=
config
.
GetEndpointsFromTestContainer
(
"udp"
,
config
.
SessionAffinityService
.
Spec
.
ClusterIP
,
framework
.
ClusterUdpPort
,
framework
.
SessionAffinityChecks
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"Failed to get endpoints from test container, error: %v"
,
err
)
framework
.
Failf
(
"Failed to get endpoints from test container, error: %v"
,
err
)
}
}
...
...
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