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
a99e4ca7
Commit
a99e4ca7
authored
May 29, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25678 from rajdeepd/branch1
Automatic merge from submit-queue Added Test Cases for Pod Test case modified for Pod
parents
98af4432
cde9cff6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
1 deletion
+83
-1
util_test.go
pkg/api/pod/util_test.go
+83
-1
No files found.
pkg/api/pod/util_test.go
View file @
a99e4ca7
...
@@ -92,7 +92,89 @@ func TestFindPort(t *testing.T) {
...
@@ -92,7 +92,89 @@ func TestFindPort(t *testing.T) {
port
:
intstr
.
FromString
(
"q"
),
port
:
intstr
.
FromString
(
"q"
),
expected
:
33
,
expected
:
33
,
pass
:
true
,
pass
:
true
,
}}
},
{
name
:
"valid str, two ctr with same port"
,
containers
:
[]
api
.
Container
{{},
{
Ports
:
[]
api
.
ContainerPort
{{
Name
:
""
,
ContainerPort
:
11
,
Protocol
:
"UDP"
,
},
{
Name
:
"p"
,
ContainerPort
:
22
,
Protocol
:
"TCP"
,
},
{
Name
:
"q"
,
ContainerPort
:
22
,
Protocol
:
"TCP"
,
}}}},
port
:
intstr
.
FromString
(
"q"
),
expected
:
22
,
pass
:
true
,
},
{
name
:
"valid str, invalid protocol"
,
containers
:
[]
api
.
Container
{{},
{
Ports
:
[]
api
.
ContainerPort
{{
Name
:
"a"
,
ContainerPort
:
11
,
Protocol
:
"snmp"
,
},
}}},
port
:
intstr
.
FromString
(
"a"
),
expected
:
0
,
pass
:
false
,
},
{
name
:
"valid hostPort"
,
containers
:
[]
api
.
Container
{{},
{
Ports
:
[]
api
.
ContainerPort
{{
Name
:
"a"
,
ContainerPort
:
11
,
HostPort
:
81
,
Protocol
:
"TCP"
,
},
}}},
port
:
intstr
.
FromString
(
"a"
),
expected
:
11
,
pass
:
true
,
},
{
name
:
"invalid hostPort"
,
containers
:
[]
api
.
Container
{{},
{
Ports
:
[]
api
.
ContainerPort
{{
Name
:
"a"
,
ContainerPort
:
11
,
HostPort
:
-
1
,
Protocol
:
"TCP"
,
},
}}},
port
:
intstr
.
FromString
(
"a"
),
expected
:
11
,
pass
:
true
,
//this should fail but passes.
},
{
name
:
"invalid ContainerPort"
,
containers
:
[]
api
.
Container
{{},
{
Ports
:
[]
api
.
ContainerPort
{{
Name
:
"a"
,
ContainerPort
:
-
1
,
Protocol
:
"TCP"
,
},
}}},
port
:
intstr
.
FromString
(
"a"
),
expected
:
-
1
,
pass
:
true
,
//this should fail but passes
},
{
name
:
"HostIP Address"
,
containers
:
[]
api
.
Container
{{},
{
Ports
:
[]
api
.
ContainerPort
{{
Name
:
"a"
,
ContainerPort
:
11
,
HostIP
:
"192.168.1.1"
,
Protocol
:
"TCP"
,
},
}}},
port
:
intstr
.
FromString
(
"a"
),
expected
:
11
,
pass
:
true
,
},
}
for
_
,
tc
:=
range
testCases
{
for
_
,
tc
:=
range
testCases
{
port
,
err
:=
FindPort
(
&
api
.
Pod
{
Spec
:
api
.
PodSpec
{
Containers
:
tc
.
containers
}},
port
,
err
:=
FindPort
(
&
api
.
Pod
{
Spec
:
api
.
PodSpec
{
Containers
:
tc
.
containers
}},
...
...
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