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
0b10c6cf
Commit
0b10c6cf
authored
Aug 21, 2015
by
Daniel Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing test in probe/http
The error that Go 1.5 returns is different compared to 1.4. Support both.
parent
5f3aff2c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
6 deletions
+34
-6
http_test.go
pkg/probe/http/http_test.go
+34
-6
No files found.
pkg/probe/http/http_test.go
View file @
0b10c6cf
...
...
@@ -29,6 +29,15 @@ import (
"k8s.io/kubernetes/pkg/probe"
)
func
containsAny
(
s
string
,
substrs
[]
string
)
bool
{
for
_
,
substr
:=
range
substrs
{
if
strings
.
Contains
(
s
,
substr
)
{
return
true
}
}
return
false
}
func
TestHTTPProbeChecker
(
t
*
testing
.
T
)
{
handleReq
:=
func
(
s
int
,
body
string
)
func
(
w
http
.
ResponseWriter
)
{
return
func
(
w
http
.
ResponseWriter
)
{
...
...
@@ -41,12 +50,31 @@ func TestHTTPProbeChecker(t *testing.T) {
testCases
:=
[]
struct
{
handler
func
(
w
http
.
ResponseWriter
)
health
probe
.
Result
body
string
// go1.5: error message changed for timeout, need to support
// both old and new
accBodies
[]
string
}{
// The probe will be filled in below. This is primarily testing that an HTTP GET happens.
{
handleReq
(
http
.
StatusOK
,
"ok body"
),
probe
.
Success
,
"ok body"
},
{
handleReq
(
-
1
,
"fail body"
),
probe
.
Failure
,
"fail body"
},
{
func
(
w
http
.
ResponseWriter
)
{
time
.
Sleep
(
3
*
time
.
Second
)
},
probe
.
Failure
,
"use of closed network connection"
},
{
handleReq
(
http
.
StatusOK
,
"ok body"
),
probe
.
Success
,
[]
string
{
"ok body"
},
},
{
handleReq
(
-
1
,
"fail body"
),
probe
.
Failure
,
[]
string
{
"fail body"
},
},
{
func
(
w
http
.
ResponseWriter
)
{
time
.
Sleep
(
3
*
time
.
Second
)
},
probe
.
Failure
,
[]
string
{
"use of closed network connection"
,
"request canceled (Client.Timeout exceeded while awaiting headers)"
,
},
},
}
for
_
,
test
:=
range
testCases
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
@@ -74,8 +102,8 @@ func TestHTTPProbeChecker(t *testing.T) {
if
health
!=
test
.
health
{
t
.
Errorf
(
"Expected %v, got %v"
,
test
.
health
,
health
)
}
if
!
strings
.
Contains
(
output
,
test
.
body
)
{
t
.
Errorf
(
"Expected
%v, got %v"
,
test
.
body
,
output
)
if
!
containsAny
(
output
,
test
.
accBodies
)
{
t
.
Errorf
(
"Expected
one of %#v, got %v"
,
test
.
accBodies
,
output
)
}
}
}
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