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
06424676
Commit
06424676
authored
Jun 08, 2017
by
Aleksandra Malinowska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add e2e test for scale down to 1
parent
038d1947
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
cluster_size_autoscaling.go
test/e2e/autoscaling/cluster_size_autoscaling.go
+20
-13
No files found.
test/e2e/autoscaling/cluster_size_autoscaling.go
View file @
06424676
...
...
@@ -392,7 +392,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})
It
(
"should be able to scale down when rescheduling a pod is required and pdb allows for it[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
1
,
1
,
func
(
increasedSize
int
)
{
runDrainTest
(
f
,
originalSizes
,
f
.
Namespace
.
Name
,
1
,
1
,
func
(
increasedSize
int
)
{
By
(
"Some node should be removed"
)
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
ClientSet
,
func
(
size
int
)
bool
{
return
size
<
increasedSize
},
scaleDownTimeout
))
...
...
@@ -400,7 +400,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})
It
(
"shouldn't be able to scale down when rescheduling a pod is required, but pdb doesn't allow drain[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
1
,
0
,
func
(
increasedSize
int
)
{
runDrainTest
(
f
,
originalSizes
,
f
.
Namespace
.
Name
,
1
,
0
,
func
(
increasedSize
int
)
{
By
(
"No nodes should be removed"
)
time
.
Sleep
(
scaleDownTimeout
)
nodes
:=
framework
.
GetReadySchedulableNodesOrDie
(
f
.
ClientSet
)
...
...
@@ -409,7 +409,15 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})
It
(
"should be able to scale down by draining multiple pods one by one as dictated by pdb[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
2
,
1
,
func
(
increasedSize
int
)
{
runDrainTest
(
f
,
originalSizes
,
f
.
Namespace
.
Name
,
2
,
1
,
func
(
increasedSize
int
)
{
By
(
"Some node should be removed"
)
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
ClientSet
,
func
(
size
int
)
bool
{
return
size
<
increasedSize
},
scaleDownTimeout
))
})
})
It
(
"should be able to scale down by draining system pods with pdb[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
"kube-system"
,
2
,
1
,
func
(
increasedSize
int
)
{
By
(
"Some node should be removed"
)
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
ClientSet
,
func
(
size
int
)
bool
{
return
size
<
increasedSize
},
scaleDownTimeout
))
...
...
@@ -465,20 +473,19 @@ func execCmd(args ...string) *exec.Cmd {
return
exec
.
Command
(
args
[
0
],
args
[
1
:
]
...
)
}
func
runDrainTest
(
f
*
framework
.
Framework
,
migSizes
map
[
string
]
int
,
podsPerNode
,
pdbSize
int
,
verifyFunction
func
(
int
))
{
func
runDrainTest
(
f
*
framework
.
Framework
,
migSizes
map
[
string
]
int
,
namespace
string
,
podsPerNode
,
pdbSize
int
,
verifyFunction
func
(
int
))
{
increasedSize
:=
manuallyIncreaseClusterSize
(
f
,
migSizes
)
nodes
,
err
:=
f
.
ClientSet
.
Core
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Set
{
"spec.unschedulable"
:
"false"
,
}
.
AsSelector
()
.
String
()})
framework
.
ExpectNoError
(
err
)
namespace
:=
f
.
Namespace
.
Name
numPods
:=
len
(
nodes
.
Items
)
*
podsPerNode
testId
:=
string
(
uuid
.
NewUUID
())
// So that we can label and find pods
labelMap
:=
map
[
string
]
string
{
"test_id"
:
testId
}
framework
.
ExpectNoError
(
runReplicatedPodOnEachNode
(
f
,
nodes
.
Items
,
podsPerNode
,
"reschedulable-pods"
,
labelMap
))
framework
.
ExpectNoError
(
runReplicatedPodOnEachNode
(
f
,
nodes
.
Items
,
namespace
,
podsPerNode
,
"reschedulable-pods"
,
labelMap
))
defer
framework
.
DeleteRCAndPods
(
f
.
ClientSet
,
f
.
InternalClientset
,
f
.
Namespace
.
Nam
e
,
"reschedulable-pods"
)
defer
framework
.
DeleteRCAndPods
(
f
.
ClientSet
,
f
.
InternalClientset
,
namespac
e
,
"reschedulable-pods"
)
By
(
"Create a PodDisruptionBudget"
)
minAvailable
:=
intstr
.
FromInt
(
numPods
-
pdbSize
)
...
...
@@ -871,7 +878,7 @@ func makeNodeSchedulable(c clientset.Interface, node *v1.Node) error {
// 3. for each node:
// 3a. enable scheduling on that node
// 3b. increase number of replicas in RC by podsPerNode
func
runReplicatedPodOnEachNode
(
f
*
framework
.
Framework
,
nodes
[]
v1
.
Node
,
podsPerNode
int
,
id
string
,
labels
map
[
string
]
string
)
error
{
func
runReplicatedPodOnEachNode
(
f
*
framework
.
Framework
,
nodes
[]
v1
.
Node
,
namespace
string
,
podsPerNode
int
,
id
string
,
labels
map
[
string
]
string
)
error
{
By
(
"Run a pod on each node"
)
for
_
,
node
:=
range
nodes
{
err
:=
makeNodeUnschedulable
(
f
.
ClientSet
,
&
node
)
...
...
@@ -888,7 +895,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, podsPer
Client
:
f
.
ClientSet
,
InternalClient
:
f
.
InternalClientset
,
Name
:
id
,
Namespace
:
f
.
Namespace
.
Nam
e
,
Namespace
:
namespac
e
,
Timeout
:
defaultTimeout
,
Image
:
framework
.
GetPauseImageName
(
f
.
ClientSet
),
Replicas
:
0
,
...
...
@@ -898,7 +905,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, podsPer
if
err
!=
nil
{
return
err
}
rc
,
err
:=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Nam
e
)
.
Get
(
id
,
metav1
.
GetOptions
{})
rc
,
err
:=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
namespac
e
)
.
Get
(
id
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
err
}
...
...
@@ -912,7 +919,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, podsPer
// (we retry 409 errors in case rc reference got out of sync)
for
j
:=
0
;
j
<
3
;
j
++
{
*
rc
.
Spec
.
Replicas
=
int32
((
i
+
1
)
*
podsPerNode
)
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Nam
e
)
.
Update
(
rc
)
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
namespac
e
)
.
Update
(
rc
)
if
err
==
nil
{
break
}
...
...
@@ -920,14 +927,14 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, podsPer
return
err
}
glog
.
Warningf
(
"Got 409 conflict when trying to scale RC, retries left: %v"
,
3
-
j
)
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Nam
e
)
.
Get
(
id
,
metav1
.
GetOptions
{})
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
namespac
e
)
.
Get
(
id
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
err
}
}
err
=
wait
.
PollImmediate
(
5
*
time
.
Second
,
podTimeout
,
func
()
(
bool
,
error
)
{
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Nam
e
)
.
Get
(
id
,
metav1
.
GetOptions
{})
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
namespac
e
)
.
Get
(
id
,
metav1
.
GetOptions
{})
if
err
!=
nil
||
rc
.
Status
.
ReadyReplicas
<
int32
((
i
+
1
)
*
podsPerNode
)
{
return
false
,
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