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
98153fce
Commit
98153fce
authored
Dec 02, 2015
by
Jay Vyas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HPA: parameterize stasis, minReplicas, maxReplicas as struct.
parent
2fcf1575
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
21 deletions
+61
-21
horizontal_pod_autoscaling.go
test/e2e/horizontal_pod_autoscaling.go
+61
-21
No files found.
test/e2e/horizontal_pod_autoscaling.go
View file @
98153fce
...
@@ -26,10 +26,9 @@ import (
...
@@ -26,10 +26,9 @@ import (
)
)
const
(
const
(
kindRC
=
"replicationController"
kindRC
=
"replicationController"
kindDeployment
=
"deployment"
kindDeployment
=
"deployment"
subresource
=
"scale"
subresource
=
"scale"
stabilityTimeout
=
10
*
time
.
Minute
)
)
var
_
=
Describe
(
"Horizontal pod autoscaling (scale resource: CPU) [Skipped]"
,
func
()
{
var
_
=
Describe
(
"Horizontal pod autoscaling (scale resource: CPU) [Skipped]"
,
func
()
{
...
@@ -60,28 +59,69 @@ var _ = Describe("Horizontal pod autoscaling (scale resource: CPU) [Skipped]", f
...
@@ -60,28 +59,69 @@ var _ = Describe("Horizontal pod autoscaling (scale resource: CPU) [Skipped]", f
})
})
})
})
func
scaleUp
(
name
,
kind
string
,
rc
*
ResourceConsumer
,
f
*
Framework
)
{
// HPAScaleTest struct is used by the scale(...) function.
rc
=
NewDynamicResourceConsumer
(
name
,
kind
,
1
,
250
,
0
,
500
,
100
,
f
)
type
HPAScaleTest
struct
{
initPods
int
cpuStart
int
maxCPU
int64
idealCPU
int
minPods
int
maxPods
int
firstScale
int
firstScaleStasis
time
.
Duration
cpuBurst
int
secondScale
int
secondScaleStasis
time
.
Duration
}
// run is a method which runs an HPA lifecycle, from a starting state, to an expected
// The initial state is defined by the initPods parameter.
// The first state change is due to the CPU being consumed initially, which HPA responds to by changing pod counts.
// The second state change is due to the CPU burst parameter, which HPA again responds to.
// TODO The use of 3 states is arbitrary, we could eventually make this test handle "n" states once this test stabilizes.
func
(
scaleTest
*
HPAScaleTest
)
run
(
name
,
kind
string
,
rc
*
ResourceConsumer
,
f
*
Framework
)
{
rc
=
NewDynamicResourceConsumer
(
name
,
kind
,
scaleTest
.
initPods
,
scaleTest
.
cpuStart
,
0
,
scaleTest
.
maxCPU
,
100
,
f
)
defer
rc
.
CleanUp
()
defer
rc
.
CleanUp
()
createCPUHorizontalPodAutoscaler
(
rc
,
20
)
createCPUHorizontalPodAutoscaler
(
rc
,
scaleTest
.
idealCPU
,
scaleTest
.
minPods
,
scaleTest
.
maxPods
)
rc
.
WaitForReplicas
(
3
)
rc
.
WaitForReplicas
(
scaleTest
.
firstScale
)
rc
.
EnsureDesiredReplicas
(
3
,
stabilityTimeout
)
rc
.
EnsureDesiredReplicas
(
scaleTest
.
firstScale
,
scaleTest
.
firstScaleStasis
)
rc
.
ConsumeCPU
(
700
)
rc
.
ConsumeCPU
(
scaleTest
.
cpuBurst
)
rc
.
WaitForReplicas
(
5
)
rc
.
WaitForReplicas
(
scaleTest
.
secondScale
)
}
func
scaleUp
(
name
,
kind
string
,
rc
*
ResourceConsumer
,
f
*
Framework
)
{
scaleTest
:=
&
HPAScaleTest
{
initPods
:
1
,
cpuStart
:
250
,
maxCPU
:
500
,
idealCPU
:
.2
*
100
,
minPods
:
1
,
maxPods
:
5
,
firstScale
:
3
,
firstScaleStasis
:
10
*
time
.
Minute
,
cpuBurst
:
700
,
secondScale
:
5
,
}
scaleTest
.
run
(
name
,
kind
,
rc
,
f
)
}
}
func
scaleDown
(
name
,
kind
string
,
rc
*
ResourceConsumer
,
f
*
Framework
)
{
func
scaleDown
(
name
,
kind
string
,
rc
*
ResourceConsumer
,
f
*
Framework
)
{
rc
=
NewDynamicResourceConsumer
(
name
,
kind
,
5
,
400
,
0
,
500
,
100
,
f
)
scaleTest
:=
&
HPAScaleTest
{
defer
rc
.
CleanUp
()
initPods
:
5
,
createCPUHorizontalPodAutoscaler
(
rc
,
30
)
cpuStart
:
400
,
rc
.
WaitForReplicas
(
3
)
maxCPU
:
500
,
rc
.
EnsureDesiredReplicas
(
3
,
stabilityTimeout
)
idealCPU
:
.3
*
100
,
rc
.
ConsumeCPU
(
100
)
minPods
:
1
,
rc
.
WaitForReplicas
(
1
)
maxPods
:
5
,
firstScale
:
3
,
firstScaleStasis
:
10
*
time
.
Minute
,
cpuBurst
:
100
,
secondScale
:
1
,
}
scaleTest
.
run
(
name
,
kind
,
rc
,
f
)
}
}
func
createCPUHorizontalPodAutoscaler
(
rc
*
ResourceConsumer
,
cpu
int
)
{
func
createCPUHorizontalPodAutoscaler
(
rc
*
ResourceConsumer
,
cpu
,
minReplicas
,
maxRepl
int
)
{
minReplicas
:=
1
hpa
:=
&
extensions
.
HorizontalPodAutoscaler
{
hpa
:=
&
extensions
.
HorizontalPodAutoscaler
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
rc
.
name
,
Name
:
rc
.
name
,
...
@@ -94,7 +134,7 @@ func createCPUHorizontalPodAutoscaler(rc *ResourceConsumer, cpu int) {
...
@@ -94,7 +134,7 @@ func createCPUHorizontalPodAutoscaler(rc *ResourceConsumer, cpu int) {
Subresource
:
subresource
,
Subresource
:
subresource
,
},
},
MinReplicas
:
&
minReplicas
,
MinReplicas
:
&
minReplicas
,
MaxReplicas
:
5
,
MaxReplicas
:
maxRepl
,
CPUUtilization
:
&
extensions
.
CPUTargetUtilization
{
TargetPercentage
:
cpu
},
CPUUtilization
:
&
extensions
.
CPUTargetUtilization
{
TargetPercentage
:
cpu
},
},
},
}
}
...
...
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