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
7b4e2552
Commit
7b4e2552
authored
May 31, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #26535 from mwielgus/e2e-scale-down
Automatic merge from submit-queue Enable cluster autoscaler scale down in e2e test cc: @piosz @jszczepkowski @fgrzadkowski
parents
dc8ff81f
2a03dfd5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
16 deletions
+79
-16
cluster_size_autoscaling.go
test/e2e/cluster_size_autoscaling.go
+79
-16
No files found.
test/e2e/cluster_size_autoscaling.go
View file @
7b4e2552
...
@@ -21,17 +21,23 @@ import (
...
@@ -21,17 +21,23 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
"github.com/golang/glog"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
const
(
const
(
scaleTimeout
=
5
*
time
.
Minute
defaultTimeout
=
3
*
time
.
Minute
resizeTimeout
=
5
*
time
.
Minute
scaleUpTimeout
=
5
*
time
.
Minute
scaleDownTimeout
=
15
*
time
.
Minute
)
)
var
_
=
framework
.
KubeDescribe
(
"Cluster size autoscaling [Feature:ClusterSizeAutoscaling] [Slow]"
,
func
()
{
var
_
=
framework
.
KubeDescribe
(
"Cluster size autoscaling
scale up
[Feature:ClusterSizeAutoscaling] [Slow]"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"autoscaling"
)
f
:=
framework
.
NewDefaultFramework
(
"autoscaling"
)
var
nodeCount
int
var
nodeCount
int
var
coresPerNode
int
var
coresPerNode
int
...
@@ -54,28 +60,58 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAut
...
@@ -54,28 +60,58 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Feature:ClusterSizeAut
ReserveMemory
(
f
,
"memory-reservation"
,
1
,
memCapacityMb
,
false
)
ReserveMemory
(
f
,
"memory-reservation"
,
1
,
memCapacityMb
,
false
)
// Verify, that cluster size is not changed.
// Verify, that cluster size is not changed.
// TODO: find a better way of verification that the cluster size will remain unchanged.
// TODO: find a better way of verification that the cluster size will remain unchanged.
time
.
Sleep
(
scaleTimeout
)
time
.
Sleep
(
scaleUpTimeout
)
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
scaleTimeout
))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
scaleUpTimeout
))
framework
.
ExpectNoError
(
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"memory-reservation"
))
framework
.
ExpectNoError
(
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"memory-reservation"
))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
scaleTimeout
))
framework
.
ExpectNoError
(
ResizeGroup
(
int32
(
nodeCount
)))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
resizeTimeout
))
By
(
"Small pending pods increase cluster size"
)
By
(
"Small pending pods increase cluster size"
)
ReserveMemory
(
f
,
"memory-reservation"
,
100
,
nodeCount
*
memCapacityMb
,
false
)
ReserveMemory
(
f
,
"memory-reservation"
,
100
,
nodeCount
*
memCapacityMb
,
false
)
// Verify, that cluster size is increased
// Verify, that cluster size is increased
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
+
1
,
scaleTimeout
))
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
Client
,
func
(
size
int
)
bool
{
return
size
>=
nodeCount
+
1
},
scaleUpTimeout
))
framework
.
ExpectNoError
(
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"memory-reservation"
))
framework
.
ExpectNoError
(
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"memory-reservation"
))
// TODO(jsz): Disable the line bellow when scale down is implemented.
framework
.
ExpectNoError
(
ResizeGroup
(
int32
(
nodeCount
)))
framework
.
ExpectNoError
(
ResizeGroup
(
int32
(
nodeCount
)))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
scal
eTimeout
))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
resiz
eTimeout
))
By
(
"Handling node port pods"
)
By
(
"Handling node port pods"
)
CreateHostPortPods
(
f
,
"host-port"
,
nodeCount
+
2
,
false
)
CreateHostPortPods
(
f
,
"host-port"
,
nodeCount
+
2
,
false
)
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
+
2
,
scaleTimeout
))
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
Client
,
framework
.
ExpectNoError
(
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"host-port"
))
func
(
size
int
)
bool
{
return
size
>=
nodeCount
+
2
},
scaleUpTimeout
))
// TODO(jsz): Disable the line bellow when scale down is implemented.
framework
.
ExpectNoError
(
ResizeGroup
(
int32
(
nodeCount
)))
framework
.
ExpectNoError
(
ResizeGroup
(
int32
(
nodeCount
)))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
scaleTimeout
))
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
f
.
Client
,
nodeCount
,
resizeTimeout
))
})
})
var
_
=
framework
.
KubeDescribe
(
"Cluster size autoscaling scale down[Feature:ClusterSizeAutoscalingScaleDown] [Slow]"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"autoscaling"
)
var
nodeCount
int
var
coresPerNode
int
var
memCapacityMb
int
BeforeEach
(
func
()
{
framework
.
SkipUnlessProviderIs
(
"gce"
)
nodes
:=
framework
.
GetReadySchedulableNodesOrDie
(
f
.
Client
)
nodeCount
=
len
(
nodes
.
Items
)
Expect
(
nodeCount
)
.
NotTo
(
BeZero
())
cpu
:=
nodes
.
Items
[
0
]
.
Status
.
Capacity
[
api
.
ResourceCPU
]
mem
:=
nodes
.
Items
[
0
]
.
Status
.
Capacity
[
api
.
ResourceMemory
]
coresPerNode
=
int
((
&
cpu
)
.
MilliValue
()
/
1000
)
memCapacityMb
=
int
((
&
mem
)
.
Value
()
/
1024
/
1024
)
})
It
(
"Should correctly handle pending and scale down after deletion"
,
func
()
{
By
(
"Small pending pods increase cluster size"
)
ReserveMemory
(
f
,
"memory-reservation"
,
100
,
nodeCount
*
memCapacityMb
,
false
)
// Verify, that cluster size is increased
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
Client
,
func
(
size
int
)
bool
{
return
size
>=
nodeCount
+
1
},
scaleUpTimeout
))
framework
.
ExpectNoError
(
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"memory-reservation"
))
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
Client
,
func
(
size
int
)
bool
{
return
size
<
nodeCount
+
1
},
scaleDownTimeout
))
})
})
})
})
...
@@ -85,7 +121,7 @@ func CreateHostPortPods(f *framework.Framework, id string, replicas int, expectR
...
@@ -85,7 +121,7 @@ func CreateHostPortPods(f *framework.Framework, id string, replicas int, expectR
Client
:
f
.
Client
,
Client
:
f
.
Client
,
Name
:
id
,
Name
:
id
,
Namespace
:
f
.
Namespace
.
Name
,
Namespace
:
f
.
Namespace
.
Name
,
Timeout
:
scale
Timeout
,
Timeout
:
default
Timeout
,
Image
:
framework
.
GetPauseImageName
(
f
.
Client
),
Image
:
framework
.
GetPauseImageName
(
f
.
Client
),
Replicas
:
replicas
,
Replicas
:
replicas
,
HostPorts
:
map
[
string
]
int
{
"port1"
:
4321
},
HostPorts
:
map
[
string
]
int
{
"port1"
:
4321
},
...
@@ -104,7 +140,7 @@ func ReserveCpu(f *framework.Framework, id string, replicas, millicores int) {
...
@@ -104,7 +140,7 @@ func ReserveCpu(f *framework.Framework, id string, replicas, millicores int) {
Client
:
f
.
Client
,
Client
:
f
.
Client
,
Name
:
id
,
Name
:
id
,
Namespace
:
f
.
Namespace
.
Name
,
Namespace
:
f
.
Namespace
.
Name
,
Timeout
:
scale
Timeout
,
Timeout
:
default
Timeout
,
Image
:
framework
.
GetPauseImageName
(
f
.
Client
),
Image
:
framework
.
GetPauseImageName
(
f
.
Client
),
Replicas
:
replicas
,
Replicas
:
replicas
,
CpuRequest
:
request
,
CpuRequest
:
request
,
...
@@ -119,7 +155,7 @@ func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, e
...
@@ -119,7 +155,7 @@ func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, e
Client
:
f
.
Client
,
Client
:
f
.
Client
,
Name
:
id
,
Name
:
id
,
Namespace
:
f
.
Namespace
.
Name
,
Namespace
:
f
.
Namespace
.
Name
,
Timeout
:
scale
Timeout
,
Timeout
:
default
Timeout
,
Image
:
framework
.
GetPauseImageName
(
f
.
Client
),
Image
:
framework
.
GetPauseImageName
(
f
.
Client
),
Replicas
:
replicas
,
Replicas
:
replicas
,
MemRequest
:
request
,
MemRequest
:
request
,
...
@@ -129,3 +165,30 @@ func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, e
...
@@ -129,3 +165,30 @@ func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, e
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
}
}
}
}
// WaitForClusterSize waits until the cluster size matches the given function.
func
WaitForClusterSizeFunc
(
c
*
client
.
Client
,
sizeFunc
func
(
int
)
bool
,
timeout
time
.
Duration
)
error
{
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
20
*
time
.
Second
)
{
nodes
,
err
:=
c
.
Nodes
()
.
List
(
api
.
ListOptions
{
FieldSelector
:
fields
.
Set
{
"spec.unschedulable"
:
"false"
,
}
.
AsSelector
()})
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to list nodes: %v"
,
err
)
continue
}
numNodes
:=
len
(
nodes
.
Items
)
// Filter out not-ready nodes.
framework
.
FilterNodes
(
nodes
,
func
(
node
api
.
Node
)
bool
{
return
framework
.
IsNodeConditionSetAsExpected
(
&
node
,
api
.
NodeReady
,
true
)
})
numReady
:=
len
(
nodes
.
Items
)
if
numNodes
==
numReady
&&
sizeFunc
(
numReady
)
{
glog
.
Infof
(
"Cluster has reached the desired size"
)
return
nil
}
glog
.
Infof
(
"Waiting for cluster, current size %d, not ready nodes %d"
,
numNodes
,
numNodes
-
numReady
)
}
return
fmt
.
Errorf
(
"timeout waiting %v for appropriate cluster size"
,
timeout
)
}
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