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
c5a92374
Commit
c5a92374
authored
Aug 29, 2017
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pod update test descriptions to match the test cases
parent
01e961b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
11 deletions
+52
-11
validation_test.go
pkg/api/validation/validation_test.go
+52
-11
No files found.
pkg/api/validation/validation_test.go
View file @
c5a92374
...
...
@@ -5552,8 +5552,8 @@ func TestValidatePodUpdate(t *testing.T) {
)
tests
:=
[]
struct
{
a
api
.
Pod
b
api
.
Pod
new
api
.
Pod
old
api
.
Pod
err
string
test
string
}{
...
...
@@ -5635,6 +5635,35 @@ func TestValidatePodUpdate(t *testing.T) {
},
},
"may not add or remove containers"
,
"less containers"
,
},
{
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Image
:
"foo:V1"
,
},
{
Image
:
"bar:V2"
,
},
},
},
},
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Image
:
"foo:V2"
,
},
},
},
},
"may not add or remove containers"
,
"more containers"
,
},
{
...
...
@@ -5676,7 +5705,19 @@ func TestValidatePodUpdate(t *testing.T) {
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"foo:V1"
}}},
},
""
,
"deletion timestamp filled out"
,
"deletion timestamp removed"
,
},
{
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
DeletionTimestamp
:
&
now
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"foo:V1"
}}},
},
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"foo:V1"
}}},
},
"metadata.deletionTimestamp"
,
"deletion timestamp added"
,
},
{
api
.
Pod
{
...
...
@@ -5688,7 +5729,7 @@ func TestValidatePodUpdate(t *testing.T) {
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"foo:V1"
}}},
},
"metadata.deletionGracePeriodSeconds"
,
"deletion grace period seconds c
lear
ed"
,
"deletion grace period seconds c
hang
ed"
,
},
{
api
.
Pod
{
...
...
@@ -6144,13 +6185,13 @@ func TestValidatePodUpdate(t *testing.T) {
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Annotations
:
map
[
string
]
string
{
api
.
MirrorPodAnnotationKey
:
""
}},
Spec
:
api
.
PodSpec
{
NodeName
:
"foo"
}},
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"foo"
}},
"metadata.annotations[kubernetes.io/config.mirror]"
,
"
remov
ed mirror pod annotation"
,
"
add
ed mirror pod annotation"
,
},
{
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"foo"
}},
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Annotations
:
map
[
string
]
string
{
api
.
MirrorPodAnnotationKey
:
""
}},
Spec
:
api
.
PodSpec
{
NodeName
:
"foo"
}},
"metadata.annotations[kubernetes.io/config.mirror]"
,
"
add
ed mirror pod annotation"
,
"
remov
ed mirror pod annotation"
,
},
{
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Annotations
:
map
[
string
]
string
{
api
.
MirrorPodAnnotationKey
:
"foo"
}},
Spec
:
api
.
PodSpec
{
NodeName
:
"foo"
}},
...
...
@@ -6205,16 +6246,16 @@ func TestValidatePodUpdate(t *testing.T) {
}
for
_
,
test
:=
range
tests
{
test
.
a
.
ObjectMeta
.
ResourceVersion
=
"1"
test
.
b
.
ObjectMeta
.
ResourceVersion
=
"1"
errs
:=
ValidatePodUpdate
(
&
test
.
a
,
&
test
.
b
)
test
.
new
.
ObjectMeta
.
ResourceVersion
=
"1"
test
.
old
.
ObjectMeta
.
ResourceVersion
=
"1"
errs
:=
ValidatePodUpdate
(
&
test
.
new
,
&
test
.
old
)
if
test
.
err
==
""
{
if
len
(
errs
)
!=
0
{
t
.
Errorf
(
"unexpected invalid: %s (%+v)
\n
A: %+v
\n
B: %+v"
,
test
.
test
,
errs
,
test
.
a
,
test
.
b
)
t
.
Errorf
(
"unexpected invalid: %s (%+v)
\n
A: %+v
\n
B: %+v"
,
test
.
test
,
errs
,
test
.
new
,
test
.
old
)
}
}
else
{
if
len
(
errs
)
==
0
{
t
.
Errorf
(
"unexpected valid: %s
\n
A: %+v
\n
B: %+v"
,
test
.
test
,
test
.
a
,
test
.
b
)
t
.
Errorf
(
"unexpected valid: %s
\n
A: %+v
\n
B: %+v"
,
test
.
test
,
test
.
new
,
test
.
old
)
}
else
if
actualErr
:=
errs
.
ToAggregate
()
.
Error
();
!
strings
.
Contains
(
actualErr
,
test
.
err
)
{
t
.
Errorf
(
"unexpected error message: %s
\n
Expected error: %s
\n
Actual error: %s"
,
test
.
test
,
test
.
err
,
actualErr
)
}
...
...
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