Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openwhisk-runtime-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Groundhog
openwhisk-runtime-python
Commits
078afc47
Commit
078afc47
authored
8 years ago
by
Rodric Rabbah
Committed by
Markus Thoemmes
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite test script.
Remove bash script.
parent
badf2eb4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/whisk/core/database/test/CacheConcurrencyTests.scala
+99
-37
99 additions, 37 deletions
.../src/whisk/core/database/test/CacheConcurrencyTests.scala
with
99 additions
and
37 deletions
tests/src/whisk/core/database/test/CacheConcurrencyTests.scala
+
99
−
37
View file @
078afc47
...
...
@@ -16,60 +16,122 @@
package
whisk.core.database.test
import
scala.util.Try
import
scala.collection.parallel._
import
scala.concurrent.forkjoin.ForkJoinPool
import
org.junit.runner.RunWith
import
org.scalatest.BeforeAndAfter
All
import
org.scalatest.BeforeAndAfter
import
org.scalatest.FlatSpec
import
org.scalatest.Matchers
import
org.scalatest.junit.JUnitRunner
import
common.TestUtils
import
common.TestUtils._
import
common.Wsk
import
common.WskProps
import
whisk.common.SimpleExec
import
common.WskTestHelpers
import
spray.json.JsString
import
whisk.common.TransactionId
@RunWith
(
classOf
[
JUnitRunner
])
class
CacheConcurrencyTests
extends
FlatSpec
with
BeforeAndAfterAll
with
Matchers
{
private
val
wsk
=
new
Wsk
with
WskTestHelpers
with
BeforeAndAfter
{
implicit
private
val
logger
=
this
implicit
private
val
transId
=
TransactionId
.
testing
implicit
private
val
wp
=
WskProps
()
private
val
wsk
=
new
Wsk
val
nExternalIters
=
1
val
nInternalIters
=
10
for
(
i
<-
1
to
nExternalIters
)
"the cache"
should
s
"support concurrent CRUD without bogus residual cache entries, iter ${i}"
in
{
try
{
val
scriptPath
=
TestUtils
.
getTestActionFilename
(
"CacheConcurrencyTests.sh"
)
val
actionFile
=
TestUtils
.
getTestActionFilename
(
"empty.js"
)
val
fullCmd
=
Seq
(
scriptPath
,
Wsk
.
baseCommand
.
mkString
,
actionFile
,
nInternalIters
.
toString
(),
"--auth"
,
wp
.
authKey
)
++
wp
.
overrides
val
(
stdout
,
stderr
,
exitCode
)
=
SimpleExec
.
syncRunCmd
(
fullCmd
)
if
(!
stdout
.
isEmpty
)
{
println
(
stdout
)
}
if
(!
stderr
.
isEmpty
)
{
println
(
this
,
stderr
)
}
exitCode
should
be
(
0
)
}
finally
{
// clean up
{
for
(
i
<-
1
to
nInternalIters
)
yield
Try
{
wsk
.
action
.
delete
(
s
"testy${i}"
)
}
}.
forall
(
_
.
isSuccess
)
val
nInternalIters
=
5
val
nThreads
=
nInternalIters
*
30
val
parallel
=
(
1
to
nInternalIters
).
par
parallel
.
tasksupport
=
new
ForkJoinTaskSupport
(
new
ForkJoinPool
(
nThreads
))
def
run
[
W
](
phase
:
String
)(
block
:
String
=>
W
)
=
parallel
.
map
{
i
=>
val
name
=
s
"testy${i}"
withClue
(
s
"$phase: failed for $name"
)
{
(
name
,
block
(
name
))
}
}
before
{
run
(
"pre-test sanitize"
)
{
name
=>
wsk
.
action
.
sanitize
(
name
)
}
}
after
{
run
(
"post-test sanitize"
)
{
name
=>
wsk
.
action
.
sanitize
(
name
)
}
}
for
(
n
<-
1
to
nExternalIters
)
"the cache"
should
s
"support concurrent CRUD without bogus residual cache entries, iter ${n}"
in
{
val
scriptPath
=
TestUtils
.
getTestActionFilename
(
"CacheConcurrencyTests.sh"
)
val
actionFile
=
TestUtils
.
getTestActionFilename
(
"empty.js"
)
run
(
"create"
)
{
name
=>
wsk
.
action
.
create
(
name
,
Some
(
actionFile
))
}
run
(
"update"
)
{
name
=>
wsk
.
action
.
create
(
name
,
None
,
update
=
true
)
}
run
(
"delete+get"
)
{
name
=>
// run 30 operations in parallel: 15 get, 1 delete, 14 more get
val
para
=
(
1
to
30
).
par
para
.
tasksupport
=
new
ForkJoinTaskSupport
(
new
ForkJoinPool
(
nThreads
))
para
.
map
{
i
=>
if
(
i
!=
16
)
{
val
rr
=
wsk
.
action
.
get
(
name
,
expectedExitCode
=
DONTCARE_EXIT
)
withClue
(
s
"expecting get to either succeed or fail with not found: $rr"
)
{
// some will succeed and some should fail with not found
rr
.
exitCode
should
(
be
(
SUCCESS_EXIT
)
or
be
(
NOT_FOUND
))
}
}
else
{
wsk
.
action
.
delete
(
name
)
}
}
}
run
(
"get after delete"
)
{
name
=>
wsk
.
action
.
get
(
name
,
expectedExitCode
=
NOT_FOUND
)
}
run
(
"recreate"
)
{
name
=>
wsk
.
action
.
create
(
name
,
Some
(
actionFile
))
}
run
(
"reupdate"
)
{
name
=>
wsk
.
action
.
create
(
name
,
None
,
parameters
=
Map
(
"color"
->
JsString
(
"red"
)),
update
=
true
)
}
run
(
"update+get"
)
{
name
=>
// run 30 operations in parallel: 15 get, 1 update, 14 more get
val
para
=
(
1
to
30
).
par
para
.
tasksupport
=
new
ForkJoinTaskSupport
(
new
ForkJoinPool
(
nThreads
))
para
.
map
{
i
=>
if
(
i
!=
16
)
{
wsk
.
action
.
get
(
name
)
}
else
{
wsk
.
action
.
create
(
name
,
None
,
parameters
=
Map
(
"color"
->
JsString
(
"blue"
)),
update
=
true
)
}
}
}
run
(
"get after update"
)
{
name
=>
wsk
.
action
.
get
(
name
)
}
map
{
case
(
name
,
rr
)
=>
withClue
(
s
"get after update: failed check for $name"
)
{
rr
.
stdout
should
include
(
"blue"
)
rr
.
stdout
should
not
include
(
"red"
)
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment