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
ad5e57b0
Commit
ad5e57b0
authored
Apr 26, 2019
by
s-ito-ts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use framework.ExpectNoError() for e2e/autoscaling
parent
47c03403
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
27 deletions
+40
-27
dns_autoscaling.go
test/e2e/autoscaling/dns_autoscaling.go
+40
-27
No files found.
test/e2e/autoscaling/dns_autoscaling.go
View file @
ad5e57b0
...
...
@@ -60,10 +60,10 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
By
(
"Collecting original replicas count and DNS scaling params"
)
var
err
error
originDNSReplicasCount
,
err
=
getDNSReplicas
(
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
pcm
,
err
:=
fetchDNSScalingConfigMap
(
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
previousParams
=
pcm
.
Data
if
nodeCount
<=
500
{
...
...
@@ -100,28 +100,30 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
// Will take around 5 minutes to run on a 4 nodes cluster.
It
(
"[Serial] [Slow] kube-dns-autoscaler should scale kube-dns pods when cluster size changed"
,
func
()
{
numNodes
,
err
:=
framework
.
NumberOfRegisteredNodes
(
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Replace the dns autoscaling parameters with testing parameters"
)
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
packLinearParams
(
&
DNSParams_1
)))
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
defer
func
()
{
By
(
"Restoring initial dns autoscaling parameters"
)
Expect
(
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
previousParams
)))
.
NotTo
(
HaveOccurred
())
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
previousParams
))
framework
.
ExpectNoError
(
err
)
By
(
"Wait for number of running and ready kube-dns pods recover"
)
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
ClusterAddonLabelKey
:
DNSLabelName
}))
_
,
err
:=
framework
.
WaitForPodsWithLabelRunningReady
(
c
,
metav1
.
NamespaceSystem
,
label
,
originDNSReplicasCount
,
DNSdefaultTimeout
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
}()
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
:=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_1
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
originalSizes
:=
make
(
map
[
string
]
int
)
for
_
,
mig
:=
range
strings
.
Split
(
framework
.
TestContext
.
CloudConfig
.
NodeInstanceGroup
,
","
)
{
size
,
err
:=
framework
.
GroupSize
(
mig
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
fmt
.
Sprintf
(
"Initial size of %s: %d"
,
mig
,
size
))
originalSizes
[
mig
]
=
size
}
...
...
@@ -132,27 +134,32 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
increasedSizes
[
key
]
=
val
+
1
}
setMigSizes
(
increasedSizes
)
Expect
(
WaitForClusterSizeFunc
(
c
,
func
(
size
int
)
bool
{
return
size
==
numNodes
+
len
(
originalSizes
)
},
scaleUpTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
WaitForClusterSizeFunc
(
c
,
func
(
size
int
)
bool
{
return
size
==
numNodes
+
len
(
originalSizes
)
},
scaleUpTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_1
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"Replace the dns autoscaling parameters with another testing parameters"
)
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
packLinearParams
(
&
DNSParams_3
)))
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_3
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"Restoring cluster size"
)
setMigSizes
(
originalSizes
)
Expect
(
framework
.
WaitForReadyNodes
(
c
,
numNodes
,
scaleDownTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
framework
.
WaitForReadyNodes
(
c
,
numNodes
,
scaleDownTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for kube-dns scaled to expected number"
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
})
// TODO: Get rid of [DisabledForLargeClusters] tag when issue #55779 is fixed.
...
...
@@ -160,49 +167,55 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
By
(
"Replace the dns autoscaling parameters with testing parameters"
)
err
:=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
packLinearParams
(
&
DNSParams_1
)))
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
defer
func
()
{
By
(
"Restoring initial dns autoscaling parameters"
)
Expect
(
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
previousParams
)))
.
NotTo
(
HaveOccurred
())
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
previousParams
))
framework
.
ExpectNoError
(
err
)
}()
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
:=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_1
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"--- Scenario: should scale kube-dns based on changed parameters ---"
)
By
(
"Replace the dns autoscaling parameters with another testing parameters"
)
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
packLinearParams
(
&
DNSParams_3
)))
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_3
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"--- Scenario: should re-create scaling parameters with default value when parameters got deleted ---"
)
By
(
"Delete the ConfigMap for autoscaler"
)
err
=
deleteDNSScalingConfigMap
(
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for the ConfigMap got re-created"
)
_
,
err
=
waitForDNSConfigMapCreated
(
c
,
DNSdefaultTimeout
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Replace the dns autoscaling parameters with another testing parameters"
)
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
packLinearParams
(
&
DNSParams_2
)))
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_2
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
By
(
"--- Scenario: should recover after autoscaler pod got deleted ---"
)
By
(
"Delete the autoscaler pod for kube-dns"
)
Expect
(
deleteDNSAutoscalerPod
(
c
))
.
NotTo
(
HaveOccurred
())
err
=
deleteDNSAutoscalerPod
(
c
)
framework
.
ExpectNoError
(
err
)
By
(
"Replace the dns autoscaling parameters with another testing parameters"
)
err
=
updateDNSScalingConfigMap
(
c
,
packDNSScalingConfigMap
(
packLinearParams
(
&
DNSParams_1
)))
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
framework
.
ExpectNoError
(
err
)
By
(
"Wait for kube-dns scaled to expected number"
)
getExpectReplicasLinear
=
getExpectReplicasFuncLinear
(
c
,
&
DNSParams_1
)
Expect
(
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
))
.
NotTo
(
HaveOccurred
())
err
=
waitForDNSReplicasSatisfied
(
c
,
getExpectReplicasLinear
,
DNSdefaultTimeout
)
framework
.
ExpectNoError
(
err
)
})
})
...
...
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