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
9ae9eb6e
Commit
9ae9eb6e
authored
Nov 17, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16984 from brendandburns/e2e4
Auto commit by PR queue bot
parents
849280f1
ed91d556
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
30 deletions
+52
-30
reboot.go
test/e2e/reboot.go
+52
-30
No files found.
test/e2e/reboot.go
View file @
9ae9eb6e
...
@@ -18,6 +18,7 @@ package e2e
...
@@ -18,6 +18,7 @@ package e2e
import
(
import
(
"fmt"
"fmt"
"sync"
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -26,6 +27,7 @@ import (
...
@@ -26,6 +27,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
)
const
(
const
(
...
@@ -43,16 +45,33 @@ const (
...
@@ -43,16 +45,33 @@ const (
)
)
var
_
=
Describe
(
"Reboot"
,
func
()
{
var
_
=
Describe
(
"Reboot"
,
func
()
{
f
:=
NewFramework
(
"reboot"
)
var
f
*
Framework
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
// These tests requires SSH to nodes, so the provider check should be identical to there
// These tests requires SSH to nodes, so the provider check should be identical to there
// (the limiting factor is the implementation of util.go's getSigner(...)).
// (the limiting factor is the implementation of util.go's getSigner(...)).
// Cluster must support node reboot
// Cluster must support node reboot
SkipUnlessProviderIs
(
"gce"
,
"gke"
,
"aws"
)
SkipUnlessProviderIs
(
providersWithSSH
...
)
})
})
AfterEach
(
func
()
{
if
CurrentGinkgoTestDescription
()
.
Failed
{
// Most of the reboot tests just make sure that addon/system pods are running, so dump
// events for the kube-system namespace on failures
namespaceName
:=
api
.
NamespaceSystem
By
(
fmt
.
Sprintf
(
"Collecting events from namespace %q."
,
namespaceName
))
events
,
err
:=
f
.
Client
.
Events
(
namespaceName
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
for
_
,
e
:=
range
events
.
Items
{
Logf
(
"event for %v: %v %v: %v"
,
e
.
InvolvedObject
.
Name
,
e
.
Source
,
e
.
Reason
,
e
.
Message
)
}
}
})
f
=
NewFramework
(
"reboot"
)
It
(
"each node by ordering clean reboot and ensure they function upon restart"
,
func
()
{
It
(
"each node by ordering clean reboot and ensure they function upon restart"
,
func
()
{
// clean shutdown and restart
// clean shutdown and restart
// We sleep 10 seconds to give some time for ssh command to cleanly finish before the node is rebooted.
// We sleep 10 seconds to give some time for ssh command to cleanly finish before the node is rebooted.
...
@@ -100,22 +119,32 @@ func testReboot(c *client.Client, rebootCmd string) {
...
@@ -100,22 +119,32 @@ func testReboot(c *client.Client, rebootCmd string) {
if
err
!=
nil
{
if
err
!=
nil
{
Failf
(
"Error getting nodes: %v"
,
err
)
Failf
(
"Error getting nodes: %v"
,
err
)
}
}
result
:=
make
(
chan
bool
,
len
(
nodelist
.
Items
))
result
:=
make
([]
bool
,
len
(
nodelist
.
Items
))
for
_
,
n
:=
range
nodelist
.
Items
{
wg
:=
sync
.
WaitGroup
{}
go
rebootNode
(
c
,
testContext
.
Provider
,
n
.
ObjectMeta
.
Name
,
rebootCmd
,
result
)
wg
.
Add
(
len
(
nodelist
.
Items
))
}
// Wait for all to finish and check the final result.
failed
:=
false
failed
:=
false
// TODO(a-robinson): Change to `for range` syntax and remove logging once
for
ix
:=
range
nodelist
.
Items
{
// we support only Go >= 1.4.
go
func
(
ix
int
)
{
for
_
,
n
:=
range
nodelist
.
Items
{
defer
wg
.
Done
()
if
!<-
result
{
n
:=
nodelist
.
Items
[
ix
]
Failf
(
"Node %s failed reboot test."
,
n
.
ObjectMeta
.
Name
)
result
[
ix
]
=
rebootNode
(
c
,
testContext
.
Provider
,
n
.
ObjectMeta
.
Name
,
rebootCmd
)
failed
=
true
if
!
result
[
ix
]
{
}
failed
=
true
}
}(
ix
)
}
}
// Wait for all to finish and check the final result.
wg
.
Wait
()
if
failed
{
if
failed
{
for
ix
:=
range
nodelist
.
Items
{
n
:=
nodelist
.
Items
[
ix
]
if
!
result
[
ix
]
{
Logf
(
"Node %s failed reboot test."
,
n
.
ObjectMeta
.
Name
)
}
}
Failf
(
"Test failed; at least one node failed to reboot in the time given."
)
Failf
(
"Test failed; at least one node failed to reboot in the time given."
)
}
}
}
}
...
@@ -149,7 +178,7 @@ func issueSSHCommand(node *api.Node, provider, cmd string) error {
...
@@ -149,7 +178,7 @@ func issueSSHCommand(node *api.Node, provider, cmd string) error {
//
//
// It returns true through result only if all of the steps pass; at the first
// It returns true through result only if all of the steps pass; at the first
// failed step, it will return false through result and not run the rest.
// failed step, it will return false through result and not run the rest.
func
rebootNode
(
c
*
client
.
Client
,
provider
,
name
,
rebootCmd
string
,
result
chan
bool
)
{
func
rebootNode
(
c
*
client
.
Client
,
provider
,
name
,
rebootCmd
string
)
bool
{
// Setup
// Setup
ns
:=
api
.
NamespaceSystem
ns
:=
api
.
NamespaceSystem
ps
:=
newPodStore
(
c
,
ns
,
labels
.
Everything
(),
fields
.
OneTermEqualSelector
(
client
.
PodHost
,
name
))
ps
:=
newPodStore
(
c
,
ns
,
labels
.
Everything
(),
fields
.
OneTermEqualSelector
(
client
.
PodHost
,
name
))
...
@@ -160,14 +189,12 @@ func rebootNode(c *client.Client, provider, name, rebootCmd string, result chan
...
@@ -160,14 +189,12 @@ func rebootNode(c *client.Client, provider, name, rebootCmd string, result chan
node
,
err
:=
c
.
Nodes
()
.
Get
(
name
)
node
,
err
:=
c
.
Nodes
()
.
Get
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Couldn't get node %s"
,
name
)
Logf
(
"Couldn't get node %s"
,
name
)
result
<-
false
return
false
return
}
}
// Node sanity check: ensure it is "ready".
// Node sanity check: ensure it is "ready".
if
!
waitForNodeToBeReady
(
c
,
name
,
nodeReadyInitialTimeout
)
{
if
!
waitForNodeToBeReady
(
c
,
name
,
nodeReadyInitialTimeout
)
{
result
<-
false
return
false
return
}
}
// Get all the pods on the node that don't have liveness probe set.
// Get all the pods on the node that don't have liveness probe set.
...
@@ -191,36 +218,31 @@ func rebootNode(c *client.Client, provider, name, rebootCmd string, result chan
...
@@ -191,36 +218,31 @@ func rebootNode(c *client.Client, provider, name, rebootCmd string, result chan
// For each pod, we do a sanity check to ensure it's running / healthy
// For each pod, we do a sanity check to ensure it's running / healthy
// now, as that's what we'll be checking later.
// now, as that's what we'll be checking later.
if
!
checkPodsRunningReady
(
c
,
ns
,
podNames
,
podReadyBeforeTimeout
)
{
if
!
checkPodsRunningReady
(
c
,
ns
,
podNames
,
podReadyBeforeTimeout
)
{
result
<-
false
return
false
return
}
}
// Reboot the node.
// Reboot the node.
if
err
=
issueSSHCommand
(
node
,
provider
,
rebootCmd
);
err
!=
nil
{
if
err
=
issueSSHCommand
(
node
,
provider
,
rebootCmd
);
err
!=
nil
{
Logf
(
"Error while issuing ssh command: %v"
,
err
)
Logf
(
"Error while issuing ssh command: %v"
,
err
)
result
<-
false
return
false
return
}
}
// Wait for some kind of "not ready" status.
// Wait for some kind of "not ready" status.
if
!
waitForNodeToBeNotReady
(
c
,
name
,
rebootNodeNotReadyTimeout
)
{
if
!
waitForNodeToBeNotReady
(
c
,
name
,
rebootNodeNotReadyTimeout
)
{
result
<-
false
return
false
return
}
}
// Wait for some kind of "ready" status.
// Wait for some kind of "ready" status.
if
!
waitForNodeToBeReady
(
c
,
name
,
rebootNodeReadyAgainTimeout
)
{
if
!
waitForNodeToBeReady
(
c
,
name
,
rebootNodeReadyAgainTimeout
)
{
result
<-
false
return
false
return
}
}
// Ensure all of the pods that we found on this node before the reboot are
// Ensure all of the pods that we found on this node before the reboot are
// running / healthy.
// running / healthy.
if
!
checkPodsRunningReady
(
c
,
ns
,
podNames
,
rebootPodReadyAgainTimeout
)
{
if
!
checkPodsRunningReady
(
c
,
ns
,
podNames
,
rebootPodReadyAgainTimeout
)
{
result
<-
false
return
false
return
}
}
Logf
(
"Reboot successful on node %s"
,
name
)
Logf
(
"Reboot successful on node %s"
,
name
)
re
sult
<-
true
re
turn
true
}
}
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