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
7567f176
Commit
7567f176
authored
Aug 25, 2017
by
Balaji Subramaniam
Committed by
Connor Doyle
Aug 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added CPU manager unit tests (none policy)
parent
ff471913
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
143 additions
and
1 deletion
+143
-1
BUILD
pkg/kubelet/cm/cpumanager/BUILD
+21
-1
cpu_manager_test.go
pkg/kubelet/cm/cpumanager/cpu_manager_test.go
+0
-0
fake_cpu_manager.go
pkg/kubelet/cm/cpumanager/fake_cpu_manager.go
+58
-0
policy_none_test.go
pkg/kubelet/cm/cpumanager/policy_none_test.go
+64
-0
No files found.
pkg/kubelet/cm/cpumanager/BUILD
View file @
7567f176
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library"
, "go_test"
)
go_library(
name = "go_default_library",
srcs = [
"cpu_manager.go",
"fake_cpu_manager.go",
"policy.go",
"policy_none.go",
],
...
...
@@ -38,3 +39,22 @@ filegroup(
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = [
"cpu_manager_test.go",
"policy_none_test.go",
],
library = ":go_default_library",
deps = [
"//pkg/kubelet/apis/cri/v1alpha1/runtime:go_default_library",
"//pkg/kubelet/cm/cpumanager/state:go_default_library",
"//pkg/kubelet/cm/cpuset:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
],
)
pkg/kubelet/cm/cpumanager/cpu_manager_test.go
0 → 100644
View file @
7567f176
This diff is collapsed.
Click to expand it.
pkg/kubelet/cm/cpumanager/fake_cpu_manager.go
0 → 100644
View file @
7567f176
/*
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
cpumanager
import
(
"github.com/golang/glog"
"k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state"
"k8s.io/kubernetes/pkg/kubelet/status"
)
type
fakeManager
struct
{
state
state
.
State
}
func
(
m
*
fakeManager
)
Start
(
activePods
ActivePodsFunc
,
podStatusProvider
status
.
PodStatusProvider
,
containerRuntime
runtimeService
)
{
glog
.
Info
(
"[fake cpumanager] Start()"
)
}
func
(
m
*
fakeManager
)
Policy
()
Policy
{
glog
.
Info
(
"[fake cpumanager] Policy()"
)
return
NewNonePolicy
()
}
func
(
m
*
fakeManager
)
AddContainer
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
,
containerID
string
)
error
{
glog
.
Infof
(
"[fake cpumanager] AddContainer (pod: %s, container: %s, container id: %s)"
,
pod
.
Name
,
container
.
Name
,
containerID
)
return
nil
}
func
(
m
*
fakeManager
)
RemoveContainer
(
containerID
string
)
error
{
glog
.
Infof
(
"[fake cpumanager] RemoveContainer (container id: %s)"
,
containerID
)
return
nil
}
func
(
m
*
fakeManager
)
State
()
state
.
Reader
{
return
m
.
state
}
// NewFakeManager creates empty/fake cpu manager
func
NewFakeManager
()
Manager
{
return
&
fakeManager
{
state
:
state
.
NewMemoryState
(),
}
}
pkg/kubelet/cm/cpumanager/policy_none_test.go
0 → 100644
View file @
7567f176
/*
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
cpumanager
import
(
"testing"
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
)
func
TestNonePolicyName
(
t
*
testing
.
T
)
{
policy
:=
&
nonePolicy
{}
policyName
:=
policy
.
Name
()
if
policyName
!=
"none"
{
t
.
Errorf
(
"NonePolicy Name() error. expected: none, returned: %v"
,
policyName
)
}
}
func
TestNonePolicyAdd
(
t
*
testing
.
T
)
{
policy
:=
&
nonePolicy
{}
st
:=
&
mockState
{
assignments
:
map
[
string
]
cpuset
.
CPUSet
{},
defaultCPUSet
:
cpuset
.
NewCPUSet
(
1
,
2
,
3
,
4
,
5
,
6
,
7
),
}
testPod
:=
makePod
(
"1000m"
,
"1000m"
)
container
:=
&
testPod
.
Spec
.
Containers
[
0
]
err
:=
policy
.
AddContainer
(
st
,
testPod
,
container
,
"fakeID"
)
if
err
!=
nil
{
t
.
Errorf
(
"NonePolicy AddContainer() error. expected no error but got: %v"
,
err
)
}
}
func
TestNonePolicyRemove
(
t
*
testing
.
T
)
{
policy
:=
&
nonePolicy
{}
st
:=
&
mockState
{
assignments
:
map
[
string
]
cpuset
.
CPUSet
{},
defaultCPUSet
:
cpuset
.
NewCPUSet
(
1
,
2
,
3
,
4
,
5
,
6
,
7
),
}
err
:=
policy
.
RemoveContainer
(
st
,
"fakeID"
)
if
err
!=
nil
{
t
.
Errorf
(
"NonePolicy RemoveContainer() error. expected no error but got %v"
,
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