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
226d97fa
Commit
226d97fa
authored
Sep 28, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14688 from brendandburns/fix3
Auto commit by PR queue bot
parents
c807bea0
c3a8dc04
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
handlers_test.go
pkg/apiserver/handlers_test.go
+14
-4
No files found.
pkg/apiserver/handlers_test.go
View file @
226d97fa
...
@@ -66,10 +66,17 @@ func TestMaxInFlight(t *testing.T) {
...
@@ -66,10 +66,17 @@ func TestMaxInFlight(t *testing.T) {
re
:=
regexp
.
MustCompile
(
"[.*
\\
/watch][^
\\
/proxy.*]"
)
re
:=
regexp
.
MustCompile
(
"[.*
\\
/watch][^
\\
/proxy.*]"
)
// Calls verifies that the server is actually blocked up before running the rest of the test
calls
:=
&
sync
.
WaitGroup
{}
calls
.
Add
(
Iterations
*
3
)
server
:=
httptest
.
NewServer
(
MaxInFlightLimit
(
sem
,
re
,
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
server
:=
httptest
.
NewServer
(
MaxInFlightLimit
(
sem
,
re
,
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
strings
.
Contains
(
r
.
URL
.
Path
,
"dontwait"
)
{
if
strings
.
Contains
(
r
.
URL
.
Path
,
"dontwait"
)
{
return
return
}
}
if
calls
!=
nil
{
calls
.
Done
()
}
block
.
Wait
()
block
.
Wait
()
})))
})))
defer
server
.
Close
()
defer
server
.
Close
()
...
@@ -81,6 +88,7 @@ func TestMaxInFlight(t *testing.T) {
...
@@ -81,6 +88,7 @@ func TestMaxInFlight(t *testing.T) {
expectHTTP
(
server
.
URL
+
"/foo/bar/watch"
,
http
.
StatusOK
,
t
)
expectHTTP
(
server
.
URL
+
"/foo/bar/watch"
,
http
.
StatusOK
,
t
)
}()
}()
}
}
for
i
:=
0
;
i
<
Iterations
;
i
++
{
for
i
:=
0
;
i
<
Iterations
;
i
++
{
// These should hang waiting on block...
// These should hang waiting on block...
go
func
()
{
go
func
()
{
...
@@ -95,15 +103,17 @@ func TestMaxInFlight(t *testing.T) {
...
@@ -95,15 +103,17 @@ func TestMaxInFlight(t *testing.T) {
expectHTTP
(
server
.
URL
,
http
.
StatusOK
,
t
)
expectHTTP
(
server
.
URL
,
http
.
StatusOK
,
t
)
}()
}()
}
}
// There's really no more elegant way to do this. I could use a WaitGroup, but even then
calls
.
Wait
()
// it'd still be racy.
calls
=
nil
time
.
Sleep
(
1
*
time
.
Second
)
expectHTTP
(
server
.
URL
+
"/dontwait/watch"
,
http
.
StatusOK
,
t
)
// Do this multiple times to show that it rate limit rejected requests don't block.
// Do this multiple times to show that it rate limit rejected requests don't block.
for
i
:=
0
;
i
<
2
;
i
++
{
for
i
:=
0
;
i
<
2
;
i
++
{
expectHTTP
(
server
.
URL
,
errors
.
StatusTooManyRequests
,
t
)
expectHTTP
(
server
.
URL
,
errors
.
StatusTooManyRequests
,
t
)
}
}
// Validate that non-accounted URLs still work
expectHTTP
(
server
.
URL
+
"/dontwait/watch"
,
http
.
StatusOK
,
t
)
block
.
Done
()
block
.
Done
()
// Show that we recover from being blocked up.
// Show that we recover from being blocked up.
...
...
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