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
680ddd49
Commit
680ddd49
authored
Nov 12, 2018
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! add longest_running_processor_microseconds metric
fix data race
parent
fd77aa5a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
12 deletions
+53
-12
metrics_test.go
staging/src/k8s.io/client-go/util/workqueue/metrics_test.go
+53
-12
No files found.
staging/src/k8s.io/client-go/util/workqueue/metrics_test.go
View file @
680ddd49
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
workqueue
import
(
"sync"
"testing"
"time"
...
...
@@ -68,20 +69,60 @@ type testMetric struct {
observedCount
int
notifyCh
chan
<-
struct
{}
lock
sync
.
Mutex
}
func
(
m
*
testMetric
)
Inc
()
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
inc
++
m
.
notify
()
}
func
(
m
*
testMetric
)
Dec
()
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
dec
++
m
.
notify
()
}
func
(
m
*
testMetric
)
Set
(
f
float64
)
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
set
=
f
m
.
notify
()
}
func
(
m
*
testMetric
)
Inc
()
{
m
.
inc
++
;
m
.
notify
()
}
func
(
m
*
testMetric
)
Dec
()
{
m
.
dec
++
;
m
.
notify
()
}
func
(
m
*
testMetric
)
Set
(
f
float64
)
{
m
.
set
=
f
;
m
.
notify
()
}
func
(
m
*
testMetric
)
Observe
(
f
float64
)
{
m
.
observedValue
=
f
;
m
.
observedCount
++
;
m
.
notify
()
}
func
(
m
*
testMetric
)
Observe
(
f
float64
)
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
observedValue
=
f
m
.
observedCount
++
m
.
notify
()
}
func
(
m
*
testMetric
)
gaugeValue
()
float64
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
if
m
.
set
!=
0
{
return
m
.
set
}
return
float64
(
m
.
inc
-
m
.
dec
)
}
func
(
m
*
testMetric
)
observationValue
()
float64
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
return
m
.
observedValue
}
func
(
m
*
testMetric
)
observationCount
()
int
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
return
m
.
observedCount
}
func
(
m
*
testMetric
)
notify
()
{
if
m
.
notifyCh
!=
nil
{
m
.
notifyCh
<-
struct
{}{}
...
...
@@ -172,10 +213,10 @@ func TestMetrics(t *testing.T) {
t
.
Errorf
(
"Expected %v, got %v"
,
"foo"
,
i
)
}
if
e
,
a
:=
50.0
,
mp
.
latency
.
observ
edValue
;
e
!=
a
{
if
e
,
a
:=
50.0
,
mp
.
latency
.
observ
ationValue
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
if
e
,
a
:=
1
,
mp
.
latency
.
observ
edCount
;
e
!=
a
{
if
e
,
a
:=
1
,
mp
.
latency
.
observ
ationCount
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
if
e
,
a
:=
0.0
,
mp
.
depth
.
gaugeValue
();
e
!=
a
{
...
...
@@ -202,10 +243,10 @@ func TestMetrics(t *testing.T) {
// Finish it up
q
.
Done
(
i
)
if
e
,
a
:=
25.0
,
mp
.
duration
.
observ
edValue
;
e
!=
a
{
if
e
,
a
:=
25.0
,
mp
.
duration
.
observ
ationValue
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
if
e
,
a
:=
1
,
mp
.
duration
.
observ
edCount
;
e
!=
a
{
if
e
,
a
:=
1
,
mp
.
duration
.
observ
ationCount
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
...
...
@@ -220,10 +261,10 @@ func TestMetrics(t *testing.T) {
t
.
Errorf
(
"Expected %v, got %v"
,
"foo"
,
i
)
}
if
e
,
a
:=
25.0
,
mp
.
latency
.
observ
edValue
;
e
!=
a
{
if
e
,
a
:=
25.0
,
mp
.
latency
.
observ
ationValue
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
if
e
,
a
:=
2
,
mp
.
latency
.
observ
edCount
;
e
!=
a
{
if
e
,
a
:=
2
,
mp
.
latency
.
observ
ationCount
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
...
...
@@ -243,10 +284,10 @@ func TestMetrics(t *testing.T) {
// Finish that one up
q
.
Done
(
i
)
if
e
,
a
:=
1000.0
,
mp
.
duration
.
observ
edValue
;
e
!=
a
{
if
e
,
a
:=
1000.0
,
mp
.
duration
.
observ
ationValue
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
if
e
,
a
:=
2
,
mp
.
duration
.
observ
edCount
;
e
!=
a
{
if
e
,
a
:=
2
,
mp
.
duration
.
observ
ationCount
()
;
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
}
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