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
720b4c5c
Commit
720b4c5c
authored
Mar 14, 2017
by
Mikhail Vyatskov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ES cluster logging test
parent
a8d8542f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
cluster_logging_es_utils.go
test/e2e/cluster_logging_es_utils.go
+4
-4
cluster_logging_utils.go
test/e2e/cluster_logging_utils.go
+14
-3
No files found.
test/e2e/cluster_logging_es_utils.go
View file @
720b4c5c
...
@@ -166,15 +166,15 @@ func (logsProvider *esLogsProvider) ReadEntries(pod *loggingPod) []*logEntry {
...
@@ -166,15 +166,15 @@ func (logsProvider *esLogsProvider) ReadEntries(pod *loggingPod) []*logEntry {
return
nil
return
nil
}
}
query
:=
fmt
.
Sprintf
(
"kubernetes.pod_name:%s AND kubernetes.namespace_name:%s"
,
pod
.
Name
,
f
.
Namespace
.
Name
)
framework
.
Logf
(
"Sending a search request to Elasticsearch with the following query: %s"
,
query
)
// Ask Elasticsearch to return all the log lines that were tagged with the
// Ask Elasticsearch to return all the log lines that were tagged with the
// pod name. Ask for ten times as many log lines because duplication is possible.
// pod name. Ask for ten times as many log lines because duplication is possible.
body
,
err
:=
proxyRequest
.
Namespace
(
api
.
NamespaceSystem
)
.
body
,
err
:=
proxyRequest
.
Namespace
(
api
.
NamespaceSystem
)
.
Name
(
"elasticsearch-logging"
)
.
Name
(
"elasticsearch-logging"
)
.
Suffix
(
"_search"
)
.
Suffix
(
"_search"
)
.
// TODO: Change filter to only match records from current test run
Param
(
"q"
,
query
)
.
// after fluent-plugin-kubernetes_metadata_filter is enabled
// and optimize current query
Param
(
"q"
,
fmt
.
Sprintf
(
"tag:*%s*"
,
pod
.
Name
))
.
// Ask for more in case we included some unrelated records in our query
// Ask for more in case we included some unrelated records in our query
Param
(
"size"
,
strconv
.
Itoa
(
pod
.
ExpectedLinesNumber
*
10
))
.
Param
(
"size"
,
strconv
.
Itoa
(
pod
.
ExpectedLinesNumber
*
10
))
.
DoRaw
()
DoRaw
()
...
...
test/e2e/cluster_logging_utils.go
View file @
720b4c5c
...
@@ -18,8 +18,8 @@ package e2e
...
@@ -18,8 +18,8 @@ package e2e
import
(
import
(
"fmt"
"fmt"
"regexp"
"strconv"
"strconv"
"strings"
"time"
"time"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
...
@@ -42,6 +42,11 @@ const (
...
@@ -42,6 +42,11 @@ const (
loggingContainerMemoryRequest
=
10
*
1024
*
1024
loggingContainerMemoryRequest
=
10
*
1024
*
1024
)
)
var
(
// Regexp, matching the contents of log entries, parsed or not
logEntryMessageRegex
=
regexp
.
MustCompile
(
"(?:I
\\
d+
\\
d+:
\\
d+:
\\
d+.
\\
d+
\\
d+ logs_generator.go:67] )?(
\\
d+) .*"
)
)
// Type to track the progress of logs generating pod
// Type to track the progress of logs generating pod
type
loggingPod
struct
{
type
loggingPod
struct
{
// Name of the pod
// Name of the pod
...
@@ -77,8 +82,12 @@ type loggingTestConfig struct {
...
@@ -77,8 +82,12 @@ type loggingTestConfig struct {
}
}
func
(
entry
*
logEntry
)
getLogEntryNumber
()
(
int
,
bool
)
{
func
(
entry
*
logEntry
)
getLogEntryNumber
()
(
int
,
bool
)
{
chunks
:=
strings
.
Split
(
entry
.
Payload
,
" "
)
submatch
:=
logEntryMessageRegex
.
FindStringSubmatch
(
entry
.
Payload
)
lineNumber
,
err
:=
strconv
.
Atoi
(
strings
.
TrimSpace
(
chunks
[
0
]))
if
submatch
==
nil
||
len
(
submatch
)
<
2
{
return
0
,
false
}
lineNumber
,
err
:=
strconv
.
Atoi
(
submatch
[
1
])
return
lineNumber
,
err
==
nil
return
lineNumber
,
err
==
nil
}
}
...
@@ -212,6 +221,8 @@ func pullMissingLogsCount(logsProvider logsProvider, pod *loggingPod) int {
...
@@ -212,6 +221,8 @@ func pullMissingLogsCount(logsProvider logsProvider, pod *loggingPod) int {
func
getMissingLinesCount
(
logsProvider
logsProvider
,
pod
*
loggingPod
)
(
int
,
error
)
{
func
getMissingLinesCount
(
logsProvider
logsProvider
,
pod
*
loggingPod
)
(
int
,
error
)
{
entries
:=
logsProvider
.
ReadEntries
(
pod
)
entries
:=
logsProvider
.
ReadEntries
(
pod
)
framework
.
Logf
(
"Got %d entries from provider"
,
len
(
entries
))
for
_
,
entry
:=
range
entries
{
for
_
,
entry
:=
range
entries
{
lineNumber
,
ok
:=
entry
.
getLogEntryNumber
()
lineNumber
,
ok
:=
entry
.
getLogEntryNumber
()
if
!
ok
{
if
!
ok
{
...
...
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