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
c9f5eea1
Commit
c9f5eea1
authored
Jun 29, 2016
by
Marcin Wielgus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
E2e test for disabling cluster autoscaler in GKE
parent
1a1a4709
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
38 deletions
+83
-38
cluster_size_autoscaling.go
test/e2e/cluster_size_autoscaling.go
+83
-38
No files found.
test/e2e/cluster_size_autoscaling.go
View file @
c9f5eea1
...
...
@@ -137,25 +137,8 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
By
(
"Creating new node-pool with one n1-standard-4 machine"
)
const
extraPoolName
=
"extra-pool"
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"node-pools"
,
"create"
,
extraPoolName
,
"--quiet"
,
"--machine-type=n1-standard-4"
,
"--num-nodes=1"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
,
"--cluster="
+
framework
.
TestContext
.
CloudConfig
.
Cluster
)
.
CombinedOutput
()
defer
func
()
{
glog
.
Infof
(
"Deleting node pool %s"
,
extraPoolName
)
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"node-pools"
,
"delete"
,
extraPoolName
,
"--quiet"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
,
"--cluster="
+
framework
.
TestContext
.
CloudConfig
.
Cluster
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
Infof
(
"Error: %v"
,
err
)
}
glog
.
Infof
(
"Node-pool deletion output: %s"
,
output
)
}()
framework
.
ExpectNoError
(
err
)
glog
.
Infof
(
"Creating node-pool: %s"
,
output
)
addNodePool
(
extraPoolName
,
"n1-standard-4"
)
defer
deleteNodePool
(
extraPoolName
)
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
c
,
nodeCount
+
1
,
resizeTimeout
))
glog
.
Infof
(
"Not enabling cluster autoscaler for the node pool (on purpose)."
)
...
...
@@ -168,6 +151,18 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
framework
.
ExpectNoError
(
waitForAllCaPodsReadyInNamespace
(
f
,
c
))
})
It
(
"should disable node pool autoscaling [Feature:ClusterSizeAutoscalingScaleUp]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"gke"
)
By
(
"Creating new node-pool with one n1-standard-4 machine"
)
const
extraPoolName
=
"extra-pool"
addNodePool
(
extraPoolName
,
"n1-standard-4"
)
defer
deleteNodePool
(
extraPoolName
)
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
c
,
nodeCount
+
1
,
resizeTimeout
))
framework
.
ExpectNoError
(
enableAutoscaler
(
extraPoolName
,
1
,
2
))
framework
.
ExpectNoError
(
disableAutoscaler
(
extraPoolName
,
1
,
2
))
})
It
(
"should increase cluster size if pods are pending due to host port conflict [Feature:ClusterSizeAutoscalingScaleUp]"
,
func
()
{
CreateHostPortPods
(
f
,
"host-port"
,
nodeCount
+
2
,
false
)
defer
framework
.
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
"host-port"
)
...
...
@@ -230,25 +225,8 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
By
(
"Creating new node-pool with one n1-standard-4 machine"
)
const
extraPoolName
=
"extra-pool"
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"node-pools"
,
"create"
,
extraPoolName
,
"--quiet"
,
"--machine-type=n1-standard-4"
,
"--num-nodes=1"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
,
"--cluster="
+
framework
.
TestContext
.
CloudConfig
.
Cluster
)
.
CombinedOutput
()
defer
func
()
{
glog
.
Infof
(
"Deleting node pool %s"
,
extraPoolName
)
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"node-pools"
,
"delete"
,
extraPoolName
,
"--quiet"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
,
"--cluster="
+
framework
.
TestContext
.
CloudConfig
.
Cluster
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
Infof
(
"Error: %v"
,
err
)
}
glog
.
Infof
(
"Node-pool deletion output: %s"
,
output
)
}()
framework
.
ExpectNoError
(
err
)
glog
.
Infof
(
"Creating node-pool: %s"
,
output
)
addNodePool
(
extraPoolName
,
"n1-standard-4"
)
defer
deleteNodePool
(
extraPoolName
)
framework
.
ExpectNoError
(
framework
.
WaitForClusterSize
(
c
,
nodeCount
+
1
,
resizeTimeout
))
framework
.
ExpectNoError
(
enableAutoscaler
(
extraPoolName
,
1
,
2
))
...
...
@@ -356,6 +334,73 @@ func enableAutoscaler(nodePool string, minCount, maxCount int) error {
return
fmt
.
Errorf
(
"autoscaler not enabled"
)
}
func
disableAutoscaler
(
nodePool
string
,
minCount
,
maxCount
int
)
error
{
if
nodePool
==
"default-pool"
{
glog
.
Infof
(
"Using gcloud to disable autoscaling for pool %s"
,
nodePool
)
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"clusters"
,
"update"
,
framework
.
TestContext
.
CloudConfig
.
Cluster
,
"--no-enable-autoscaling"
,
"--node-pool="
+
nodePool
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
)
.
Output
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to enable autoscaling: %v"
,
err
)
}
glog
.
Infof
(
"Config update result: %s"
,
output
)
}
else
{
glog
.
Infof
(
"Using direct api access to disable autoscaling for pool %s"
,
nodePool
)
updateRequest
:=
"{"
+
"
\"
update
\"
: {"
+
"
\"
desiredNodePoolId
\"
:
\"
"
+
nodePool
+
"
\"
,"
+
"
\"
desiredNodePoolAutoscaling
\"
: {"
+
"
\"
enabled
\"
:
\"
false
\"
,"
+
" }"
+
" }"
+
"}"
url
:=
getGKEClusterUrl
()
glog
.
Infof
(
"Using gke api url %s"
,
url
)
putResult
,
err
:=
doPut
(
url
,
updateRequest
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to put %s: %v"
,
url
,
err
)
}
glog
.
Infof
(
"Config update result: %s"
,
putResult
)
}
for
startTime
:=
time
.
Now
();
startTime
.
Add
(
gkeUpdateTimeout
)
.
After
(
time
.
Now
());
time
.
Sleep
(
30
*
time
.
Second
)
{
if
val
,
err
:=
isAutoscalerEnabled
(
minCount
);
err
==
nil
&&
!
val
{
return
nil
}
}
return
fmt
.
Errorf
(
"autoscaler still enabled"
)
}
func
addNodePool
(
name
string
,
machineType
string
)
{
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"node-pools"
,
"create"
,
name
,
"--quiet"
,
"--machine-type="
+
machineType
,
"--num-nodes=1"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
,
"--cluster="
+
framework
.
TestContext
.
CloudConfig
.
Cluster
)
.
CombinedOutput
()
framework
.
ExpectNoError
(
err
)
glog
.
Infof
(
"Creating node-pool %s: %s"
,
name
,
output
)
}
func
deleteNodePool
(
name
string
)
{
glog
.
Infof
(
"Deleting node pool %s"
,
name
)
output
,
err
:=
exec
.
Command
(
"gcloud"
,
"alpha"
,
"container"
,
"node-pools"
,
"delete"
,
name
,
"--quiet"
,
"--project="
+
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
"--zone="
+
framework
.
TestContext
.
CloudConfig
.
Zone
,
"--cluster="
+
framework
.
TestContext
.
CloudConfig
.
Cluster
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
Infof
(
"Error: %v"
,
err
)
}
glog
.
Infof
(
"Node-pool deletion output: %s"
,
output
)
}
func
doPut
(
url
,
content
string
)
(
string
,
error
)
{
req
,
err
:=
http
.
NewRequest
(
"PUT"
,
url
,
bytes
.
NewBuffer
([]
byte
(
content
)))
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
...
...
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