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
46945ab5
Commit
46945ab5
authored
Jan 08, 2016
by
Marek Grabowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19402 from gmarek/json
Implement JSON printing for test summaries
parents
1f0a074b
f5a41823
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
25 deletions
+46
-25
framework.go
test/e2e/framework.go
+1
-1
log_size_monitoring.go
test/e2e/log_size_monitoring.go
+30
-13
metrics_util.go
test/e2e/metrics_util.go
+3
-1
resource_usage_gatherer.go
test/e2e/resource_usage_gatherer.go
+12
-10
No files found.
test/e2e/framework.go
View file @
46945ab5
...
@@ -152,7 +152,7 @@ func (f *Framework) afterEach() {
...
@@ -152,7 +152,7 @@ func (f *Framework) afterEach() {
summaries
:=
make
([]
TestDataSummary
,
0
)
summaries
:=
make
([]
TestDataSummary
,
0
)
if
testContext
.
GatherKubeSystemResourceUsageData
{
if
testContext
.
GatherKubeSystemResourceUsageData
{
summaries
=
append
(
summaries
,
f
.
gatherer
.
stopAndSummarize
([]
int
{
50
,
90
,
99
,
100
},
f
.
addonResourceConstraints
))
summaries
=
append
(
summaries
,
f
.
gatherer
.
stopAndSummarize
([]
int
{
90
,
99
},
f
.
addonResourceConstraints
))
}
}
if
testContext
.
GatherLogsSizes
{
if
testContext
.
GatherLogsSizes
{
...
...
test/e2e/log_size_monitoring.go
View file @
46945ab5
...
@@ -75,8 +75,15 @@ type LogsSizeVerifier struct {
...
@@ -75,8 +75,15 @@ type LogsSizeVerifier struct {
workers
[]
*
LogSizeGatherer
workers
[]
*
LogSizeGatherer
}
}
type
SingleLogSummary
struct
{
AverageGenerationRate
int
NumberOfProbes
int
}
type
LogSizeDataTimeseries
map
[
string
]
map
[
string
][]
TimestampedSize
// node -> file -> data
// node -> file -> data
type
LogsSizeDataSummary
map
[
string
]
map
[
string
]
[]
TimestampedSize
type
LogsSizeDataSummary
map
[
string
]
map
[
string
]
SingleLogSummary
// TODO: make sure that we don't need locking here
// TODO: make sure that we don't need locking here
func
(
s
*
LogsSizeDataSummary
)
PrintHumanReadable
()
string
{
func
(
s
*
LogsSizeDataSummary
)
PrintHumanReadable
()
string
{
...
@@ -86,12 +93,7 @@ func (s *LogsSizeDataSummary) PrintHumanReadable() string {
...
@@ -86,12 +93,7 @@ func (s *LogsSizeDataSummary) PrintHumanReadable() string {
for
k
,
v
:=
range
*
s
{
for
k
,
v
:=
range
*
s
{
fmt
.
Fprintf
(
w
,
"%v
\t\t\t\n
"
,
k
)
fmt
.
Fprintf
(
w
,
"%v
\t\t\t\n
"
,
k
)
for
path
,
data
:=
range
v
{
for
path
,
data
:=
range
v
{
if
len
(
data
)
>
1
{
fmt
.
Fprintf
(
w
,
"
\t
%v
\t
%v
\t
%v
\n
"
,
path
,
data
.
AverageGenerationRate
,
data
.
NumberOfProbes
)
last
:=
data
[
len
(
data
)
-
1
]
first
:=
data
[
0
]
rate
:=
(
last
.
size
-
first
.
size
)
/
int
(
last
.
timestamp
.
Sub
(
first
.
timestamp
)
/
time
.
Second
)
fmt
.
Fprintf
(
w
,
"
\t
%v
\t
%v
\t
%v
\n
"
,
path
,
rate
,
len
(
data
))
}
}
}
}
}
w
.
Flush
()
w
.
Flush
()
...
@@ -99,11 +101,11 @@ func (s *LogsSizeDataSummary) PrintHumanReadable() string {
...
@@ -99,11 +101,11 @@ func (s *LogsSizeDataSummary) PrintHumanReadable() string {
}
}
func
(
s
*
LogsSizeDataSummary
)
PrintJSON
()
string
{
func
(
s
*
LogsSizeDataSummary
)
PrintJSON
()
string
{
return
"JSON printer not implemented for LogsSizeDataSummary"
return
prettyPrintJSON
(
*
s
)
}
}
type
LogsSizeData
struct
{
type
LogsSizeData
struct
{
data
Log
sSizeDataSummary
data
Log
SizeDataTimeseries
lock
sync
.
Mutex
lock
sync
.
Mutex
}
}
...
@@ -116,7 +118,7 @@ type WorkItem struct {
...
@@ -116,7 +118,7 @@ type WorkItem struct {
}
}
func
prepareData
(
masterAddress
string
,
nodeAddresses
[]
string
)
LogsSizeData
{
func
prepareData
(
masterAddress
string
,
nodeAddresses
[]
string
)
LogsSizeData
{
data
:=
make
(
Log
sSizeDataSummary
)
data
:=
make
(
Log
SizeDataTimeseries
)
ips
:=
append
(
nodeAddresses
,
masterAddress
)
ips
:=
append
(
nodeAddresses
,
masterAddress
)
for
_
,
ip
:=
range
ips
{
for
_
,
ip
:=
range
ips
{
data
[
ip
]
=
make
(
map
[
string
][]
TimestampedSize
)
data
[
ip
]
=
make
(
map
[
string
][]
TimestampedSize
)
...
@@ -170,9 +172,24 @@ func NewLogsVerifier(c *client.Client, stopChannel chan bool) *LogsSizeVerifier
...
@@ -170,9 +172,24 @@ func NewLogsVerifier(c *client.Client, stopChannel chan bool) *LogsSizeVerifier
return
verifier
return
verifier
}
}
// PrintData returns a string with formated results
// GetSummary returns a summary (average generation rate and number of probes) of the data gathered by LogSizeVerifier
func
(
v
*
LogsSizeVerifier
)
GetSummary
()
*
LogsSizeDataSummary
{
func
(
s
*
LogsSizeVerifier
)
GetSummary
()
*
LogsSizeDataSummary
{
return
&
v
.
data
.
data
result
:=
make
(
LogsSizeDataSummary
)
for
k
,
v
:=
range
s
.
data
.
data
{
result
[
k
]
=
make
(
map
[
string
]
SingleLogSummary
)
for
path
,
data
:=
range
v
{
if
len
(
data
)
>
1
{
last
:=
data
[
len
(
data
)
-
1
]
first
:=
data
[
0
]
rate
:=
(
last
.
size
-
first
.
size
)
/
int
(
last
.
timestamp
.
Sub
(
first
.
timestamp
)
/
time
.
Second
)
result
[
k
][
path
]
=
SingleLogSummary
{
AverageGenerationRate
:
rate
,
NumberOfProbes
:
len
(
data
),
}
}
}
}
return
&
result
}
}
// Run starts log size gathering. It starts a gorouting for every worker and then blocks until stopChannel is closed
// Run starts log size gathering. It starts a gorouting for every worker and then blocks until stopChannel is closed
...
...
test/e2e/metrics_util.go
View file @
46945ab5
...
@@ -70,7 +70,7 @@ func (m *metricsForE2E) PrintHumanReadable() string {
...
@@ -70,7 +70,7 @@ func (m *metricsForE2E) PrintHumanReadable() string {
}
}
func
(
m
*
metricsForE2E
)
PrintJSON
()
string
{
func
(
m
*
metricsForE2E
)
PrintJSON
()
string
{
return
"JSON printer not implemented for Metrics"
return
prettyPrintJSON
(
*
m
)
}
}
var
InterestingApiServerMetrics
=
[]
string
{
var
InterestingApiServerMetrics
=
[]
string
{
...
@@ -402,10 +402,12 @@ func VerifySchedulerLatency(c *client.Client) error {
...
@@ -402,10 +402,12 @@ func VerifySchedulerLatency(c *client.Client) error {
func
prettyPrintJSON
(
metrics
interface
{})
string
{
func
prettyPrintJSON
(
metrics
interface
{})
string
{
output
:=
&
bytes
.
Buffer
{}
output
:=
&
bytes
.
Buffer
{}
if
err
:=
json
.
NewEncoder
(
output
)
.
Encode
(
metrics
);
err
!=
nil
{
if
err
:=
json
.
NewEncoder
(
output
)
.
Encode
(
metrics
);
err
!=
nil
{
Logf
(
"Error building encoder: %v"
,
err
)
return
""
return
""
}
}
formatted
:=
&
bytes
.
Buffer
{}
formatted
:=
&
bytes
.
Buffer
{}
if
err
:=
json
.
Indent
(
formatted
,
output
.
Bytes
(),
""
,
" "
);
err
!=
nil
{
if
err
:=
json
.
Indent
(
formatted
,
output
.
Bytes
(),
""
,
" "
);
err
!=
nil
{
Logf
(
"Error indenting: %v"
,
err
)
return
""
return
""
}
}
return
string
(
formatted
.
Bytes
())
return
string
(
formatted
.
Bytes
())
...
...
test/e2e/resource_usage_gatherer.go
View file @
46945ab5
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"fmt"
"fmt"
"math"
"math"
"sort"
"sort"
"strconv"
"strings"
"strings"
"sync"
"sync"
"text/tabwriter"
"text/tabwriter"
...
@@ -48,12 +49,13 @@ type containerResourceGatherer struct {
...
@@ -48,12 +49,13 @@ type containerResourceGatherer struct {
}
}
type
singleContainerSummary
struct
{
type
singleContainerSummary
struct
{
n
ame
string
N
ame
string
c
pu
float64
C
pu
float64
m
em
int64
M
em
int64
}
}
type
ResourceUsageSummary
map
[
int
][]
singleContainerSummary
// we can't have int here, as JSON does not accept integer keys.
type
ResourceUsageSummary
map
[
string
][]
singleContainerSummary
func
(
s
*
ResourceUsageSummary
)
PrintHumanReadable
()
string
{
func
(
s
*
ResourceUsageSummary
)
PrintHumanReadable
()
string
{
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
...
@@ -62,7 +64,7 @@ func (s *ResourceUsageSummary) PrintHumanReadable() string {
...
@@ -62,7 +64,7 @@ func (s *ResourceUsageSummary) PrintHumanReadable() string {
buf
.
WriteString
(
fmt
.
Sprintf
(
"%v percentile:
\n
"
,
perc
))
buf
.
WriteString
(
fmt
.
Sprintf
(
"%v percentile:
\n
"
,
perc
))
fmt
.
Fprintf
(
w
,
"container
\t
cpu(cores)
\t
memory(MB)
\n
"
)
fmt
.
Fprintf
(
w
,
"container
\t
cpu(cores)
\t
memory(MB)
\n
"
)
for
_
,
summary
:=
range
summaries
{
for
_
,
summary
:=
range
summaries
{
fmt
.
Fprintf
(
w
,
"%q
\t
%.3f
\t
%.2f
\n
"
,
summary
.
name
,
summary
.
cpu
,
float64
(
summary
.
m
em
)
/
(
1024
*
1024
))
fmt
.
Fprintf
(
w
,
"%q
\t
%.3f
\t
%.2f
\n
"
,
summary
.
Name
,
summary
.
Cpu
,
float64
(
summary
.
M
em
)
/
(
1024
*
1024
))
}
}
w
.
Flush
()
w
.
Flush
()
}
}
...
@@ -70,7 +72,7 @@ func (s *ResourceUsageSummary) PrintHumanReadable() string {
...
@@ -70,7 +72,7 @@ func (s *ResourceUsageSummary) PrintHumanReadable() string {
}
}
func
(
s
*
ResourceUsageSummary
)
PrintJSON
()
string
{
func
(
s
*
ResourceUsageSummary
)
PrintJSON
()
string
{
return
"JSON printer not implemented for ResourceUsageSummary"
return
prettyPrintJSON
(
*
s
)
}
}
func
(
g
*
containerResourceGatherer
)
startGatheringData
(
c
*
client
.
Client
,
period
time
.
Duration
)
{
func
(
g
*
containerResourceGatherer
)
startGatheringData
(
c
*
client
.
Client
,
period
time
.
Duration
)
{
...
@@ -115,10 +117,10 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai
...
@@ -115,10 +117,10 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai
for
_
,
perc
:=
range
percentiles
{
for
_
,
perc
:=
range
percentiles
{
for
_
,
name
:=
range
sortedKeys
{
for
_
,
name
:=
range
sortedKeys
{
usage
:=
stats
[
perc
][
name
]
usage
:=
stats
[
perc
][
name
]
summary
[
perc
]
=
append
(
summary
[
perc
],
singleContainerSummary
{
summary
[
strconv
.
Itoa
(
perc
)]
=
append
(
summary
[
strconv
.
Itoa
(
perc
)
],
singleContainerSummary
{
n
ame
:
name
,
N
ame
:
name
,
c
pu
:
usage
.
CPUUsageInCores
,
C
pu
:
usage
.
CPUUsageInCores
,
m
em
:
usage
.
MemoryWorkingSetInBytes
,
M
em
:
usage
.
MemoryWorkingSetInBytes
,
})
})
// Verifying 99th percentile of resource usage
// Verifying 99th percentile of resource usage
if
perc
==
99
{
if
perc
==
99
{
...
...
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