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
36f94fab
Commit
36f94fab
authored
Aug 14, 2015
by
Jerzy Szczepkowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12719 from piosz/autoscaling_e2e
Enabled Autoscaling e2e test for cpu utilization
parents
7296a5bd
fb44d5e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
8 deletions
+53
-8
e2e.sh
hack/jenkins/e2e.sh
+7
-0
autoscaling.go
test/e2e/autoscaling.go
+46
-8
No files found.
hack/jenkins/e2e.sh
View file @
36f94fab
...
@@ -102,6 +102,7 @@ GCE_FLAKY_TESTS=(
...
@@ -102,6 +102,7 @@ GCE_FLAKY_TESTS=(
# Tests which are not able to be run in parallel.
# Tests which are not able to be run in parallel.
GCE_PARALLEL_SKIP_TESTS
=(
GCE_PARALLEL_SKIP_TESTS
=(
${
GCE_DEFAULT_SKIP_TESTS
[@]
:+
${
GCE_DEFAULT_SKIP_TESTS
[@]
}}
${
GCE_DEFAULT_SKIP_TESTS
[@]
:+
${
GCE_DEFAULT_SKIP_TESTS
[@]
}}
"Autoscaling"
"Etcd"
"Etcd"
"NetworkingNew"
"NetworkingNew"
"Nodes
\s
Network"
"Nodes
\s
Network"
...
@@ -127,6 +128,7 @@ GCE_PARALLEL_FLAKY_TESTS=(
...
@@ -127,6 +128,7 @@ GCE_PARALLEL_FLAKY_TESTS=(
# Tests that should not run on soak cluster.
# Tests that should not run on soak cluster.
GCE_SOAK_CONTINUOUS_SKIP_TESTS
=(
GCE_SOAK_CONTINUOUS_SKIP_TESTS
=(
"Autoscaling"
"Density.*30
\s
pods"
"Density.*30
\s
pods"
"Elasticsearch"
"Elasticsearch"
"Etcd.*SIGKILL"
"Etcd.*SIGKILL"
...
@@ -141,6 +143,10 @@ GCE_SOAK_CONTINUOUS_SKIP_TESTS=(
...
@@ -141,6 +143,10 @@ GCE_SOAK_CONTINUOUS_SKIP_TESTS=(
"Skipped"
"Skipped"
)
)
GCE_RELEASE_SKIP_TESTS
=(
"Autoscaling"
)
# Define environment variables based on the Jenkins project name.
# Define environment variables based on the Jenkins project name.
case
${
JOB_NAME
}
in
case
${
JOB_NAME
}
in
# Runs all non-flaky tests on GCE, sequentially.
# Runs all non-flaky tests on GCE, sequentially.
...
@@ -283,6 +289,7 @@ case ${JOB_NAME} in
...
@@ -283,6 +289,7 @@ case ${JOB_NAME} in
:
${
E2E_NETWORK
:
=
"e2e-gce-release"
}
:
${
E2E_NETWORK
:
=
"e2e-gce-release"
}
:
${
GINKGO_TEST_ARGS
:
=
"--ginkgo.skip=
$(
join_regex_allow_empty
\
:
${
GINKGO_TEST_ARGS
:
=
"--ginkgo.skip=
$(
join_regex_allow_empty
\
${
GCE_DEFAULT_SKIP_TESTS
[@]
:+
${
GCE_DEFAULT_SKIP_TESTS
[@]
}}
\
${
GCE_DEFAULT_SKIP_TESTS
[@]
:+
${
GCE_DEFAULT_SKIP_TESTS
[@]
}}
\
${
GCE_RELEASE_SKIP_TESTS
[@]
:+
${
GCE_RELEASE_SKIP_TESTS
[@]
}}
\
${
GCE_FLAKY_TESTS
[@]
:+
${
GCE_FLAKY_TESTS
[@]
}}
\
${
GCE_FLAKY_TESTS
[@]
:+
${
GCE_FLAKY_TESTS
[@]
}}
\
)
"
}
)
"
}
:
${
KUBE_GCE_INSTANCE_PREFIX
=
"e2e-gce"
}
:
${
KUBE_GCE_INSTANCE_PREFIX
=
"e2e-gce"
}
...
...
test/e2e/autoscaling.go
View file @
36f94fab
...
@@ -21,29 +21,43 @@ import (
...
@@ -21,29 +21,43 @@ import (
"os/exec"
"os/exec"
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
)
var
_
=
Describe
(
"Autoscaling"
,
func
()
{
var
_
=
Describe
(
"Autoscaling"
,
func
()
{
f
:=
NewFramework
(
"autoscaling"
)
f
:=
NewFramework
(
"autoscaling"
)
var
nodeCount
int
var
coresPerNode
int
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
// Ensure cluster size is equal to 1.
SkipUnlessProviderIs
(
"gce"
)
expectNoError
(
waitForClusterSize
(
f
.
Client
,
1
))
nodes
,
err
:=
f
.
Client
.
Nodes
()
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
nodeCount
=
len
(
nodes
.
Items
)
Expect
(
nodeCount
)
.
NotTo
(
BeZero
())
res
:=
nodes
.
Items
[
0
]
.
Status
.
Capacity
[
api
.
ResourceCPU
]
coresPerNode
=
int
((
&
res
)
.
MilliValue
()
/
1000
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
cleanUpAutoscaler
()
cleanUpAutoscaler
()
})
})
It
(
"[
Skipped] [
Autoscaling] should scale cluster size based on cpu utilization"
,
func
()
{
It
(
"[Autoscaling] should scale cluster size based on cpu utilization"
,
func
()
{
setUpAutoscaler
(
"cpu/node_utilization"
,
0.
8
,
1
,
10
)
setUpAutoscaler
(
"cpu/node_utilization"
,
0.
7
,
nodeCount
,
nodeCount
+
1
)
ConsumeCpu
(
f
,
"cpu-utilization"
,
1
)
ConsumeCpu
(
f
,
"cpu-utilization"
,
nodeCount
*
coresPerNode
)
expectNoError
(
waitForClusterSize
(
f
.
Client
,
2
))
expectNoError
(
waitForClusterSize
(
f
.
Client
,
nodeCount
+
1
))
StopConsuming
(
f
,
"cpu-utilization"
)
StopConsuming
(
f
,
"cpu-utilization"
)
expectNoError
(
waitForClusterSize
(
f
.
Client
,
1
))
expectNoError
(
waitForClusterSize
(
f
.
Client
,
nodeCount
))
})
})
It
(
"[Skipped] [Autoscaling] should scale cluster size based on cpu reservation"
,
func
()
{
It
(
"[Skipped] [Autoscaling] should scale cluster size based on cpu reservation"
,
func
()
{
...
@@ -77,7 +91,7 @@ var _ = Describe("Autoscaling", func() {
...
@@ -77,7 +91,7 @@ var _ = Describe("Autoscaling", func() {
})
})
})
})
func
setUpAutoscaler
(
metric
string
,
target
float64
,
min
,
max
int
64
)
{
func
setUpAutoscaler
(
metric
string
,
target
float64
,
min
,
max
int
)
{
// TODO integrate with kube-up.sh script once it will support autoscaler setup.
// TODO integrate with kube-up.sh script once it will support autoscaler setup.
By
(
"Setting up autoscaler to scale based on "
+
metric
)
By
(
"Setting up autoscaler to scale based on "
+
metric
)
_
,
err
:=
exec
.
Command
(
"gcloud"
,
"preview"
,
"autoscaler"
,
_
,
err
:=
exec
.
Command
(
"gcloud"
,
"preview"
,
"autoscaler"
,
...
@@ -100,7 +114,28 @@ func cleanUpAutoscaler() {
...
@@ -100,7 +114,28 @@ func cleanUpAutoscaler() {
expectNoError
(
err
)
expectNoError
(
err
)
}
}
func
CreateService
(
f
*
Framework
,
name
string
)
{
By
(
"Running sevice"
+
name
)
service
:=
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
},
Spec
:
api
.
ServiceSpec
{
Selector
:
map
[
string
]
string
{
"name"
:
name
,
},
Ports
:
[]
api
.
ServicePort
{{
Port
:
8080
,
TargetPort
:
util
.
NewIntOrStringFromInt
(
8080
),
}},
},
}
_
,
err
:=
f
.
Client
.
Services
(
f
.
Namespace
.
Name
)
.
Create
(
service
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
func
ConsumeCpu
(
f
*
Framework
,
id
string
,
cores
int
)
{
func
ConsumeCpu
(
f
*
Framework
,
id
string
,
cores
int
)
{
CreateService
(
f
,
id
)
By
(
fmt
.
Sprintf
(
"Running RC which consumes %v cores"
,
cores
))
By
(
fmt
.
Sprintf
(
"Running RC which consumes %v cores"
,
cores
))
config
:=
&
RCConfig
{
config
:=
&
RCConfig
{
Client
:
f
.
Client
,
Client
:
f
.
Client
,
...
@@ -157,6 +192,9 @@ func ReserveMemory(f *Framework, id string, gigabytes int) {
...
@@ -157,6 +192,9 @@ func ReserveMemory(f *Framework, id string, gigabytes int) {
}
}
func
StopConsuming
(
f
*
Framework
,
id
string
)
{
func
StopConsuming
(
f
*
Framework
,
id
string
)
{
By
(
"Stopping service "
+
id
)
err
:=
f
.
Client
.
Services
(
f
.
Namespace
.
Name
)
.
Delete
(
id
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Stopping RC "
+
id
)
By
(
"Stopping RC "
+
id
)
expectNoError
(
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
id
))
expectNoError
(
DeleteRC
(
f
.
Client
,
f
.
Namespace
.
Name
,
id
))
}
}
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