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
ada74893
Commit
ada74893
authored
Oct 01, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce timeouts in e2e tests by polling before sleeping
parent
6421ae97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
service.go
test/e2e/service.go
+2
-2
util.go
test/e2e/util.go
+13
-13
No files found.
test/e2e/service.go
View file @
ada74893
...
@@ -1151,7 +1151,7 @@ func testReachableInTime(ip string, port int, timeout time.Duration) bool {
...
@@ -1151,7 +1151,7 @@ func testReachableInTime(ip string, port int, timeout time.Duration) bool {
desc
:=
fmt
.
Sprintf
(
"the url %s to be reachable"
,
url
)
desc
:=
fmt
.
Sprintf
(
"the url %s to be reachable"
,
url
)
By
(
fmt
.
Sprintf
(
"Waiting up to %v for %s"
,
timeout
,
desc
))
By
(
fmt
.
Sprintf
(
"Waiting up to %v for %s"
,
timeout
,
desc
))
start
:=
time
.
Now
()
start
:=
time
.
Now
()
err
:=
wait
.
Poll
(
poll
,
timeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
poll
,
timeout
,
func
()
(
bool
,
error
)
{
resp
,
err
:=
httpGetNoConnectionPool
(
url
)
resp
,
err
:=
httpGetNoConnectionPool
(
url
)
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Got error waiting for reachability of %s: %v (%v)"
,
url
,
err
,
time
.
Since
(
start
))
Logf
(
"Got error waiting for reachability of %s: %v (%v)"
,
url
,
err
,
time
.
Since
(
start
))
...
@@ -1190,7 +1190,7 @@ func testNotReachable(ip string, port int) {
...
@@ -1190,7 +1190,7 @@ func testNotReachable(ip string, port int) {
desc
:=
fmt
.
Sprintf
(
"the url %s to be *not* reachable"
,
url
)
desc
:=
fmt
.
Sprintf
(
"the url %s to be *not* reachable"
,
url
)
By
(
fmt
.
Sprintf
(
"Waiting up to %v for %s"
,
podStartTimeout
,
desc
))
By
(
fmt
.
Sprintf
(
"Waiting up to %v for %s"
,
podStartTimeout
,
desc
))
err
:=
wait
.
Poll
(
poll
,
podStartTimeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
poll
,
podStartTimeout
,
func
()
(
bool
,
error
)
{
resp
,
err
:=
httpGetNoConnectionPool
(
url
)
resp
,
err
:=
httpGetNoConnectionPool
(
url
)
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Successfully waited for %s"
,
desc
)
Logf
(
"Successfully waited for %s"
,
desc
)
...
...
test/e2e/util.go
View file @
ada74893
...
@@ -66,7 +66,7 @@ const (
...
@@ -66,7 +66,7 @@ const (
nonExist
=
"NonExist"
nonExist
=
"NonExist"
// How often to poll pods and nodes.
// How often to poll pods and nodes.
poll
=
5
*
time
.
Second
poll
=
2
*
time
.
Second
// service accounts are provisioned after namespace creation
// service accounts are provisioned after namespace creation
// a service account is required to support pod creation in a namespace as part of admission control
// a service account is required to support pod creation in a namespace as part of admission control
...
@@ -331,7 +331,7 @@ func waitForPodsRunningReady(ns string, minPods int, timeout time.Duration) erro
...
@@ -331,7 +331,7 @@ func waitForPodsRunningReady(ns string, minPods int, timeout time.Duration) erro
start
:=
time
.
Now
()
start
:=
time
.
Now
()
Logf
(
"Waiting up to %v for all pods (need at least %d) in namespace '%s' to be running and ready"
,
Logf
(
"Waiting up to %v for all pods (need at least %d) in namespace '%s' to be running and ready"
,
timeout
,
minPods
,
ns
)
timeout
,
minPods
,
ns
)
if
wait
.
Poll
(
poll
,
timeout
,
func
()
(
bool
,
error
)
{
if
wait
.
Poll
Immediate
(
poll
,
timeout
,
func
()
(
bool
,
error
)
{
// We get the new list of pods and replication controllers in every
// We get the new list of pods and replication controllers in every
// iteration because more pods come online during startup and we want to
// iteration because more pods come online during startup and we want to
// ensure they are also checked.
// ensure they are also checked.
...
@@ -466,7 +466,7 @@ func createTestingNS(baseName string, c *client.Client) (*api.Namespace, error)
...
@@ -466,7 +466,7 @@ func createTestingNS(baseName string, c *client.Client) (*api.Namespace, error)
}
}
// Be robust about making the namespace creation call.
// Be robust about making the namespace creation call.
var
got
*
api
.
Namespace
var
got
*
api
.
Namespace
if
err
:=
wait
.
Poll
(
poll
,
singleCallTimeout
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
Poll
Immediate
(
poll
,
singleCallTimeout
,
func
()
(
bool
,
error
)
{
var
err
error
var
err
error
got
,
err
=
c
.
Namespaces
()
.
Create
(
namespaceObj
)
got
,
err
=
c
.
Namespaces
()
.
Create
(
namespaceObj
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -531,7 +531,7 @@ func deleteNS(c *client.Client, namespace string, timeout time.Duration) error {
...
@@ -531,7 +531,7 @@ func deleteNS(c *client.Client, namespace string, timeout time.Duration) error {
return
err
return
err
}
}
err
:=
wait
.
Poll
(
5
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
5
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
if
_
,
err
:=
c
.
Namespaces
()
.
Get
(
namespace
);
err
!=
nil
{
if
_
,
err
:=
c
.
Namespaces
()
.
Get
(
namespace
);
err
!=
nil
{
if
apierrs
.
IsNotFound
(
err
)
{
if
apierrs
.
IsNotFound
(
err
)
{
return
true
,
nil
return
true
,
nil
...
@@ -619,7 +619,7 @@ func waitForPodSuccessInNamespace(c *client.Client, podName string, contName str
...
@@ -619,7 +619,7 @@ func waitForPodSuccessInNamespace(c *client.Client, podName string, contName str
func
waitForRCPodOnNode
(
c
*
client
.
Client
,
ns
,
rcName
,
node
string
)
(
*
api
.
Pod
,
error
)
{
func
waitForRCPodOnNode
(
c
*
client
.
Client
,
ns
,
rcName
,
node
string
)
(
*
api
.
Pod
,
error
)
{
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
rcName
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
rcName
}))
var
p
*
api
.
Pod
=
nil
var
p
*
api
.
Pod
=
nil
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
5
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
10
*
time
.
Second
,
5
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
Logf
(
"Waiting for pod %s to appear on node %s"
,
rcName
,
node
)
Logf
(
"Waiting for pod %s to appear on node %s"
,
rcName
,
node
)
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
())
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -638,7 +638,7 @@ func waitForRCPodOnNode(c *client.Client, ns, rcName, node string) (*api.Pod, er
...
@@ -638,7 +638,7 @@ func waitForRCPodOnNode(c *client.Client, ns, rcName, node string) (*api.Pod, er
}
}
func
waitForPodToDisappear
(
c
*
client
.
Client
,
ns
,
podName
string
,
label
labels
.
Selector
,
interval
,
timeout
time
.
Duration
)
error
{
func
waitForPodToDisappear
(
c
*
client
.
Client
,
ns
,
podName
string
,
label
labels
.
Selector
,
interval
,
timeout
time
.
Duration
)
error
{
return
wait
.
Poll
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
return
wait
.
Poll
Immediate
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
Logf
(
"Waiting for pod %s to disappear"
,
podName
)
Logf
(
"Waiting for pod %s to disappear"
,
podName
)
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
())
pods
,
err
:=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -668,7 +668,7 @@ func waitForRCPodToDisappear(c *client.Client, ns, rcName, podName string) error
...
@@ -668,7 +668,7 @@ func waitForRCPodToDisappear(c *client.Client, ns, rcName, podName string) error
// waitForService waits until the service appears (exist == true), or disappears (exist == false)
// waitForService waits until the service appears (exist == true), or disappears (exist == false)
func
waitForService
(
c
*
client
.
Client
,
namespace
,
name
string
,
exist
bool
,
interval
,
timeout
time
.
Duration
)
error
{
func
waitForService
(
c
*
client
.
Client
,
namespace
,
name
string
,
exist
bool
,
interval
,
timeout
time
.
Duration
)
error
{
err
:=
wait
.
Poll
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
_
,
err
:=
c
.
Services
(
namespace
)
.
Get
(
name
)
_
,
err
:=
c
.
Services
(
namespace
)
.
Get
(
name
)
switch
{
switch
{
case
err
==
nil
:
case
err
==
nil
:
...
@@ -723,7 +723,7 @@ func countEndpointsNum(e *api.Endpoints) int {
...
@@ -723,7 +723,7 @@ func countEndpointsNum(e *api.Endpoints) int {
// waitForReplicationController waits until the RC appears (exist == true), or disappears (exist == false)
// waitForReplicationController waits until the RC appears (exist == true), or disappears (exist == false)
func
waitForReplicationController
(
c
*
client
.
Client
,
namespace
,
name
string
,
exist
bool
,
interval
,
timeout
time
.
Duration
)
error
{
func
waitForReplicationController
(
c
*
client
.
Client
,
namespace
,
name
string
,
exist
bool
,
interval
,
timeout
time
.
Duration
)
error
{
err
:=
wait
.
Poll
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
_
,
err
:=
c
.
ReplicationControllers
(
namespace
)
.
Get
(
name
)
_
,
err
:=
c
.
ReplicationControllers
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Get ReplicationController %s in namespace %s failed (%v)."
,
name
,
namespace
,
err
)
Logf
(
"Get ReplicationController %s in namespace %s failed (%v)."
,
name
,
namespace
,
err
)
...
@@ -818,13 +818,13 @@ func (r podResponseChecker) checkAllResponses() (done bool, err error) {
...
@@ -818,13 +818,13 @@ func (r podResponseChecker) checkAllResponses() (done bool, err error) {
func
podsResponding
(
c
*
client
.
Client
,
ns
,
name
string
,
wantName
bool
,
pods
*
api
.
PodList
)
error
{
func
podsResponding
(
c
*
client
.
Client
,
ns
,
name
string
,
wantName
bool
,
pods
*
api
.
PodList
)
error
{
By
(
"trying to dial each unique pod"
)
By
(
"trying to dial each unique pod"
)
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
name
}))
return
wait
.
Poll
(
poll
,
podRespondingTimeout
,
podResponseChecker
{
c
,
ns
,
label
,
name
,
wantName
,
pods
}
.
checkAllResponses
)
return
wait
.
Poll
Immediate
(
poll
,
podRespondingTimeout
,
podResponseChecker
{
c
,
ns
,
label
,
name
,
wantName
,
pods
}
.
checkAllResponses
)
}
}
func
serviceResponding
(
c
*
client
.
Client
,
ns
,
name
string
)
error
{
func
serviceResponding
(
c
*
client
.
Client
,
ns
,
name
string
)
error
{
By
(
fmt
.
Sprintf
(
"trying to dial the service %s.%s via the proxy"
,
ns
,
name
))
By
(
fmt
.
Sprintf
(
"trying to dial the service %s.%s via the proxy"
,
ns
,
name
))
return
wait
.
Poll
(
poll
,
serviceRespondingTimeout
,
func
()
(
done
bool
,
err
error
)
{
return
wait
.
Poll
Immediate
(
poll
,
serviceRespondingTimeout
,
func
()
(
done
bool
,
err
error
)
{
body
,
err
:=
c
.
Get
()
.
body
,
err
:=
c
.
Get
()
.
Prefix
(
"proxy"
)
.
Prefix
(
"proxy"
)
.
Namespace
(
ns
)
.
Namespace
(
ns
)
.
...
@@ -1569,7 +1569,7 @@ func DeleteRC(c *client.Client, ns, name string) error {
...
@@ -1569,7 +1569,7 @@ func DeleteRC(c *client.Client, ns, name string) error {
// waitForRCPodsGone waits until there are no pods reported under an RC's selector (because the pods
// waitForRCPodsGone waits until there are no pods reported under an RC's selector (because the pods
// have completed termination).
// have completed termination).
func
waitForRCPodsGone
(
c
*
client
.
Client
,
rc
*
api
.
ReplicationController
)
error
{
func
waitForRCPodsGone
(
c
*
client
.
Client
,
rc
*
api
.
ReplicationController
)
error
{
return
wait
.
Poll
(
poll
,
2
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
return
wait
.
Poll
Immediate
(
poll
,
2
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
if
pods
,
err
:=
c
.
Pods
(
rc
.
Namespace
)
.
List
(
labels
.
SelectorFromSet
(
rc
.
Spec
.
Selector
),
fields
.
Everything
());
err
==
nil
&&
len
(
pods
.
Items
)
==
0
{
if
pods
,
err
:=
c
.
Pods
(
rc
.
Namespace
)
.
List
(
labels
.
SelectorFromSet
(
rc
.
Spec
.
Selector
),
fields
.
Everything
());
err
==
nil
&&
len
(
pods
.
Items
)
==
0
{
return
true
,
nil
return
true
,
nil
}
}
...
@@ -1630,7 +1630,7 @@ func waitForDeploymentStatus(c *client.Client, ns, deploymentName string, desire
...
@@ -1630,7 +1630,7 @@ func waitForDeploymentStatus(c *client.Client, ns, deploymentName string, desire
func
listNodes
(
c
*
client
.
Client
,
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NodeList
,
error
)
{
func
listNodes
(
c
*
client
.
Client
,
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NodeList
,
error
)
{
var
nodes
*
api
.
NodeList
var
nodes
*
api
.
NodeList
var
errLast
error
var
errLast
error
if
wait
.
Poll
(
poll
,
singleCallTimeout
,
func
()
(
bool
,
error
)
{
if
wait
.
Poll
Immediate
(
poll
,
singleCallTimeout
,
func
()
(
bool
,
error
)
{
nodes
,
errLast
=
c
.
Nodes
()
.
List
(
label
,
field
)
nodes
,
errLast
=
c
.
Nodes
()
.
List
(
label
,
field
)
return
errLast
==
nil
,
nil
return
errLast
==
nil
,
nil
})
!=
nil
{
})
!=
nil
{
...
@@ -1872,7 +1872,7 @@ func allNodesReady(c *client.Client, timeout time.Duration) error {
...
@@ -1872,7 +1872,7 @@ func allNodesReady(c *client.Client, timeout time.Duration) error {
Logf
(
"Waiting up to %v for all nodes to be ready"
,
timeout
)
Logf
(
"Waiting up to %v for all nodes to be ready"
,
timeout
)
var
notReady
[]
api
.
Node
var
notReady
[]
api
.
Node
err
:=
wait
.
Poll
(
poll
,
timeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
(
poll
,
timeout
,
func
()
(
bool
,
error
)
{
notReady
=
nil
notReady
=
nil
nodes
,
err
:=
c
.
Nodes
()
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
nodes
,
err
:=
c
.
Nodes
()
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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