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
34d848eb
Commit
34d848eb
authored
May 26, 2018
by
liangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cni bandwidth test
parent
8038a0df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
cni_test.go
pkg/kubelet/dockershim/network/cni/cni_test.go
+13
-2
No files found.
pkg/kubelet/dockershim/network/cni/cni_test.go
View file @
34d848eb
...
...
@@ -61,7 +61,7 @@ func installPluginUnderTest(t *testing.T, testBinDir, testConfDir, testDataDir,
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to install plugin %s: %v"
,
confFile
,
err
)
}
networkConfig
:=
fmt
.
Sprintf
(
`{ "name": "%s", "type": "%s", "capabilities": {"portMappings": true} }`
,
confName
,
binName
)
networkConfig
:=
fmt
.
Sprintf
(
`{ "name": "%s", "type": "%s", "capabilities": {"portMappings": true
, "bandwidth": true
} }`
,
confName
,
binName
)
_
,
err
=
f
.
WriteString
(
networkConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to write network config file (%v)"
,
err
)
...
...
@@ -236,8 +236,12 @@ func TestCNIPlugin(t *testing.T) {
t
.
Fatalf
(
"Failed to select the desired plugin: %v"
,
err
)
}
bandwidthAnnotation
:=
make
(
map
[
string
]
string
)
bandwidthAnnotation
[
"kubernetes.io/ingress-bandwidth"
]
=
"1M"
bandwidthAnnotation
[
"kubernetes.io/egress-bandwidth"
]
=
"1M"
// Set up the pod
err
=
plug
.
SetUpPod
(
"podNamespace"
,
"podName"
,
containerID
,
map
[
string
]
string
{}
)
err
=
plug
.
SetUpPod
(
"podNamespace"
,
"podName"
,
containerID
,
bandwidthAnnotation
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected nil: %v"
,
err
)
}
...
...
@@ -255,6 +259,7 @@ func TestCNIPlugin(t *testing.T) {
// Verify the correct network configuration was passed
inputConfig
:=
struct
{
RuntimeConfig
struct
{
Bandwidth
map
[
string
]
interface
{}
`json:"bandwidth"`
PortMappings
[]
map
[
string
]
interface
{}
`json:"portMappings"`
}
`json:"runtimeConfig"`
}{}
...
...
@@ -270,6 +275,12 @@ func TestCNIPlugin(t *testing.T) {
if
!
reflect
.
DeepEqual
(
inputConfig
.
RuntimeConfig
.
PortMappings
,
expectedMappings
)
{
t
.
Errorf
(
"mismatch in expected port mappings. expected %v got %v"
,
expectedMappings
,
inputConfig
.
RuntimeConfig
.
PortMappings
)
}
expectedBandwidth
:=
map
[
string
]
interface
{}{
"ingressRate"
:
1000.0
,
"egressRate"
:
1000.0
,
}
if
!
reflect
.
DeepEqual
(
inputConfig
.
RuntimeConfig
.
Bandwidth
,
expectedBandwidth
)
{
t
.
Errorf
(
"mismatch in expected bandwidth. expected %v got %v"
,
expectedBandwidth
,
inputConfig
.
RuntimeConfig
.
Bandwidth
)
}
// Get its IP address
status
,
err
:=
plug
.
GetPodNetworkStatus
(
"podNamespace"
,
"podName"
,
containerID
)
...
...
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