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
6f46780c
Commit
6f46780c
authored
Oct 16, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests to reproduce the issue and verify the fix.
parent
1b8f8519
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
kubelet_test.go
pkg/kubelet/kubelet_test.go
+86
-0
No files found.
pkg/kubelet/kubelet_test.go
View file @
6f46780c
...
@@ -1462,6 +1462,27 @@ func TestMakeEnvironmentVariables(t *testing.T) {
...
@@ -1462,6 +1462,27 @@ func TestMakeEnvironmentVariables(t *testing.T) {
}
}
}
}
func
waitingState
(
cName
string
)
api
.
ContainerStatus
{
return
api
.
ContainerStatus
{
Name
:
cName
,
State
:
api
.
ContainerState
{
Waiting
:
&
api
.
ContainerStateWaiting
{},
},
}
}
func
waitingStateWithLastTermination
(
cName
string
)
api
.
ContainerStatus
{
return
api
.
ContainerStatus
{
Name
:
cName
,
State
:
api
.
ContainerState
{
Waiting
:
&
api
.
ContainerStateWaiting
{},
},
LastTerminationState
:
api
.
ContainerState
{
Terminated
:
&
api
.
ContainerStateTerminated
{
ExitCode
:
0
,
},
},
}
}
func
runningState
(
cName
string
)
api
.
ContainerStatus
{
func
runningState
(
cName
string
)
api
.
ContainerStatus
{
return
api
.
ContainerStatus
{
return
api
.
ContainerStatus
{
Name
:
cName
,
Name
:
cName
,
...
@@ -1566,6 +1587,32 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
...
@@ -1566,6 +1587,32 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
api
.
PodPending
,
api
.
PodPending
,
"mixed state #2 with restart always"
,
"mixed state #2 with restart always"
,
},
},
{
&
api
.
Pod
{
Spec
:
desiredState
,
Status
:
api
.
PodStatus
{
ContainerStatuses
:
[]
api
.
ContainerStatus
{
runningState
(
"containerA"
),
waitingState
(
"containerB"
),
},
},
},
api
.
PodPending
,
"mixed state #3 with restart always"
,
},
{
&
api
.
Pod
{
Spec
:
desiredState
,
Status
:
api
.
PodStatus
{
ContainerStatuses
:
[]
api
.
ContainerStatus
{
runningState
(
"containerA"
),
waitingStateWithLastTermination
(
"containerB"
),
},
},
},
api
.
PodRunning
,
"backoff crashloop container with restart always"
,
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
if
status
:=
GetPhase
(
&
test
.
pod
.
Spec
,
test
.
pod
.
Status
.
ContainerStatuses
);
status
!=
test
.
status
{
if
status
:=
GetPhase
(
&
test
.
pod
.
Spec
,
test
.
pod
.
Status
.
ContainerStatuses
);
status
!=
test
.
status
{
...
@@ -1654,6 +1701,19 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
...
@@ -1654,6 +1701,19 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
api
.
PodPending
,
api
.
PodPending
,
"mixed state #2 with restart never"
,
"mixed state #2 with restart never"
,
},
},
{
&
api
.
Pod
{
Spec
:
desiredState
,
Status
:
api
.
PodStatus
{
ContainerStatuses
:
[]
api
.
ContainerStatus
{
runningState
(
"containerA"
),
waitingState
(
"containerB"
),
},
},
},
api
.
PodPending
,
"mixed state #3 with restart never"
,
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
if
status
:=
GetPhase
(
&
test
.
pod
.
Spec
,
test
.
pod
.
Status
.
ContainerStatuses
);
status
!=
test
.
status
{
if
status
:=
GetPhase
(
&
test
.
pod
.
Spec
,
test
.
pod
.
Status
.
ContainerStatuses
);
status
!=
test
.
status
{
...
@@ -1742,6 +1802,32 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
...
@@ -1742,6 +1802,32 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
api
.
PodPending
,
api
.
PodPending
,
"mixed state #2 with restart onfailure"
,
"mixed state #2 with restart onfailure"
,
},
},
{
&
api
.
Pod
{
Spec
:
desiredState
,
Status
:
api
.
PodStatus
{
ContainerStatuses
:
[]
api
.
ContainerStatus
{
runningState
(
"containerA"
),
waitingState
(
"containerB"
),
},
},
},
api
.
PodPending
,
"mixed state #3 with restart onfailure"
,
},
{
&
api
.
Pod
{
Spec
:
desiredState
,
Status
:
api
.
PodStatus
{
ContainerStatuses
:
[]
api
.
ContainerStatus
{
runningState
(
"containerA"
),
waitingStateWithLastTermination
(
"containerB"
),
},
},
},
api
.
PodRunning
,
"backoff crashloop container with restart onfailure"
,
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
if
status
:=
GetPhase
(
&
test
.
pod
.
Spec
,
test
.
pod
.
Status
.
ContainerStatuses
);
status
!=
test
.
status
{
if
status
:=
GetPhase
(
&
test
.
pod
.
Spec
,
test
.
pod
.
Status
.
ContainerStatuses
);
status
!=
test
.
status
{
...
...
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