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
ebcce18d
Commit
ebcce18d
authored
Feb 23, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort events by their first timestamp when dumping them
parent
b19102ba
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
util.go
test/e2e/util.go
+21
-2
No files found.
test/e2e/util.go
View file @
ebcce18d
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"os"
"os"
"os/exec"
"os/exec"
"path/filepath"
"path/filepath"
"sort"
"strconv"
"strconv"
"strings"
"strings"
"sync"
"sync"
...
@@ -1828,8 +1829,13 @@ func dumpAllNamespaceInfo(c *client.Client, namespace string) {
...
@@ -1828,8 +1829,13 @@ func dumpAllNamespaceInfo(c *client.Client, namespace string) {
events
,
err
:=
c
.
Events
(
namespace
)
.
List
(
api
.
ListOptions
{})
events
,
err
:=
c
.
Events
(
namespace
)
.
List
(
api
.
ListOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
for
_
,
e
:=
range
events
.
Items
{
// Sort events by their first timestamp
Logf
(
"event for %v: %v %v: %v"
,
e
.
InvolvedObject
.
Name
,
e
.
Source
,
e
.
Reason
,
e
.
Message
)
sortedEvents
:=
events
.
Items
if
len
(
sortedEvents
)
>
1
{
sort
.
Sort
(
byFirstTimestamp
(
sortedEvents
))
}
for
_
,
e
:=
range
sortedEvents
{
Logf
(
"At %v - event for %v: %v %v: %v"
,
e
.
FirstTimestamp
,
e
.
InvolvedObject
.
Name
,
e
.
Source
,
e
.
Reason
,
e
.
Message
)
}
}
// 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,
...
@@ -1840,6 +1846,19 @@ func dumpAllNamespaceInfo(c *client.Client, namespace string) {
...
@@ -1840,6 +1846,19 @@ func dumpAllNamespaceInfo(c *client.Client, namespace string) {
dumpAllNodeInfo
(
c
)
dumpAllNodeInfo
(
c
)
}
}
// byFirstTimestamp sorts a slice of events by first timestamp, using their involvedObject's name as a tie breaker.
type
byFirstTimestamp
[]
api
.
Event
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
)
Less
(
i
,
j
int
)
bool
{
if
o
[
i
]
.
FirstTimestamp
.
Equal
(
o
[
j
]
.
FirstTimestamp
)
{
return
o
[
i
]
.
InvolvedObject
.
Name
<
o
[
j
]
.
InvolvedObject
.
Name
}
return
o
[
i
]
.
FirstTimestamp
.
Before
(
o
[
j
]
.
FirstTimestamp
)
}
func
dumpAllPodInfo
(
c
*
client
.
Client
)
{
func
dumpAllPodInfo
(
c
*
client
.
Client
)
{
pods
,
err
:=
c
.
Pods
(
""
)
.
List
(
api
.
ListOptions
{})
pods
,
err
:=
c
.
Pods
(
""
)
.
List
(
api
.
ListOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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