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
25f37007
Commit
25f37007
authored
May 12, 2016
by
Saad Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #24846 from pmorie/kubelet-test-loc
Reduce LOC in kubelet tests
parents
19169889
d1e0e726
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 @
25f37007
...
...
@@ -674,37 +674,29 @@ func TestFindContainersByPod(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
{
{
ContainerPort
:
80
,
HostPort
:
8080
,
HostIP
:
"127.0.0.1"
,
},
{
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"
,
},
portMapping
(
80
,
8080
,
""
,
"127.0.0.1"
),
portMapping
(
443
,
443
,
"tcp"
,
""
),
portMapping
(
444
,
444
,
"udp"
,
""
),
portMapping
(
445
,
445
,
"foobar"
,
""
),
portMapping
(
443
,
446
,
"tcp"
,
""
),
portMapping
(
443
,
446
,
"udp"
,
""
),
}
exposedPorts
,
bindings
:=
makePortsAndBindings
(
ports
)
...
...
@@ -725,38 +717,20 @@ func TestMakePortsAndBindings(t *testing.T) {
// Construct expected bindings
expectPortBindings
:=
map
[
string
][]
dockernat
.
PortBinding
{
"80/tcp"
:
{
dockernat
.
PortBinding
{
HostPort
:
"8080"
,
HostIP
:
"127.0.0.1"
,
},
portBinding
(
"8080"
,
"127.0.0.1"
),
},
"443/tcp"
:
{
dockernat
.
PortBinding
{
HostPort
:
"443"
,
HostIP
:
""
,
},
dockernat
.
PortBinding
{
HostPort
:
"446"
,
HostIP
:
""
,
},
portBinding
(
"443"
,
""
),
portBinding
(
"446"
,
""
),
},
"443/udp"
:
{
dockernat
.
PortBinding
{
HostPort
:
"446"
,
HostIP
:
""
,
},
portBinding
(
"446"
,
""
),
},
"444/udp"
:
{
dockernat
.
PortBinding
{
HostPort
:
"444"
,
HostIP
:
""
,
},
portBinding
(
"444"
,
""
),
},
"445/tcp"
:
{
dockernat
.
PortBinding
{
HostPort
:
"445"
,
HostIP
:
""
,
},
portBinding
(
"445"
,
""
),
},
}
...
...
pkg/kubelet/kubelet_test.go
View file @
25f37007
This diff is collapsed.
Click to expand it.
pkg/kubelet/pod_workers_test.go
View file @
25f37007
...
...
@@ -229,36 +229,12 @@ func TestFakePodWorkers(t *testing.T) {
&
api
.
Pod
{},
},
{
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
},
},
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"fooMirror"
,
Namespace
:
"new"
,
},
},
podWithUidNameNs
(
"12345678"
,
"foo"
,
"new"
),
podWithUidNameNs
(
"12345678"
,
"fooMirror"
,
"new"
),
},
{
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"98765"
,
Name
:
"bar"
,
Namespace
:
"new"
,
},
},
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"98765"
,
Name
:
"barMirror"
,
Namespace
:
"new"
,
},
},
podWithUidNameNs
(
"98765"
,
"bar"
,
"new"
),
podWithUidNameNs
(
"98765"
,
"barMirror"
,
"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