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
2d132ed6
Commit
2d132ed6
authored
Aug 16, 2017
by
jianglingxia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update it
parent
da00e92f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
stateful_pod_control_test.go
pkg/controller/statefulset/stateful_pod_control_test.go
+26
-26
No files found.
pkg/controller/statefulset/stateful_pod_control_test.go
View file @
2d132ed6
...
@@ -63,7 +63,7 @@ func TestStatefulPodControlCreatesPods(t *testing.T) {
...
@@ -63,7 +63,7 @@ func TestStatefulPodControlCreatesPods(t *testing.T) {
}
}
for
i
:=
range
events
{
for
i
:=
range
events
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeNormal
)
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeNormal
)
{
t
.
Errorf
(
"
Expected normal events found
%s"
,
events
[
i
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
i
])
}
}
}
}
}
}
...
@@ -93,7 +93,7 @@ func TestStatefulPodControlCreatePodExists(t *testing.T) {
...
@@ -93,7 +93,7 @@ func TestStatefulPodControlCreatePodExists(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
0
{
if
eventCount
:=
len
(
events
);
eventCount
!=
0
{
t
.
Errorf
(
"
Expected 0 events when Pod and PVC exist found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod and PVC exist: got %d events, but want 0
"
,
eventCount
)
for
i
:=
range
events
{
for
i
:=
range
events
{
t
.
Log
(
events
[
i
])
t
.
Log
(
events
[
i
])
}
}
...
@@ -120,11 +120,11 @@ func TestStatefulPodControlCreatePodPvcCreateFailure(t *testing.T) {
...
@@ -120,11 +120,11 @@ func TestStatefulPodControlCreatePodPvcCreateFailure(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
t
.
Errorf
(
"
Expected 2 events for PVC create failure found %d
"
,
eventCount
)
t
.
Errorf
(
"
PVC create failure: got %d events, but want 2
"
,
eventCount
)
}
}
for
i
:=
range
events
{
for
i
:=
range
events
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeWarning
)
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected normal events found
%s"
,
events
[
i
])
t
.
Errorf
(
"
Found unexpected non-warning event
%s"
,
events
[
i
])
}
}
}
}
}
}
...
@@ -158,11 +158,11 @@ func TestStatefulPodControlCreatePodPvcGetFailure(t *testing.T) {
...
@@ -158,11 +158,11 @@ func TestStatefulPodControlCreatePodPvcGetFailure(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
t
.
Errorf
(
"
Expected 2 events for PVC create failure found %d
"
,
eventCount
)
t
.
Errorf
(
"
PVC create failure: got %d events, but want 2
"
,
eventCount
)
}
}
for
i
:=
range
events
{
for
i
:=
range
events
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeWarning
)
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected normal events found
%s"
,
events
[
i
])
t
.
Errorf
(
"
Found unexpected non-warning event:
%s"
,
events
[
i
])
}
}
}
}
}
}
...
@@ -187,12 +187,12 @@ func TestStatefulPodControlCreatePodFailed(t *testing.T) {
...
@@ -187,12 +187,12 @@ func TestStatefulPodControlCreatePodFailed(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
t
.
Errorf
(
"
Expected 2 events for failed Pod create found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod create failed: got %d events, but want 2
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
0
])
}
else
if
!
strings
.
Contains
(
events
[
1
],
v1
.
EventTypeWarning
)
{
}
else
if
!
strings
.
Contains
(
events
[
1
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected warning event found
%s"
,
events
[
1
])
t
.
Errorf
(
"
Found unexpected non-warning event
%s"
,
events
[
1
])
}
}
}
}
...
@@ -212,7 +212,7 @@ func TestStatefulPodControlNoOpUpdate(t *testing.T) {
...
@@ -212,7 +212,7 @@ func TestStatefulPodControlNoOpUpdate(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
0
{
if
eventCount
:=
len
(
events
);
eventCount
!=
0
{
t
.
Errorf
(
"
Expected 0 events for no-op update found %d
"
,
eventCount
)
t
.
Errorf
(
"
no-op update: got %d events, but want 0
"
,
eventCount
)
}
}
}
}
...
@@ -234,9 +234,9 @@ func TestStatefulPodControlUpdatesIdentity(t *testing.T) {
...
@@ -234,9 +234,9 @@ func TestStatefulPodControlUpdatesIdentity(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
t
.
Errorf
(
"
Expected 1 event for successful Pod update found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod update successful:got %d events,but want 1
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
0
])
}
}
if
!
identityMatches
(
set
,
updated
)
{
if
!
identityMatches
(
set
,
updated
)
{
t
.
Error
(
"Name update failed identity does not match"
)
t
.
Error
(
"Name update failed identity does not match"
)
...
@@ -264,9 +264,9 @@ func TestStatefulPodControlUpdateIdentityFailure(t *testing.T) {
...
@@ -264,9 +264,9 @@ func TestStatefulPodControlUpdateIdentityFailure(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
t
.
Errorf
(
"
Expected 1 event for failed Pod update found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod update failed: got %d events, but want 1
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeWarning
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected warning event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-warning event
%s"
,
events
[
0
])
}
}
if
identityMatches
(
set
,
pod
)
{
if
identityMatches
(
set
,
pod
)
{
t
.
Error
(
"Failed update mutated Pod identity"
)
t
.
Error
(
"Failed update mutated Pod identity"
)
...
@@ -308,11 +308,11 @@ func TestStatefulPodControlUpdatesPodStorage(t *testing.T) {
...
@@ -308,11 +308,11 @@ func TestStatefulPodControlUpdatesPodStorage(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
t
.
Errorf
(
"
Expected 2 event for successful Pod storage update found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod storage update successful: got %d events, but want 2
"
,
eventCount
)
}
}
for
i
:=
range
events
{
for
i
:=
range
events
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeNormal
)
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeNormal
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
i
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
i
])
}
}
}
}
if
!
storageMatches
(
set
,
updated
)
{
if
!
storageMatches
(
set
,
updated
)
{
...
@@ -348,11 +348,11 @@ func TestStatefulPodControlUpdatePodStorageFailure(t *testing.T) {
...
@@ -348,11 +348,11 @@ func TestStatefulPodControlUpdatePodStorageFailure(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
if
eventCount
:=
len
(
events
);
eventCount
!=
2
{
t
.
Errorf
(
"
Expected 2 event for failed Pod storage update found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod storage update failed: got %d events, but want 2
"
,
eventCount
)
}
}
for
i
:=
range
events
{
for
i
:=
range
events
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeWarning
)
{
if
!
strings
.
Contains
(
events
[
i
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
i
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
i
])
}
}
}
}
}
}
...
@@ -384,9 +384,9 @@ func TestStatefulPodControlUpdatePodConflictSuccess(t *testing.T) {
...
@@ -384,9 +384,9 @@ func TestStatefulPodControlUpdatePodConflictSuccess(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
t
.
Errorf
(
"
Expected 1 event for successful Pod update found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod update successful: got %d, but want 1
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
0
])
}
}
if
!
identityMatches
(
set
,
pod
)
{
if
!
identityMatches
(
set
,
pod
)
{
t
.
Error
(
"Name update failed identity does not match"
)
t
.
Error
(
"Name update failed identity does not match"
)
...
@@ -415,9 +415,9 @@ func TestStatefulPodControlUpdatePodConflictFailure(t *testing.T) {
...
@@ -415,9 +415,9 @@ func TestStatefulPodControlUpdatePodConflictFailure(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
t
.
Errorf
(
"
Expected 1 event for failed Pod update found %d
"
,
eventCount
)
t
.
Errorf
(
"
Pod update failed: got %d events, but want 1
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeWarning
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
0
])
}
}
}
}
...
@@ -435,9 +435,9 @@ func TestStatefulPodControlDeletesStatefulPod(t *testing.T) {
...
@@ -435,9 +435,9 @@ func TestStatefulPodControlDeletesStatefulPod(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
t
.
Errorf
(
"
Expected 1 events for successful delete found %d
"
,
eventCount
)
t
.
Errorf
(
"
delete successful: got %d events, but want 1
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeNormal
)
{
t
.
Errorf
(
"
Expected normal event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-normal event
%s"
,
events
[
0
])
}
}
}
}
...
@@ -455,9 +455,9 @@ func TestStatefulPodControlDeleteFailure(t *testing.T) {
...
@@ -455,9 +455,9 @@ func TestStatefulPodControlDeleteFailure(t *testing.T) {
}
}
events
:=
collectEvents
(
recorder
.
Events
)
events
:=
collectEvents
(
recorder
.
Events
)
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
if
eventCount
:=
len
(
events
);
eventCount
!=
1
{
t
.
Errorf
(
"
Expected 1 events for failed delete found %d
"
,
eventCount
)
t
.
Errorf
(
"
delete failed: got %d events, but want 1
"
,
eventCount
)
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeWarning
)
{
}
else
if
!
strings
.
Contains
(
events
[
0
],
v1
.
EventTypeWarning
)
{
t
.
Errorf
(
"
Expected warning event found
%s"
,
events
[
0
])
t
.
Errorf
(
"
Found unexpected non-warning event
%s"
,
events
[
0
])
}
}
}
}
...
...
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