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
24473417
Unverified
Commit
24473417
authored
Jan 01, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add conformance tests for terminationMessage(Path|Policy)
Test root, non-root, success and message, failure and message.
parent
e6d35b03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
29 deletions
+96
-29
runtime_conformance_test.go
test/e2e_node/runtime_conformance_test.go
+96
-29
No files found.
test/e2e_node/runtime_conformance_test.go
View file @
24473417
...
...
@@ -28,6 +28,7 @@ import (
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
gomegatypes
"github.com/onsi/gomega/types"
)
const
(
...
...
@@ -128,46 +129,112 @@ while true; do sleep 1; done
}
})
It
(
"should report termination message if TerminationMessagePath is set [Conformance]"
,
func
()
{
name
:=
"termination-message-container"
terminationMessage
:=
"DONE"
terminationMessagePath
:=
"/dev/termination-log"
priv
:=
true
c
:=
ConformanceContainer
{
PodClient
:
f
.
PodClient
(),
Container
:
v1
.
Container
{
rootUser
:=
int64
(
0
)
nonRootUser
:=
int64
(
10000
)
for
_
,
testCase
:=
range
[]
struct
{
name
string
container
v1
.
Container
phase
v1
.
PodPhase
message
gomegatypes
.
GomegaMatcher
}{
{
name
:
"if TerminationMessagePath is set [Conformance]"
,
container
:
v1
.
Container
{
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Name
:
name
,
Command
:
[]
string
{
"/bin/sh"
,
"-c"
},
Args
:
[]
string
{
fmt
.
Sprintf
(
"/bin/echo -n %s > %s"
,
terminationMessage
,
terminationMessagePath
)
},
TerminationMessagePath
:
terminationMessagePath
,
Args
:
[]
string
{
"/bin/echo -n DONE > /dev/termination-log"
},
TerminationMessagePath
:
"/dev/termination-log"
,
SecurityContext
:
&
v1
.
SecurityContext
{
Privileged
:
&
priv
,
RunAsUser
:
&
rootUser
,
},
},
RestartPolicy
:
v1
.
RestartPolicyNever
,
}
phase
:
v1
.
PodSucceeded
,
message
:
Equal
(
"DONE"
),
},
{
name
:
"if TerminationMessagePath is set as non-root user and at a non-default path [Conformance]"
,
container
:
v1
.
Container
{
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"/bin/sh"
,
"-c"
},
Args
:
[]
string
{
"/bin/echo -n DONE > /dev/termination-custom-log"
},
TerminationMessagePath
:
"/dev/termination-custom-log"
,
SecurityContext
:
&
v1
.
SecurityContext
{
RunAsUser
:
&
nonRootUser
,
},
},
phase
:
v1
.
PodSucceeded
,
message
:
Equal
(
"DONE"
),
},
{
name
:
"from log output if TerminationMessagePolicy FallbackToLogOnError is set [Conformance]"
,
container
:
v1
.
Container
{
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"/bin/sh"
,
"-c"
},
Args
:
[]
string
{
"/bin/echo -n DONE; /bin/false"
},
TerminationMessagePath
:
"/dev/termination-log"
,
TerminationMessagePolicy
:
v1
.
TerminationMessageFallbackToLogsOnError
,
},
phase
:
v1
.
PodFailed
,
message
:
Equal
(
"DONE
\n
"
),
},
By
(
"create the container"
)
c
.
Create
()
defer
c
.
Delete
()
{
name
:
"as empty when pod succeeds and TerminationMessagePolicy FallbackToLogOnError is set"
,
container
:
v1
.
Container
{
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"/bin/sh"
,
"-c"
},
Args
:
[]
string
{
"/bin/echo DONE; /bin/true"
},
TerminationMessagePath
:
"/dev/termination-log"
,
TerminationMessagePolicy
:
v1
.
TerminationMessageFallbackToLogsOnError
,
},
phase
:
v1
.
PodSucceeded
,
message
:
Equal
(
""
),
},
By
(
"wait for the container to succeed"
)
Eventually
(
c
.
GetPhase
,
retryTimeout
,
pollInterval
)
.
Should
(
Equal
(
v1
.
PodSucceeded
))
{
name
:
"from file when pod succeeds and TerminationMessagePolicy FallbackToLogOnError is set [Conformance]"
,
container
:
v1
.
Container
{
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"/bin/sh"
,
"-c"
},
Args
:
[]
string
{
"/bin/echo -n OK > /dev/termination-log; /bin/echo DONE; /bin/true"
},
TerminationMessagePath
:
"/dev/termination-log"
,
TerminationMessagePolicy
:
v1
.
TerminationMessageFallbackToLogsOnError
,
},
phase
:
v1
.
PodSucceeded
,
message
:
Equal
(
"OK"
),
},
}
{
It
(
fmt
.
Sprintf
(
"should report termination message %s"
,
testCase
.
name
),
func
()
{
testCase
.
container
.
Name
=
"termination-message-container"
c
:=
ConformanceContainer
{
PodClient
:
f
.
PodClient
(),
Container
:
testCase
.
container
,
RestartPolicy
:
v1
.
RestartPolicyNever
,
}
By
(
"get the container status
"
)
status
,
err
:=
c
.
GetStatus
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
()
)
By
(
"create the container
"
)
c
.
Create
()
defer
c
.
Delete
(
)
By
(
"the container should be terminated"
)
Expect
(
GetContainerState
(
status
.
State
))
.
To
(
Equal
(
ContainerStateTerminated
))
By
(
fmt
.
Sprintf
(
"wait for the container to reach %s"
,
testCase
.
phase
)
)
Eventually
(
c
.
GetPhase
,
retryTimeout
,
pollInterval
)
.
Should
(
Equal
(
testCase
.
phase
))
By
(
"the termination message should be set"
)
Expect
(
status
.
State
.
Terminated
.
Message
)
.
Should
(
Equal
(
terminationMessage
))
By
(
"get the container status"
)
status
,
err
:=
c
.
GetStatus
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"delete the container"
)
Expect
(
c
.
Delete
())
.
To
(
Succeed
())
})
By
(
"the container should be terminated"
)
Expect
(
GetContainerState
(
status
.
State
))
.
To
(
Equal
(
ContainerStateTerminated
))
By
(
"the termination message should be set"
)
Expect
(
status
.
State
.
Terminated
.
Message
)
.
Should
(
testCase
.
message
)
By
(
"delete the container"
)
Expect
(
c
.
Delete
())
.
To
(
Succeed
())
})
}
})
Context
(
"when running a container with a new image"
,
func
()
{
...
...
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