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
bbb27cde
Commit
bbb27cde
authored
Sep 20, 2016
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dumping federation events if federation test failed
parent
25801575
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
6 deletions
+32
-6
e2e.go
test/e2e/e2e.go
+5
-1
framework.go
test/e2e/framework/framework.go
+6
-1
util.go
test/e2e/framework/util.go
+20
-3
kubectl.go
test/e2e/kubectl.go
+1
-1
No files found.
test/e2e/e2e.go
View file @
bbb27cde
...
@@ -98,6 +98,10 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
...
@@ -98,6 +98,10 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatal
(
"Error loading client: "
,
err
)
glog
.
Fatal
(
"Error loading client: "
,
err
)
}
}
clientset
,
err
:=
framework
.
LoadClientset
()
if
err
!=
nil
{
glog
.
Fatal
(
"Error loading clientset: "
,
err
)
}
// Delete any namespaces except default and kube-system. This ensures no
// Delete any namespaces except default and kube-system. This ensures no
// lingering resources are left over from a previous test run.
// lingering resources are left over from a previous test run.
...
@@ -118,7 +122,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
...
@@ -118,7 +122,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
// ready will fail).
// ready will fail).
podStartupTimeout
:=
framework
.
TestContext
.
SystemPodsStartupTimeout
podStartupTimeout
:=
framework
.
TestContext
.
SystemPodsStartupTimeout
if
err
:=
framework
.
WaitForPodsRunningReady
(
c
,
api
.
NamespaceSystem
,
int32
(
framework
.
TestContext
.
MinStartupPods
),
podStartupTimeout
,
framework
.
ImagePullerLabels
);
err
!=
nil
{
if
err
:=
framework
.
WaitForPodsRunningReady
(
c
,
api
.
NamespaceSystem
,
int32
(
framework
.
TestContext
.
MinStartupPods
),
podStartupTimeout
,
framework
.
ImagePullerLabels
);
err
!=
nil
{
framework
.
DumpAllNamespaceInfo
(
c
,
api
.
NamespaceSystem
)
framework
.
DumpAllNamespaceInfo
(
c
,
clientset
,
api
.
NamespaceSystem
)
framework
.
LogFailedContainers
(
c
,
api
.
NamespaceSystem
)
framework
.
LogFailedContainers
(
c
,
api
.
NamespaceSystem
)
framework
.
RunKubernetesServiceTestContainer
(
c
,
api
.
NamespaceDefault
)
framework
.
RunKubernetesServiceTestContainer
(
c
,
api
.
NamespaceDefault
)
framework
.
Failf
(
"Error waiting for all pods to be running and ready: %v"
,
err
)
framework
.
Failf
(
"Error waiting for all pods to be running and ready: %v"
,
err
)
...
...
test/e2e/framework/framework.go
View file @
bbb27cde
...
@@ -356,10 +356,15 @@ func (f *Framework) AfterEach() {
...
@@ -356,10 +356,15 @@ func (f *Framework) AfterEach() {
// Print events if the test failed.
// Print events if the test failed.
if
CurrentGinkgoTestDescription
()
.
Failed
&&
TestContext
.
DumpLogsOnFailure
{
if
CurrentGinkgoTestDescription
()
.
Failed
&&
TestContext
.
DumpLogsOnFailure
{
DumpAllNamespaceInfo
(
f
.
Client
,
f
.
Namespace
.
Name
)
// Pass both unversioned client and and versioned clientset, till we have removed all uses of the unversioned client.
DumpAllNamespaceInfo
(
f
.
Client
,
f
.
Clientset_1_5
,
f
.
Namespace
.
Name
)
By
(
fmt
.
Sprintf
(
"Dumping a list of prepulled images on each node"
))
By
(
fmt
.
Sprintf
(
"Dumping a list of prepulled images on each node"
))
LogContainersInPodsWithLabels
(
f
.
Client
,
api
.
NamespaceSystem
,
ImagePullerLabels
,
"image-puller"
)
LogContainersInPodsWithLabels
(
f
.
Client
,
api
.
NamespaceSystem
,
ImagePullerLabels
,
"image-puller"
)
if
f
.
federated
{
if
f
.
federated
{
// Dump federation events in federation namespace.
DumpEventsInNamespace
(
func
(
opts
api
.
ListOptions
,
ns
string
)
(
*
v1
.
EventList
,
error
)
{
return
f
.
FederationClientset_1_4
.
Core
()
.
Events
(
ns
)
.
List
(
opts
)
},
f
.
FederationNamespace
.
Name
)
// Print logs of federation control plane pods (federation-apiserver and federation-controller-manager)
// Print logs of federation control plane pods (federation-apiserver and federation-controller-manager)
LogPodsWithLabels
(
f
.
Client
,
"federation"
,
map
[
string
]
string
{
"app"
:
"federated-cluster"
})
LogPodsWithLabels
(
f
.
Client
,
"federation"
,
map
[
string
]
string
{
"app"
:
"federated-cluster"
})
// Print logs of kube-dns pod
// Print logs of kube-dns pod
...
...
test/e2e/framework/util.go
View file @
bbb27cde
...
@@ -52,6 +52,7 @@ import (
...
@@ -52,6 +52,7 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/cache"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/typed/discovery"
"k8s.io/kubernetes/pkg/client/typed/discovery"
"k8s.io/kubernetes/pkg/client/typed/dynamic"
"k8s.io/kubernetes/pkg/client/typed/dynamic"
...
@@ -1978,6 +1979,14 @@ func LoadClient() (*client.Client, error) {
...
@@ -1978,6 +1979,14 @@ func LoadClient() (*client.Client, error) {
return
loadClientFromConfig
(
config
)
return
loadClientFromConfig
(
config
)
}
}
func
LoadClientset
()
(
*
release_1_5
.
Clientset
,
error
)
{
config
,
err
:=
LoadConfig
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error creating client: %v"
,
err
.
Error
())
}
return
release_1_5
.
NewForConfig
(
config
)
}
// randomSuffix provides a random string to append to pods,services,rcs.
// randomSuffix provides a random string to append to pods,services,rcs.
// TODO: Allow service names to have the same form as names
// TODO: Allow service names to have the same form as names
// for pods and replication controllers so we don't
// for pods and replication controllers so we don't
...
@@ -2815,9 +2824,11 @@ func dumpPodDebugInfo(c *client.Client, pods []*api.Pod) {
...
@@ -2815,9 +2824,11 @@ func dumpPodDebugInfo(c *client.Client, pods []*api.Pod) {
DumpNodeDebugInfo
(
c
,
badNodes
.
List
())
DumpNodeDebugInfo
(
c
,
badNodes
.
List
())
}
}
func
DumpAllNamespaceInfo
(
c
*
client
.
Client
,
namespace
string
)
{
type
EventsLister
func
(
opts
api
.
ListOptions
,
ns
string
)
(
*
v1
.
EventList
,
error
)
func
DumpEventsInNamespace
(
eventsLister
EventsLister
,
namespace
string
)
{
By
(
fmt
.
Sprintf
(
"Collecting events from namespace %q."
,
namespace
))
By
(
fmt
.
Sprintf
(
"Collecting events from namespace %q."
,
namespace
))
events
,
err
:=
c
.
Events
(
namespace
)
.
List
(
api
.
ListOptions
{}
)
events
,
err
:=
eventsLister
(
api
.
ListOptions
{},
namespace
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// Sort events by their first timestamp
// Sort events by their first timestamp
...
@@ -2831,6 +2842,12 @@ func DumpAllNamespaceInfo(c *client.Client, namespace string) {
...
@@ -2831,6 +2842,12 @@ func DumpAllNamespaceInfo(c *client.Client, namespace string) {
// Note that we don't wait for any Cleanup to propagate, which means
// Note that we don't wait for any Cleanup to propagate, which means
// that if you delete a bunch of pods right before ending your test,
// that if you delete a bunch of pods right before ending your test,
// you may or may not see the killing/deletion/Cleanup events.
// you may or may not see the killing/deletion/Cleanup events.
}
func
DumpAllNamespaceInfo
(
c
*
client
.
Client
,
cs
*
release_1_5
.
Clientset
,
namespace
string
)
{
DumpEventsInNamespace
(
func
(
opts
api
.
ListOptions
,
ns
string
)
(
*
v1
.
EventList
,
error
)
{
return
cs
.
Core
()
.
Events
(
ns
)
.
List
(
opts
)
},
namespace
)
// If cluster is large, then the following logs are basically useless, because:
// If cluster is large, then the following logs are basically useless, because:
// 1. it takes tens of minutes or hours to grab all of them
// 1. it takes tens of minutes or hours to grab all of them
...
@@ -2850,7 +2867,7 @@ func DumpAllNamespaceInfo(c *client.Client, namespace string) {
...
@@ -2850,7 +2867,7 @@ func DumpAllNamespaceInfo(c *client.Client, namespace string) {
}
}
// byFirstTimestamp sorts a slice of events by first timestamp, using their involvedObject's name as a tie breaker.
// byFirstTimestamp sorts a slice of events by first timestamp, using their involvedObject's name as a tie breaker.
type
byFirstTimestamp
[]
api
.
Event
type
byFirstTimestamp
[]
v1
.
Event
func
(
o
byFirstTimestamp
)
Len
()
int
{
return
len
(
o
)
}
func
(
o
byFirstTimestamp
)
Len
()
int
{
return
len
(
o
)
}
func
(
o
byFirstTimestamp
)
Swap
(
i
,
j
int
)
{
o
[
i
],
o
[
j
]
=
o
[
j
],
o
[
i
]
}
func
(
o
byFirstTimestamp
)
Swap
(
i
,
j
int
)
{
o
[
i
],
o
[
j
]
=
o
[
j
],
o
[
i
]
}
...
...
test/e2e/kubectl.go
View file @
bbb27cde
...
@@ -199,7 +199,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
...
@@ -199,7 +199,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
pods
,
err
:=
clusterState
()
.
WaitFor
(
atLeast
,
framework
.
PodStartTimeout
)
pods
,
err
:=
clusterState
()
.
WaitFor
(
atLeast
,
framework
.
PodStartTimeout
)
if
err
!=
nil
||
len
(
pods
)
<
atLeast
{
if
err
!=
nil
||
len
(
pods
)
<
atLeast
{
// TODO: Generalize integrating debug info into these tests so we always get debug info when we need it
// TODO: Generalize integrating debug info into these tests so we always get debug info when we need it
framework
.
DumpAllNamespaceInfo
(
c
,
ns
)
framework
.
DumpAllNamespaceInfo
(
c
,
f
.
Clientset_1_5
,
ns
)
framework
.
Failf
(
"Verified %v of %v pods , error : %v"
,
len
(
pods
),
atLeast
,
err
)
framework
.
Failf
(
"Verified %v of %v pods , error : %v"
,
len
(
pods
),
atLeast
,
err
)
}
}
}
}
...
...
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