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
c12f4978
Commit
c12f4978
authored
Jun 01, 2017
by
Andrzej Wasylkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made WaitForReplicas and EnsureDesiredReplicas use PollImmediate and improved logging.
parent
30b3472f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
autoscaling_utils.go
test/e2e/common/autoscaling_utils.go
+23
-17
util.go
test/e2e/framework/util.go
+2
-2
No files found.
test/e2e/common/autoscaling_utils.go
View file @
c12f4978
...
@@ -332,27 +332,33 @@ func (rc *ResourceConsumer) GetReplicas() int {
...
@@ -332,27 +332,33 @@ func (rc *ResourceConsumer) GetReplicas() int {
}
}
func
(
rc
*
ResourceConsumer
)
WaitForReplicas
(
desiredReplicas
int
)
{
func
(
rc
*
ResourceConsumer
)
WaitForReplicas
(
desiredReplicas
int
)
{
timeout
:=
15
*
time
.
Minute
duration
:=
15
*
time
.
Minute
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
20
*
time
.
Second
)
{
interval
:=
20
*
time
.
Second
if
desiredReplicas
==
rc
.
GetReplicas
()
{
err
:=
wait
.
PollImmediate
(
interval
,
duration
,
func
()
(
bool
,
error
)
{
framework
.
Logf
(
"%s: current replicas number is equal to desired replicas number: %d"
,
rc
.
kind
,
desiredReplicas
)
replicas
:=
rc
.
GetReplicas
()
return
framework
.
Logf
(
"waiting for %d replicas (current: %d)"
,
desiredReplicas
,
replicas
)
}
else
{
return
replicas
==
desiredReplicas
,
nil
// Expected number of replicas found. Exit.
framework
.
Logf
(
"%s: current replicas number %d waiting to be %d"
,
rc
.
kind
,
rc
.
GetReplicas
(),
desiredReplicas
)
})
}
framework
.
ExpectNoErrorWithOffset
(
1
,
err
,
"timeout waiting %v for %d replicas"
,
duration
,
desiredReplicas
)
}
framework
.
Failf
(
"timeout waiting %v for pods size to be %d"
,
timeout
,
desiredReplicas
)
}
}
func
(
rc
*
ResourceConsumer
)
EnsureDesiredReplicas
(
desiredReplicas
int
,
timeout
time
.
Duration
)
{
func
(
rc
*
ResourceConsumer
)
EnsureDesiredReplicas
(
desiredReplicas
int
,
duration
time
.
Duration
)
{
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
10
*
time
.
Second
)
{
interval
:=
10
*
time
.
Second
actual
:=
rc
.
GetReplicas
()
err
:=
wait
.
PollImmediate
(
interval
,
duration
,
func
()
(
bool
,
error
)
{
if
desiredReplicas
!=
actual
{
replicas
:=
rc
.
GetReplicas
()
framework
.
Failf
(
"Number of replicas has changed: expected %v, got %v"
,
desiredReplicas
,
actual
)
framework
.
Logf
(
"expecting there to be %d replicas (are: %d)"
,
desiredReplicas
,
replicas
)
if
replicas
!=
desiredReplicas
{
return
false
,
fmt
.
Errorf
(
"number of replicas changed unexpectedly"
)
}
else
{
return
false
,
nil
// Expected number of replicas found. Continue polling until timeout.
}
}
framework
.
Logf
(
"Number of replicas is as expected"
)
})
// The call above always returns an error, but if it is timeout, it's OK (condition satisfied all the time).
if
err
==
wait
.
ErrWaitTimeout
{
framework
.
Logf
(
"Number of replicas was stable over %v"
,
duration
)
return
}
}
framework
.
Logf
(
"Number of replicas was stable over %v"
,
timeout
)
framework
.
ExpectNoErrorWithOffset
(
1
,
err
)
}
}
// Pause stops background goroutines responsible for consuming resources.
// Pause stops background goroutines responsible for consuming resources.
...
...
test/e2e/framework/util.go
View file @
c12f4978
...
@@ -294,7 +294,7 @@ func Failf(format string, args ...interface{}) {
...
@@ -294,7 +294,7 @@ func Failf(format string, args ...interface{}) {
func
FailfWithOffset
(
offset
int
,
format
string
,
args
...
interface
{})
{
func
FailfWithOffset
(
offset
int
,
format
string
,
args
...
interface
{})
{
msg
:=
fmt
.
Sprintf
(
format
,
args
...
)
msg
:=
fmt
.
Sprintf
(
format
,
args
...
)
log
(
"INFO"
,
msg
)
log
(
"INFO"
,
msg
)
Fail
(
nowStamp
()
+
": "
+
msg
,
1
+
offset
)
Fail
(
nowStamp
()
+
": "
+
msg
,
1
+
offset
)
}
}
func
Skipf
(
format
string
,
args
...
interface
{})
{
func
Skipf
(
format
string
,
args
...
interface
{})
{
...
@@ -1932,7 +1932,7 @@ func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) {
...
@@ -1932,7 +1932,7 @@ func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) {
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Unexpected error occurred: %v"
,
err
)
Logf
(
"Unexpected error occurred: %v"
,
err
)
}
}
ExpectWithOffset
(
1
+
offset
,
err
)
.
NotTo
(
HaveOccurred
(),
explain
...
)
ExpectWithOffset
(
1
+
offset
,
err
)
.
NotTo
(
HaveOccurred
(),
explain
...
)
}
}
func
ExpectNoErrorWithRetries
(
fn
func
()
error
,
maxRetries
int
,
explain
...
interface
{})
{
func
ExpectNoErrorWithRetries
(
fn
func
()
error
,
maxRetries
int
,
explain
...
interface
{})
{
...
...
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