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
e7620e81
Commit
e7620e81
authored
May 15, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make TestGetServerGroupsWithTimeout more reliable
parent
bd0d0937
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
discovery_client_test.go
...g/src/k8s.io/client-go/discovery/discovery_client_test.go
+13
-7
No files found.
staging/src/k8s.io/client-go/discovery/discovery_client_test.go
View file @
e7620e81
...
@@ -136,20 +136,26 @@ func TestGetServerGroupsWithTimeout(t *testing.T) {
...
@@ -136,20 +136,26 @@ func TestGetServerGroupsWithTimeout(t *testing.T) {
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
// first we need to write headers, otherwise http client will complain about
// first we need to write headers, otherwise http client will complain about
// exceeding timeout awaiting headers, only after we can block the call
// exceeding timeout awaiting headers, only after we can block the call
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
Header
()
.
Set
(
"Connection"
,
"keep-alive"
)
if
wf
,
ok
:=
w
.
(
http
.
Flusher
);
ok
{
wf
.
Flush
()
}
<-
done
<-
done
}))
}))
defer
server
.
Close
()
defer
server
.
Close
()
defer
close
(
done
)
defer
close
(
done
)
tmp
:=
defaultTimeout
client
:=
NewDiscoveryClientForConfigOrDie
(
&
restclient
.
Config
{
Host
:
server
.
URL
,
Timeout
:
2
*
time
.
Second
})
defaultTimeout
=
2
*
time
.
Second
client
:=
NewDiscoveryClientForConfigOrDie
(
&
restclient
.
Config
{
Host
:
server
.
URL
})
_
,
err
:=
client
.
ServerGroups
()
_
,
err
:=
client
.
ServerGroups
()
if
err
==
nil
||
!
strings
.
Contains
(
err
.
Error
(),
"deadline"
)
{
// the error we're getting here is wrapped in errors.errorString which makes
// it impossible to unwrap and check it's attributes, so instead we're checking
// the textual output which is presenting http.httpError with timeout set to true
if
err
==
nil
{
t
.
Fatal
(
"missing error"
)
}
if
!
strings
.
Contains
(
err
.
Error
(),
"timeout:true"
)
&&
!
strings
.
Contains
(
err
.
Error
(),
"context.deadlineExceededError"
)
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
done
<-
true
defaultTimeout
=
tmp
}
}
func
TestGetServerResourcesWithV1Server
(
t
*
testing
.
T
)
{
func
TestGetServerResourcesWithV1Server
(
t
*
testing
.
T
)
{
...
...
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