Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3df94c6f
Unverified
Commit
3df94c6f
authored
May 14, 2019
by
Carl Bergquist
Committed by
GitHub
May 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serverlock: run tests async should be more linear time wise (#17059)
parent
6c7224c7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
pkg/infra/serverlock/serverlock_integration_test.go
+10
-15
No files found.
pkg/infra/serverlock/serverlock_integration_test.go
View file @
3df94c6f
...
@@ -7,34 +7,29 @@ import (
...
@@ -7,34 +7,29 @@ import (
"testing"
"testing"
"time"
"time"
.
"github.com/smartystreets/goconvey/convey
"
"github.com/stretchr/testify/assert
"
)
)
func
TestServerLok
(
t
*
testing
.
T
)
{
func
TestServerLok
(
t
*
testing
.
T
)
{
sl
:=
createTestableServerLock
(
t
)
sl
:=
createTestableServerLock
(
t
)
Convey
(
"Server lock integration tests"
,
t
,
func
()
{
counter
:=
0
counter
:=
0
var
err
error
fn
:=
func
()
{
counter
++
}
incCounter
:=
func
()
{
counter
++
}
atInterval
:=
time
.
Second
*
1
atInterval
:=
time
.
Second
*
1
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
//this time `fn` should be executed
//this time `fn` should be executed
So
(
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
incCounter
),
ShouldBeNil
)
assert
.
Nil
(
t
,
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
fn
)
)
//this should not execute `fn`
//this should not execute `fn`
So
(
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
incCounter
),
ShouldBeNil
)
assert
.
Nil
(
t
,
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
fn
))
So
(
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
incCounter
),
ShouldBeNil
)
assert
.
Nil
(
t
,
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
fn
))
So
(
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
incCounter
),
ShouldBeNil
)
So
(
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
incCounter
),
ShouldBeNil
)
// wait 5
second.
// wait 2
second.
<-
time
.
After
(
atInterval
*
2
)
<-
time
.
After
(
time
.
Second
*
2
)
// now `fn` should be executed again
// now `fn` should be executed again
err
=
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
incCounter
)
err
:=
sl
.
LockAndExecute
(
ctx
,
"test-operation"
,
atInterval
,
fn
)
So
(
err
,
ShouldBeNil
)
assert
.
Nil
(
t
,
err
)
So
(
counter
,
ShouldEqual
,
2
)
assert
.
Equal
(
t
,
counter
,
2
)
})
}
}
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