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
f501aceb
Commit
f501aceb
authored
Sep 13, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the monitorParent option when starting services, and set
monitorParent to false when stop-services=false.
parent
0d3befd7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
e2e_node_suite_test.go
test/e2e_node/e2e_node_suite_test.go
+3
-1
server.go
test/e2e_node/services/server.go
+18
-11
services.go
test/e2e_node/services/services.go
+10
-6
No files found.
test/e2e_node/e2e_node_suite_test.go
View file @
f501aceb
...
...
@@ -114,7 +114,9 @@ var _ = SynchronizedBeforeSuite(func() []byte {
maskLocksmithdOnCoreos
()
if
*
startServices
{
e2es
=
services
.
NewE2EServices
()
// If the services are expected to stop after test, they should monitor the test process.
// If the services are expected to keep running after test, they should not monitor the test process.
e2es
=
services
.
NewE2EServices
(
*
stopServices
)
Expect
(
e2es
.
Start
())
.
To
(
Succeed
(),
"should be able to start node services."
)
glog
.
Infof
(
"Node services started. Running tests..."
)
}
else
{
...
...
test/e2e_node/services/server.go
View file @
f501aceb
...
...
@@ -54,6 +54,9 @@ type server struct {
// outFilename is the name of the log file. The stdout and stderr of the server
// will be redirected to this file.
outFilename
string
// monitorParent determines whether the server should watch its parent process and exit
// if its parent is gone.
monitorParent
bool
// restartOnExit determines whether a restart loop is launched with the server
restartOnExit
bool
// Writing to this channel, if it is not nil, stops the restart loop.
...
...
@@ -65,7 +68,7 @@ type server struct {
// newServer returns a new server with the given name, commands, health check
// URLs, etc.
func
newServer
(
name
string
,
start
,
kill
,
restart
*
exec
.
Cmd
,
urls
[]
string
,
outputFileName
string
,
restartOnExit
bool
)
*
server
{
func
newServer
(
name
string
,
start
,
kill
,
restart
*
exec
.
Cmd
,
urls
[]
string
,
outputFileName
string
,
monitorParent
,
restartOnExit
bool
)
*
server
{
return
&
server
{
name
:
name
,
startCommand
:
start
,
...
...
@@ -73,6 +76,7 @@ func newServer(name string, start, kill, restart *exec.Cmd, urls []string, outpu
restartCommand
:
restart
,
healthCheckUrls
:
urls
,
outFilename
:
outputFileName
,
monitorParent
:
monitorParent
,
restartOnExit
:
restartOnExit
,
}
}
...
...
@@ -177,17 +181,20 @@ func (s *server) start() error {
s
.
startCommand
.
Stdout
=
outfile
s
.
startCommand
.
Stderr
=
outfile
// Death of this test process should kill the server as well.
attrs
:=
&
syscall
.
SysProcAttr
{}
// Hack to set linux-only field without build tags.
deathSigField
:=
reflect
.
ValueOf
(
attrs
)
.
Elem
()
.
FieldByName
(
"Pdeathsig"
)
if
deathSigField
.
IsValid
()
{
deathSigField
.
Set
(
reflect
.
ValueOf
(
syscall
.
SIGTERM
))
}
else
{
errCh
<-
fmt
.
Errorf
(
"failed to set Pdeathsig field (non-linux build)"
)
return
// If monitorParent is set, set Pdeathsig when starting the server.
if
s
.
monitorParent
{
// Death of this test process should kill the server as well.
attrs
:=
&
syscall
.
SysProcAttr
{}
// Hack to set linux-only field without build tags.
deathSigField
:=
reflect
.
ValueOf
(
attrs
)
.
Elem
()
.
FieldByName
(
"Pdeathsig"
)
if
deathSigField
.
IsValid
()
{
deathSigField
.
Set
(
reflect
.
ValueOf
(
syscall
.
SIGTERM
))
}
else
{
errCh
<-
fmt
.
Errorf
(
"failed to set Pdeathsig field (non-linux build)"
)
return
}
s
.
startCommand
.
SysProcAttr
=
attrs
}
s
.
startCommand
.
SysProcAttr
=
attrs
// Start the command
err
=
s
.
startCommand
.
Start
()
...
...
test/e2e_node/services/services.go
View file @
f501aceb
...
...
@@ -37,9 +37,12 @@ import (
// E2EServices starts and stops e2e services in a separate process. The test
// uses it to start and stop all e2e services.
type
E2EServices
struct
{
services
*
server
kubelet
*
server
logFiles
map
[
string
]
logFileData
// monitorParent determines whether the sub-processes should watch and die with the current
// process.
monitorParent
bool
services
*
server
kubelet
*
server
logFiles
map
[
string
]
logFileData
}
// logFileData holds data about logfiles to fetch with a journalctl command or
...
...
@@ -50,8 +53,9 @@ type logFileData struct {
}
// NewE2EServices returns a new E2EServices instance.
func
NewE2EServices
()
*
E2EServices
{
func
NewE2EServices
(
monitorParent
bool
)
*
E2EServices
{
return
&
E2EServices
{
monitorParent
:
monitorParent
,
// Special log files that need to be collected for additional debugging.
logFiles
:
map
[
string
]
logFileData
{
"kern.log"
:
{[]
string
{
"/var/log/kern.log"
},
[]
string
{
"-k"
}},
...
...
@@ -151,7 +155,7 @@ func (e *E2EServices) startInternalServices() (*server, error) {
"--logtostderr"
,
"--vmodule=*="
+
LOG_VERBOSITY_LEVEL
,
)
server
:=
newServer
(
"services"
,
startCmd
,
nil
,
nil
,
getServicesHealthCheckURLs
(),
servicesLogFile
,
false
)
server
:=
newServer
(
"services"
,
startCmd
,
nil
,
nil
,
getServicesHealthCheckURLs
(),
servicesLogFile
,
e
.
monitorParent
,
false
)
return
server
,
server
.
start
()
}
...
...
@@ -206,7 +210,6 @@ func (e *E2EServices) startKubelet() (*server, error) {
"--eviction-hard"
,
framework
.
TestContext
.
EvictionHard
,
"--eviction-pressure-transition-period"
,
"30s"
,
"--feature-gates"
,
framework
.
TestContext
.
FeatureGates
,
"--runtime-integration-type"
,
framework
.
TestContext
.
RuntimeIntegrationType
,
"--v"
,
LOG_VERBOSITY_LEVEL
,
"--logtostderr"
,
)
if
framework
.
TestContext
.
RuntimeIntegrationType
!=
""
{
...
...
@@ -238,6 +241,7 @@ func (e *E2EServices) startKubelet() (*server, error) {
restartCommand
,
[]
string
{
kubeletHealthCheckURL
},
"kubelet.log"
,
e
.
monitorParent
,
true
/* restartOnExit */
)
return
server
,
server
.
start
()
}
...
...
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