Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
ffceed6d
Commit
ffceed6d
authored
Apr 24, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make queue fairness test more deterministic
parent
862391be
Pipeline
#3923
failed with stage
in 27 minutes and 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
21 deletions
+14
-21
Main.hs
tests/queue/Main.hs
+14
-21
No files found.
tests/queue/Main.hs
View file @
ffceed6d
...
...
@@ -138,35 +138,28 @@ testExceptions = do
testFairness
::
IO
()
testFairness
=
do
k
<-
genSecret
let
settings
=
defaultJobSettings
2
k
let
settings
=
defaultJobSettings
1
k
st
::
JobsState
JobT
[
String
]
()
<-
newJobsState
settings
defaultPrios
runningJs
<-
newTVarIO
(
Counts
0
0
)
let
j
jobt
_jHandle
_inp
_l
=
do
atomically
$
modifyTVar
runningJs
(
inc
jobt
)
threadDelay
jobDuration
atomically
$
modifyTVar
runningJs
(
dec
jobt
)
pickedSchedule
<-
newMVar
(
JobSchedule
mempty
)
let
j
jobt
_jHandle
_inp
_l
=
addJobToSchedule
jobt
pickedSchedule
jobs
=
[
(
A
,
j
A
)
,
(
A
,
j
A
)
,
(
B
,
j
B
)
,
(
A
,
j
A
)
,
(
A
,
j
A
)
]
_jids
<-
forM
jobs
$
\
(
t
,
f
)
->
do
pushJob
t
()
f
settings
st
threadDelay
initialDelay
r1
<-
readTVarIO
runningJs
r1
`
shouldBe
`
(
Counts
2
0
)
threadDelay
jobDuration
r2
<-
readTVarIO
runningJs
r2
`
shouldBe
`
(
Counts
1
1
)
-- MOST IMPORTANT CHECK: the B got picked after the
-- two As, because it was inserted right after them
-- and has equal priority.
threadDelay
jobDuration
r3
<-
readTVarIO
runningJs
r3
`
shouldBe
`
(
Counts
1
0
)
time
<-
getCurrentTime
-- in this scenario we simulate two types of jobs all with
-- all the same level of priority: our queue implementation
-- will behave as a classic FIFO, keeping into account the
-- time of arrival.
atomically
$
forM_
(
zip
[
0
,
2
..
]
jobs
)
$
\
(
timeDelta
,
(
t
,
f
))
->
void
$
pushJobWithTime
(
addUTCTime
(
fromInteger
timeDelta
)
time
)
t
()
f
settings
st
threadDelay
jobDuration
r4
<-
readTVarIO
runningJs
r4
`
shouldBe
`
(
Counts
0
0
)
finalSchedule
<-
readMVar
pickedSchedule
finalSchedule
`
shouldBe
`
JobSchedule
(
fromList
[
A
,
A
,
B
,
A
,
A
])
newtype
MyDummyMonad
a
=
MyDummyMonad
{
_MyDummyMonad
::
GargM
Env
GargError
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