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
e1df5c8b
Commit
e1df5c8b
authored
Jul 07, 2016
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix proxy unit tests
parent
51dcff40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
27 deletions
+29
-27
proxier_test.go
pkg/proxy/userspace/proxier_test.go
+29
-27
No files found.
pkg/proxy/userspace/proxier_test.go
View file @
e1df5c8b
...
@@ -536,15 +536,14 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
...
@@ -536,15 +536,14 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
func
TestTCPProxyUpdateDeleteUpdate
(
t
*
testing
.
T
)
{
func
TestTCPProxyUpdateDeleteUpdate
(
t
*
testing
.
T
)
{
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
service
:=
proxy
.
ServicePortName
{
NamespacedName
:
types
.
NamespacedName
{
Namespace
:
"testnamespace"
,
Name
:
"echo"
},
Port
:
"p"
}
service
:=
proxy
.
ServicePortName
{
NamespacedName
:
types
.
NamespacedName
{
Namespace
:
"testnamespace"
,
Name
:
"echo"
},
Port
:
"p"
}
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
:=
api
.
Endpoints
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
Subsets
:
[]
api
.
EndpointSubset
{{
Subsets
:
[]
api
.
EndpointSubset
{{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"127.0.0.1"
}},
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"127.0.0.1"
}},
Ports
:
[]
api
.
EndpointPort
{{
Name
:
"p"
,
Port
:
tcpServerPort
}},
Ports
:
[]
api
.
EndpointPort
{{
Name
:
"p"
,
Port
:
tcpServerPort
}},
}},
}},
}
},
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
})
})
p
,
err
:=
createProxier
(
lb
,
net
.
ParseIP
(
"0.0.0.0"
),
ipttest
.
NewFake
(),
net
.
ParseIP
(
"127.0.0.1"
),
nil
,
time
.
Minute
,
udpIdleTimeoutForTest
)
p
,
err
:=
createProxier
(
lb
,
net
.
ParseIP
(
"0.0.0.0"
),
ipttest
.
NewFake
(),
net
.
ParseIP
(
"127.0.0.1"
),
nil
,
time
.
Minute
,
udpIdleTimeoutForTest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -569,6 +568,8 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -569,6 +568,8 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
}
}
waitForNumProxyLoops
(
t
,
p
,
0
)
waitForNumProxyLoops
(
t
,
p
,
0
)
// need to add endpoint here because it got clean up during service delete
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
})
p
.
OnServiceUpdate
([]
api
.
Service
{{
p
.
OnServiceUpdate
([]
api
.
Service
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"1.2.3.4"
,
Ports
:
[]
api
.
ServicePort
{{
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"1.2.3.4"
,
Ports
:
[]
api
.
ServicePort
{{
...
@@ -588,15 +589,14 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -588,15 +589,14 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
func
TestUDPProxyUpdateDeleteUpdate
(
t
*
testing
.
T
)
{
func
TestUDPProxyUpdateDeleteUpdate
(
t
*
testing
.
T
)
{
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
service
:=
proxy
.
ServicePortName
{
NamespacedName
:
types
.
NamespacedName
{
Namespace
:
"testnamespace"
,
Name
:
"echo"
},
Port
:
"p"
}
service
:=
proxy
.
ServicePortName
{
NamespacedName
:
types
.
NamespacedName
{
Namespace
:
"testnamespace"
,
Name
:
"echo"
},
Port
:
"p"
}
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
:=
api
.
Endpoints
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
Subsets
:
[]
api
.
EndpointSubset
{{
Subsets
:
[]
api
.
EndpointSubset
{{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"127.0.0.1"
}},
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"127.0.0.1"
}},
Ports
:
[]
api
.
EndpointPort
{{
Name
:
"p"
,
Port
:
udpServerPort
}},
Ports
:
[]
api
.
EndpointPort
{{
Name
:
"p"
,
Port
:
udpServerPort
}},
}},
}},
}
},
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
})
})
p
,
err
:=
createProxier
(
lb
,
net
.
ParseIP
(
"0.0.0.0"
),
ipttest
.
NewFake
(),
net
.
ParseIP
(
"127.0.0.1"
),
nil
,
time
.
Minute
,
udpIdleTimeoutForTest
)
p
,
err
:=
createProxier
(
lb
,
net
.
ParseIP
(
"0.0.0.0"
),
ipttest
.
NewFake
(),
net
.
ParseIP
(
"127.0.0.1"
),
nil
,
time
.
Minute
,
udpIdleTimeoutForTest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -621,6 +621,8 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
...
@@ -621,6 +621,8 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
}
}
waitForNumProxyLoops
(
t
,
p
,
0
)
waitForNumProxyLoops
(
t
,
p
,
0
)
// need to add endpoint here because it got clean up during service delete
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
})
p
.
OnServiceUpdate
([]
api
.
Service
{{
p
.
OnServiceUpdate
([]
api
.
Service
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"1.2.3.4"
,
Ports
:
[]
api
.
ServicePort
{{
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"1.2.3.4"
,
Ports
:
[]
api
.
ServicePort
{{
...
@@ -785,15 +787,14 @@ func TestProxyUpdatePublicIPs(t *testing.T) {
...
@@ -785,15 +787,14 @@ func TestProxyUpdatePublicIPs(t *testing.T) {
func
TestProxyUpdatePortal
(
t
*
testing
.
T
)
{
func
TestProxyUpdatePortal
(
t
*
testing
.
T
)
{
lb
:=
NewLoadBalancerRR
()
lb
:=
NewLoadBalancerRR
()
service
:=
proxy
.
ServicePortName
{
NamespacedName
:
types
.
NamespacedName
{
Namespace
:
"testnamespace"
,
Name
:
"echo"
},
Port
:
"p"
}
service
:=
proxy
.
ServicePortName
{
NamespacedName
:
types
.
NamespacedName
{
Namespace
:
"testnamespace"
,
Name
:
"echo"
},
Port
:
"p"
}
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
:=
api
.
Endpoints
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
service
.
Name
,
Namespace
:
service
.
Namespace
},
Subsets
:
[]
api
.
EndpointSubset
{{
Subsets
:
[]
api
.
EndpointSubset
{{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"127.0.0.1"
}},
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"127.0.0.1"
}},
Ports
:
[]
api
.
EndpointPort
{{
Name
:
"p"
,
Port
:
tcpServerPort
}},
Ports
:
[]
api
.
EndpointPort
{{
Name
:
"p"
,
Port
:
tcpServerPort
}},
}},
}},
}
},
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
})
})
p
,
err
:=
createProxier
(
lb
,
net
.
ParseIP
(
"0.0.0.0"
),
ipttest
.
NewFake
(),
net
.
ParseIP
(
"127.0.0.1"
),
nil
,
time
.
Minute
,
udpIdleTimeoutForTest
)
p
,
err
:=
createProxier
(
lb
,
net
.
ParseIP
(
"0.0.0.0"
),
ipttest
.
NewFake
(),
net
.
ParseIP
(
"127.0.0.1"
),
nil
,
time
.
Minute
,
udpIdleTimeoutForTest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -842,6 +843,7 @@ func TestProxyUpdatePortal(t *testing.T) {
...
@@ -842,6 +843,7 @@ func TestProxyUpdatePortal(t *testing.T) {
Protocol
:
"TCP"
,
Protocol
:
"TCP"
,
}}},
}}},
}})
}})
lb
.
OnEndpointsUpdate
([]
api
.
Endpoints
{
endpoint
})
svcInfo
,
exists
=
p
.
getServiceInfo
(
service
)
svcInfo
,
exists
=
p
.
getServiceInfo
(
service
)
if
!
exists
{
if
!
exists
{
t
.
Fatalf
(
"service with ClusterIP set not found in the proxy"
)
t
.
Fatalf
(
"service with ClusterIP set not found in the proxy"
)
...
...
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