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
13f7b317
Commit
13f7b317
authored
Feb 03, 2017
by
tanshanshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test for scheduler
parent
9b12e372
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
BUILD
plugin/pkg/scheduler/algorithmprovider/defaults/BUILD
+4
-1
defaults.go
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
+2
-1
defaults_test.go
...pkg/scheduler/algorithmprovider/defaults/defaults_test.go
+62
-0
No files found.
plugin/pkg/scheduler/algorithmprovider/defaults/BUILD
View file @
13f7b317
...
@@ -28,7 +28,10 @@ go_library(
...
@@ -28,7 +28,10 @@ go_library(
go_test(
go_test(
name = "go_default_test",
name = "go_default_test",
srcs = ["compatibility_test.go"],
srcs = [
"compatibility_test.go",
"defaults_test.go",
],
library = ":go_default_library",
library = ":go_default_library",
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
...
...
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
13f7b317
...
@@ -41,6 +41,7 @@ const (
...
@@ -41,6 +41,7 @@ const (
DefaultMaxAzureDiskVolumes
=
16
DefaultMaxAzureDiskVolumes
=
16
ClusterAutoscalerProvider
=
"ClusterAutoscalerProvider"
ClusterAutoscalerProvider
=
"ClusterAutoscalerProvider"
StatefulSetKind
=
"StatefulSet"
StatefulSetKind
=
"StatefulSet"
KubeMaxPDVols
=
"KUBE_MAX_PD_VOLS"
)
)
func
init
()
{
func
init
()
{
...
@@ -217,7 +218,7 @@ func defaultPriorities() sets.String {
...
@@ -217,7 +218,7 @@ func defaultPriorities() sets.String {
// getMaxVols checks the max PD volumes environment variable, otherwise returning a default value
// getMaxVols checks the max PD volumes environment variable, otherwise returning a default value
func
getMaxVols
(
defaultVal
int
)
int
{
func
getMaxVols
(
defaultVal
int
)
int
{
if
rawMaxVols
:=
os
.
Getenv
(
"KUBE_MAX_PD_VOLS"
);
rawMaxVols
!=
""
{
if
rawMaxVols
:=
os
.
Getenv
(
KubeMaxPDVols
);
rawMaxVols
!=
""
{
if
parsedMaxVols
,
err
:=
strconv
.
Atoi
(
rawMaxVols
);
err
!=
nil
{
if
parsedMaxVols
,
err
:=
strconv
.
Atoi
(
rawMaxVols
);
err
!=
nil
{
glog
.
Errorf
(
"Unable to parse maxiumum PD volumes value, using default of %v: %v"
,
defaultVal
,
err
)
glog
.
Errorf
(
"Unable to parse maxiumum PD volumes value, using default of %v: %v"
,
defaultVal
,
err
)
}
else
if
parsedMaxVols
<=
0
{
}
else
if
parsedMaxVols
<=
0
{
...
...
plugin/pkg/scheduler/algorithmprovider/defaults/defaults_test.go
0 → 100644
View file @
13f7b317
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
defaults
import
(
"os"
"testing"
)
func
TestGetMaxVols
(
t
*
testing
.
T
)
{
previousValue
:=
os
.
Getenv
(
KubeMaxPDVols
)
defaultValue
:=
39
tests
:=
[]
struct
{
rawMaxVols
string
expected
int
test
string
}{
{
rawMaxVols
:
"invalid"
,
expected
:
defaultValue
,
test
:
"Unable to parse maxiumum PD volumes value, using default value"
,
},
{
rawMaxVols
:
"-2"
,
expected
:
defaultValue
,
test
:
"Maximum PD volumes must be a positive value, using default value"
,
},
{
rawMaxVols
:
"40"
,
expected
:
40
,
test
:
"Parse maximum PD volumes value from env"
,
},
}
for
_
,
test
:=
range
tests
{
os
.
Setenv
(
KubeMaxPDVols
,
test
.
rawMaxVols
)
result
:=
getMaxVols
(
defaultValue
)
if
result
!=
test
.
expected
{
t
.
Errorf
(
"%s: expected %v got %v"
,
test
.
test
,
test
.
expected
,
result
)
}
}
os
.
Unsetenv
(
KubeMaxPDVols
)
if
previousValue
!=
""
{
os
.
Setenv
(
KubeMaxPDVols
,
previousValue
)
}
}
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