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
cd23c5d1
Commit
cd23c5d1
authored
Aug 18, 2017
by
Mik Vyatskov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stackdriver Logging e2e: Explicitly check for docker and kubelet logs presence
parent
bd5e2d58
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
11 deletions
+39
-11
basic.go
test/e2e/instrumentation/logging/stackdrvier/basic.go
+15
-5
utils.go
test/e2e/instrumentation/logging/stackdrvier/utils.go
+10
-6
types.go
test/e2e/instrumentation/logging/utils/types.go
+1
-0
wait.go
test/e2e/instrumentation/logging/utils/wait.go
+13
-0
No files found.
test/e2e/instrumentation/logging/stackdrvier/basic.go
View file @
cd23c5d1
...
@@ -142,11 +142,21 @@ var _ = instrumentation.SIGDescribe("Cluster level logging implemented by Stackd
...
@@ -142,11 +142,21 @@ var _ = instrumentation.SIGDescribe("Cluster level logging implemented by Stackd
ginkgo
.
It
(
"should ingest system logs from all nodes"
,
func
()
{
ginkgo
.
It
(
"should ingest system logs from all nodes"
,
func
()
{
withLogProviderForScope
(
f
,
systemScope
,
func
(
p
*
sdLogProvider
)
{
withLogProviderForScope
(
f
,
systemScope
,
func
(
p
*
sdLogProvider
)
{
ginkgo
.
By
(
"Waiting for some system logs to ingest"
)
ginkgo
.
By
(
"Waiting for some kubelet logs to be ingested from each node"
,
func
()
{
nodeIds
:=
utils
.
GetNodeIds
(
f
.
ClientSet
)
nodeIds
:=
utils
.
GetNodeIds
(
f
.
ClientSet
)
c
:=
utils
.
NewLogChecker
(
p
,
utils
.
UntilFirstEntry
,
utils
.
JustTimeout
,
nodeIds
...
)
log
:=
fmt
.
Sprintf
(
"projects/%s/logs/kubelet"
,
framework
.
TestContext
.
CloudConfig
.
ProjectID
)
err
:=
utils
.
WaitForLogs
(
c
,
ingestionInterval
,
ingestionTimeout
)
c
:=
utils
.
NewLogChecker
(
p
,
utils
.
UntilFirstEntryFromLog
(
log
),
utils
.
JustTimeout
,
nodeIds
...
)
framework
.
ExpectNoError
(
err
)
err
:=
utils
.
WaitForLogs
(
c
,
ingestionInterval
,
ingestionTimeout
)
framework
.
ExpectNoError
(
err
)
})
ginkgo
.
By
(
"Waiting for some docker logs to be ingested from each node"
,
func
()
{
nodeIds
:=
utils
.
GetNodeIds
(
f
.
ClientSet
)
log
:=
fmt
.
Sprintf
(
"projects/%s/logs/docker"
,
framework
.
TestContext
.
CloudConfig
.
ProjectID
)
c
:=
utils
.
NewLogChecker
(
p
,
utils
.
UntilFirstEntryFromLog
(
log
),
utils
.
JustTimeout
,
nodeIds
...
)
err
:=
utils
.
WaitForLogs
(
c
,
ingestionInterval
,
ingestionTimeout
)
framework
.
ExpectNoError
(
err
)
})
})
})
})
})
})
})
test/e2e/instrumentation/logging/stackdrvier/utils.go
View file @
cd23c5d1
...
@@ -315,23 +315,27 @@ func (p *sdLogProvider) tryGetName(sdLogEntry sd.LogEntry) (string, bool) {
...
@@ -315,23 +315,27 @@ func (p *sdLogProvider) tryGetName(sdLogEntry sd.LogEntry) (string, bool) {
return
""
,
false
return
""
,
false
}
}
func
convertLogEntry
(
sdLogEntry
sd
.
LogEntry
)
(
utils
.
LogEntry
,
error
)
{
func
convertLogEntry
(
sdLogEntry
sd
.
LogEntry
)
(
entry
utils
.
LogEntry
,
err
error
)
{
entry
=
utils
.
LogEntry
{
LogName
:
sdLogEntry
.
LogName
}
if
sdLogEntry
.
TextPayload
!=
""
{
if
sdLogEntry
.
TextPayload
!=
""
{
return
utils
.
LogEntry
{
TextPayload
:
sdLogEntry
.
TextPayload
},
nil
entry
.
TextPayload
=
sdLogEntry
.
TextPayload
return
}
}
bytes
,
err
:=
sdLogEntry
.
JsonPayload
.
MarshalJSON
()
bytes
,
err
:=
sdLogEntry
.
JsonPayload
.
MarshalJSON
()
if
err
!=
nil
{
if
err
!=
nil
{
return
utils
.
LogEntry
{},
fmt
.
Errorf
(
"Failed to get jsonPayload from LogEntry %v"
,
sdLogEntry
)
err
=
fmt
.
Errorf
(
"Failed to get jsonPayload from LogEntry %v"
,
sdLogEntry
)
return
}
}
var
jsonObject
map
[
string
]
interface
{}
var
jsonObject
map
[
string
]
interface
{}
err
=
json
.
Unmarshal
(
bytes
,
&
jsonObject
)
err
=
json
.
Unmarshal
(
bytes
,
&
jsonObject
)
if
err
!=
nil
{
if
err
!=
nil
{
return
utils
.
LogEntry
{},
err
=
fmt
.
Errorf
(
"Failed to deserialize jsonPayload as json object %s"
,
string
(
bytes
[
:
]))
fmt
.
Errorf
(
"Failed to deserialize jsonPayload as json object %s"
,
string
(
bytes
[
:
]))
return
}
}
return
utils
.
LogEntry
{
JSONPayload
:
jsonObject
},
nil
entry
.
JSONPayload
=
jsonObject
return
}
}
func
pullAndAck
(
service
*
pubsub
.
Service
,
subs
*
pubsub
.
Subscription
)
([]
*
pubsub
.
ReceivedMessage
,
error
)
{
func
pullAndAck
(
service
*
pubsub
.
Service
,
subs
*
pubsub
.
Subscription
)
([]
*
pubsub
.
ReceivedMessage
,
error
)
{
...
...
test/e2e/instrumentation/logging/utils/types.go
View file @
cd23c5d1
...
@@ -30,6 +30,7 @@ var (
...
@@ -30,6 +30,7 @@ var (
// LogEntry represents a log entry, received from the logging backend.
// LogEntry represents a log entry, received from the logging backend.
type
LogEntry
struct
{
type
LogEntry
struct
{
LogName
string
TextPayload
string
TextPayload
string
JSONPayload
map
[
string
]
interface
{}
JSONPayload
map
[
string
]
interface
{}
}
}
...
...
test/e2e/instrumentation/logging/utils/wait.go
View file @
cd23c5d1
...
@@ -42,6 +42,19 @@ var UntilFirstEntry IngestionPred = func(_ string, entries []LogEntry) (bool, er
...
@@ -42,6 +42,19 @@ var UntilFirstEntry IngestionPred = func(_ string, entries []LogEntry) (bool, er
return
len
(
entries
)
>
0
,
nil
return
len
(
entries
)
>
0
,
nil
}
}
// UntilFirstEntryFromLog is a IngestionPred that checks that at least one
// entry from the log with a given name was ingested.
func
UntilFirstEntryFromLog
(
log
string
)
IngestionPred
{
return
func
(
_
string
,
entries
[]
LogEntry
)
(
bool
,
error
)
{
for
_
,
e
:=
range
entries
{
if
e
.
LogName
==
log
{
return
true
,
nil
}
}
return
false
,
nil
}
}
// TimeoutFun is a function that is called when the waiting times out.
// TimeoutFun is a function that is called when the waiting times out.
type
TimeoutFun
func
([]
string
,
[]
bool
)
error
type
TimeoutFun
func
([]
string
,
[]
bool
)
error
...
...
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