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
b25d596a
Commit
b25d596a
authored
Jan 22, 2016
by
Zach Loafman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19630 from mikedanese/fix-test
test: make ValidateCount throw an error instead of a log
parents
7189db37
39c7ea57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
6 deletions
+32
-6
endpoints_controller_test.go
pkg/controller/endpoint/endpoints_controller_test.go
+30
-4
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+1
-1
fake_handler.go
pkg/util/testing/fake_handler.go
+1
-1
No files found.
pkg/controller/endpoint/endpoints_controller_test.go
View file @
b25d596a
...
@@ -168,15 +168,28 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) {
...
@@ -168,15 +168,28 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) {
// defer testServer.Close()
// defer testServer.Close()
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
testServer
.
URL
,
GroupVersion
:
testapi
.
Default
.
GroupVersion
()})
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
testServer
.
URL
,
GroupVersion
:
testapi
.
Default
.
GroupVersion
()})
endpoints
:=
NewEndpointController
(
client
,
controller
.
NoResyncPeriodFunc
)
endpoints
:=
NewEndpointController
(
client
,
controller
.
NoResyncPeriodFunc
)
addPods
(
endpoints
.
podStore
.
Store
,
ns
,
1
,
1
,
0
)
endpoints
.
serviceStore
.
Store
.
Add
(
&
api
.
Service
{
endpoints
.
serviceStore
.
Store
.
Add
(
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
ns
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
ns
},
Spec
:
api
.
ServiceSpec
{
Spec
:
api
.
ServiceSpec
{
Selector
:
map
[
string
]
string
{},
Selector
:
map
[
string
]
string
{},
Ports
:
[]
api
.
ServicePort
{{
Port
:
80
}},
Ports
:
[]
api
.
ServicePort
{{
Port
:
80
,
TargetPort
:
intstr
.
FromInt
(
8080
),
Protocol
:
"TCP"
}},
},
},
})
})
endpoints
.
syncService
(
ns
+
"/foo"
)
endpoints
.
syncService
(
ns
+
"/foo"
)
endpointsHandler
.
ValidateRequestCount
(
t
,
0
)
endpointsHandler
.
ValidateRequestCount
(
t
,
2
)
data
:=
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
&
api
.
Endpoints
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
ns
,
ResourceVersion
:
"1"
,
},
Subsets
:
[]
api
.
EndpointSubset
{{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"1.2.3.4"
,
TargetRef
:
&
api
.
ObjectReference
{
Kind
:
"Pod"
,
Name
:
"pod0"
,
Namespace
:
ns
}}},
Ports
:
[]
api
.
EndpointPort
{{
Port
:
8080
,
Protocol
:
"TCP"
}},
}},
})
endpointsHandler
.
ValidateRequest
(
t
,
testapi
.
Default
.
ResourcePath
(
"endpoints"
,
ns
,
"foo"
),
"PUT"
,
&
data
)
}
}
func
TestSyncEndpointsProtocolUDP
(
t
*
testing
.
T
)
{
func
TestSyncEndpointsProtocolUDP
(
t
*
testing
.
T
)
{
...
@@ -197,15 +210,28 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) {
...
@@ -197,15 +210,28 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) {
// defer testServer.Close()
// defer testServer.Close()
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
testServer
.
URL
,
GroupVersion
:
testapi
.
Default
.
GroupVersion
()})
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
testServer
.
URL
,
GroupVersion
:
testapi
.
Default
.
GroupVersion
()})
endpoints
:=
NewEndpointController
(
client
,
controller
.
NoResyncPeriodFunc
)
endpoints
:=
NewEndpointController
(
client
,
controller
.
NoResyncPeriodFunc
)
addPods
(
endpoints
.
podStore
.
Store
,
ns
,
1
,
1
,
0
)
endpoints
.
serviceStore
.
Store
.
Add
(
&
api
.
Service
{
endpoints
.
serviceStore
.
Store
.
Add
(
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
ns
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
ns
},
Spec
:
api
.
ServiceSpec
{
Spec
:
api
.
ServiceSpec
{
Selector
:
map
[
string
]
string
{},
Selector
:
map
[
string
]
string
{},
Ports
:
[]
api
.
ServicePort
{{
Port
:
80
}},
Ports
:
[]
api
.
ServicePort
{{
Port
:
80
,
TargetPort
:
intstr
.
FromInt
(
8080
),
Protocol
:
"UDP"
}},
},
},
})
})
endpoints
.
syncService
(
ns
+
"/foo"
)
endpoints
.
syncService
(
ns
+
"/foo"
)
endpointsHandler
.
ValidateRequestCount
(
t
,
0
)
endpointsHandler
.
ValidateRequestCount
(
t
,
2
)
data
:=
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
&
api
.
Endpoints
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
ns
,
ResourceVersion
:
"1"
,
},
Subsets
:
[]
api
.
EndpointSubset
{{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"1.2.3.4"
,
TargetRef
:
&
api
.
ObjectReference
{
Kind
:
"Pod"
,
Name
:
"pod0"
,
Namespace
:
ns
}}},
Ports
:
[]
api
.
EndpointPort
{{
Port
:
8080
,
Protocol
:
"UDP"
}},
}},
})
endpointsHandler
.
ValidateRequest
(
t
,
testapi
.
Default
.
ResourcePath
(
"endpoints"
,
ns
,
"foo"
),
"PUT"
,
&
data
)
}
}
func
TestSyncEndpointsItemsEmptySelectorSelectsAll
(
t
*
testing
.
T
)
{
func
TestSyncEndpointsItemsEmptySelectorSelectsAll
(
t
*
testing
.
T
)
{
...
...
pkg/controller/replication/replication_controller_test.go
View file @
b25d596a
...
@@ -295,7 +295,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) {
...
@@ -295,7 +295,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) {
// Setup a test server so we can lie about the current state of pods
// Setup a test server so we can lie about the current state of pods
fakeHandler
:=
utiltesting
.
FakeHandler
{
fakeHandler
:=
utiltesting
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
""
,
ResponseBody
:
"
{}
"
,
}
}
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
// TODO: Uncomment when fix #19254
// TODO: Uncomment when fix #19254
...
...
pkg/util/testing/fake_handler.go
View file @
b25d596a
...
@@ -79,7 +79,7 @@ func (f *FakeHandler) ValidateRequestCount(t TestInterface, count int) bool {
...
@@ -79,7 +79,7 @@ func (f *FakeHandler) ValidateRequestCount(t TestInterface, count int) bool {
defer
f
.
lock
.
Unlock
()
defer
f
.
lock
.
Unlock
()
if
f
.
requestCount
!=
count
{
if
f
.
requestCount
!=
count
{
ok
=
false
ok
=
false
t
.
Log
f
(
"Expected %d call, but got %d. Only the last call is recorded and checked."
,
count
,
f
.
requestCount
)
t
.
Error
f
(
"Expected %d call, but got %d. Only the last call is recorded and checked."
,
count
,
f
.
requestCount
)
}
}
f
.
hasBeenChecked
=
true
f
.
hasBeenChecked
=
true
return
ok
return
ok
...
...
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