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
d1e0e726
Commit
d1e0e726
authored
Apr 27, 2016
by
Paul Morie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce LOC in kubelet tests
parent
ae6dec63
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
82 deletions
+32
-82
docker_test.go
pkg/kubelet/dockertools/docker_test.go
+28
-54
kubelet_test.go
pkg/kubelet/kubelet_test.go
+0
-0
pod_workers_test.go
pkg/kubelet/pod_workers_test.go
+4
-28
No files found.
pkg/kubelet/dockertools/docker_test.go
View file @
d1e0e726
...
@@ -680,37 +680,29 @@ func TestFindContainersByPod(t *testing.T) {
...
@@ -680,37 +680,29 @@ func TestFindContainersByPod(t *testing.T) {
}
}
func
TestMakePortsAndBindings
(
t
*
testing
.
T
)
{
func
TestMakePortsAndBindings
(
t
*
testing
.
T
)
{
portMapping
:=
func
(
container
,
host
int
,
protocol
api
.
Protocol
,
ip
string
)
kubecontainer
.
PortMapping
{
return
kubecontainer
.
PortMapping
{
ContainerPort
:
container
,
HostPort
:
host
,
Protocol
:
protocol
,
HostIP
:
ip
,
}
}
portBinding
:=
func
(
port
,
ip
string
)
dockernat
.
PortBinding
{
return
dockernat
.
PortBinding
{
HostPort
:
port
,
HostIP
:
ip
,
}
}
ports
:=
[]
kubecontainer
.
PortMapping
{
ports
:=
[]
kubecontainer
.
PortMapping
{
{
portMapping
(
80
,
8080
,
""
,
"127.0.0.1"
),
ContainerPort
:
80
,
portMapping
(
443
,
443
,
"tcp"
,
""
),
HostPort
:
8080
,
portMapping
(
444
,
444
,
"udp"
,
""
),
HostIP
:
"127.0.0.1"
,
portMapping
(
445
,
445
,
"foobar"
,
""
),
},
portMapping
(
443
,
446
,
"tcp"
,
""
),
{
portMapping
(
443
,
446
,
"udp"
,
""
),
ContainerPort
:
443
,
HostPort
:
443
,
Protocol
:
"tcp"
,
},
{
ContainerPort
:
444
,
HostPort
:
444
,
Protocol
:
"udp"
,
},
{
ContainerPort
:
445
,
HostPort
:
445
,
Protocol
:
"foobar"
,
},
{
ContainerPort
:
443
,
HostPort
:
446
,
Protocol
:
"tcp"
,
},
{
ContainerPort
:
443
,
HostPort
:
446
,
Protocol
:
"udp"
,
},
}
}
exposedPorts
,
bindings
:=
makePortsAndBindings
(
ports
)
exposedPorts
,
bindings
:=
makePortsAndBindings
(
ports
)
...
@@ -731,38 +723,20 @@ func TestMakePortsAndBindings(t *testing.T) {
...
@@ -731,38 +723,20 @@ func TestMakePortsAndBindings(t *testing.T) {
// Construct expected bindings
// Construct expected bindings
expectPortBindings
:=
map
[
string
][]
dockernat
.
PortBinding
{
expectPortBindings
:=
map
[
string
][]
dockernat
.
PortBinding
{
"80/tcp"
:
{
"80/tcp"
:
{
dockernat
.
PortBinding
{
portBinding
(
"8080"
,
"127.0.0.1"
),
HostPort
:
"8080"
,
HostIP
:
"127.0.0.1"
,
},
},
},
"443/tcp"
:
{
"443/tcp"
:
{
dockernat
.
PortBinding
{
portBinding
(
"443"
,
""
),
HostPort
:
"443"
,
portBinding
(
"446"
,
""
),
HostIP
:
""
,
},
dockernat
.
PortBinding
{
HostPort
:
"446"
,
HostIP
:
""
,
},
},
},
"443/udp"
:
{
"443/udp"
:
{
dockernat
.
PortBinding
{
portBinding
(
"446"
,
""
),
HostPort
:
"446"
,
HostIP
:
""
,
},
},
},
"444/udp"
:
{
"444/udp"
:
{
dockernat
.
PortBinding
{
portBinding
(
"444"
,
""
),
HostPort
:
"444"
,
HostIP
:
""
,
},
},
},
"445/tcp"
:
{
"445/tcp"
:
{
dockernat
.
PortBinding
{
portBinding
(
"445"
,
""
),
HostPort
:
"445"
,
HostIP
:
""
,
},
},
},
}
}
...
...
pkg/kubelet/kubelet_test.go
View file @
d1e0e726
This diff is collapsed.
Click to expand it.
pkg/kubelet/pod_workers_test.go
View file @
d1e0e726
...
@@ -228,36 +228,12 @@ func TestFakePodWorkers(t *testing.T) {
...
@@ -228,36 +228,12 @@ func TestFakePodWorkers(t *testing.T) {
&
api
.
Pod
{},
&
api
.
Pod
{},
},
},
{
{
&
api
.
Pod
{
podWithUidNameNs
(
"12345678"
,
"foo"
,
"new"
),
ObjectMeta
:
api
.
ObjectMeta
{
podWithUidNameNs
(
"12345678"
,
"fooMirror"
,
"new"
),
UID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
},
},
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"fooMirror"
,
Namespace
:
"new"
,
},
},
},
},
{
{
&
api
.
Pod
{
podWithUidNameNs
(
"98765"
,
"bar"
,
"new"
),
ObjectMeta
:
api
.
ObjectMeta
{
podWithUidNameNs
(
"98765"
,
"barMirror"
,
"new"
),
UID
:
"98765"
,
Name
:
"bar"
,
Namespace
:
"new"
,
},
},
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"98765"
,
Name
:
"barMirror"
,
Namespace
:
"new"
,
},
},
},
},
}
}
...
...
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