Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-flow-metrics
Commits
f9ff0e5b
Commit
f9ff0e5b
authored
Dec 13, 2017
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make tests more reliable
parent
d52d20ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
flow_test.go
flow_test.go
+7
-7
No files found.
flow_test.go
View file @
f9ff0e5b
...
@@ -17,7 +17,7 @@ func TestBasic(t *testing.T) {
...
@@ -17,7 +17,7 @@ func TestBasic(t *testing.T) {
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
m
:=
new
(
Meter
)
m
:=
new
(
Meter
)
for
i
:=
0
;
i
<
1
00
;
i
++
{
for
i
:=
0
;
i
<
3
00
;
i
++
{
m
.
Mark
(
1000
)
m
.
Mark
(
1000
)
<-
ticker
.
C
<-
ticker
.
C
}
}
...
@@ -42,8 +42,8 @@ func TestBasic(t *testing.T) {
...
@@ -42,8 +42,8 @@ func TestBasic(t *testing.T) {
// get the right total
// get the right total
actual
=
m
.
Snapshot
()
actual
=
m
.
Snapshot
()
if
actual
.
Total
!=
1
40000
{
if
actual
.
Total
!=
3
40000
{
t
.
Errorf
(
"expected total %d, got %d"
,
12
0000
,
actual
.
Total
)
t
.
Errorf
(
"expected total %d, got %d"
,
34
0000
,
actual
.
Total
)
}
}
}()
}()
}
}
...
@@ -60,7 +60,7 @@ func TestShared(t *testing.T) {
...
@@ -60,7 +60,7 @@ func TestShared(t *testing.T) {
defer
wg
.
Done
()
defer
wg
.
Done
()
ticker
:=
time
.
NewTicker
(
40
*
time
.
Millisecond
)
ticker
:=
time
.
NewTicker
(
40
*
time
.
Millisecond
)
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
for
i
:=
0
;
i
<
1
00
;
i
++
{
for
i
:=
0
;
i
<
3
00
;
i
++
{
m
.
Mark
(
50
)
m
.
Mark
(
50
)
<-
ticker
.
C
<-
ticker
.
C
}
}
...
@@ -73,7 +73,7 @@ func TestShared(t *testing.T) {
...
@@ -73,7 +73,7 @@ func TestShared(t *testing.T) {
}
}
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
time
.
Sleep
(
40
*
1
00
*
time
.
Millisecond
)
time
.
Sleep
(
40
*
3
00
*
time
.
Millisecond
)
actual
:=
m
.
Snapshot
()
actual
:=
m
.
Snapshot
()
if
!
approxEq
(
actual
.
Rate
,
25000
,
250
)
{
if
!
approxEq
(
actual
.
Rate
,
25000
,
250
)
{
t
.
Errorf
(
"expected rate 25000 (±250), got %f"
,
actual
.
Rate
)
t
.
Errorf
(
"expected rate 25000 (±250), got %f"
,
actual
.
Rate
)
...
@@ -92,8 +92,8 @@ func TestShared(t *testing.T) {
...
@@ -92,8 +92,8 @@ func TestShared(t *testing.T) {
// get the right total
// get the right total
actual
=
m
.
Snapshot
()
actual
=
m
.
Snapshot
()
if
actual
.
Total
!=
1
40000
{
if
actual
.
Total
!=
3
40000
{
t
.
Errorf
(
"expected total %d, got %d"
,
1
40000
,
actual
.
Total
)
t
.
Errorf
(
"expected total %d, got %d"
,
3
40000
,
actual
.
Total
)
}
}
}()
}()
}
}
...
...
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