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
fee83f65
Commit
fee83f65
authored
Jun 21, 2017
by
Jiaying Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test coverage for nvidiaGPUManager initialization
Part of #47750 ```release-note NONE ```
parent
33fc75e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
BUILD
pkg/kubelet/gpu/nvidia/BUILD
+1
-0
nvidia_gpu_manager_test.go
pkg/kubelet/gpu/nvidia/nvidia_gpu_manager_test.go
+31
-0
No files found.
pkg/kubelet/gpu/nvidia/BUILD
View file @
fee83f65
...
...
@@ -44,6 +44,7 @@ go_test(
library = ":go_default_library",
tags = ["automanaged"],
deps = [
"//pkg/kubelet/dockershim/libdocker:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
...
...
pkg/kubelet/gpu/nvidia/nvidia_gpu_manager_test.go
View file @
fee83f65
...
...
@@ -17,6 +17,8 @@ limitations under the License.
package
nvidia
import
(
"os"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
...
...
@@ -26,6 +28,7 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker"
)
type
testActivePodsLister
struct
{
...
...
@@ -60,6 +63,34 @@ func makeTestPod(numContainers, gpusPerContainer int) *v1.Pod {
return
pod
}
func
TestNewNvidiaGPUManager
(
t
*
testing
.
T
)
{
podLister
:=
&
testActivePodsLister
{}
// Expects nil GPUManager and an error with nil dockerClient.
testGpuManager1
,
err
:=
NewNvidiaGPUManager
(
podLister
,
nil
)
as
:=
assert
.
New
(
t
)
as
.
Nil
(
testGpuManager1
)
as
.
NotNil
(
err
)
// Expects a GPUManager to be created with non-nil dockerClient.
fakeDocker
:=
libdocker
.
NewFakeDockerClient
()
testGpuManager2
,
err
:=
NewNvidiaGPUManager
(
podLister
,
fakeDocker
)
as
.
NotNil
(
testGpuManager2
)
as
.
Nil
(
err
)
// Expects zero capacity without any GPUs.
gpuCapacity
:=
testGpuManager2
.
Capacity
()
as
.
Equal
(
len
(
gpuCapacity
),
1
)
rgpu
:=
gpuCapacity
[
v1
.
ResourceNvidiaGPU
]
as
.
Equal
(
rgpu
.
Value
(),
int64
(
0
))
err2
:=
testGpuManager2
.
Start
()
if
!
os
.
IsNotExist
(
err2
)
{
gpus
:=
reflect
.
ValueOf
(
testGpuManager2
)
.
Elem
()
.
FieldByName
(
"allGPUs"
)
.
Len
()
as
.
NotZero
(
gpus
)
}
}
func
TestMultiContainerPodGPUAllocation
(
t
*
testing
.
T
)
{
podLister
:=
&
testActivePodsLister
{}
...
...
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