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
5644e787
Commit
5644e787
authored
8 years ago
by
Markus Thömmes
Committed by
rodric rabbah
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Harden replication test (#1834)
parent
d42ee545
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/src/whisk/core/database/test/ExtendedCouchDbRestClient.scala
+13
-4
13 additions, 4 deletions
.../whisk/core/database/test/ExtendedCouchDbRestClient.scala
tests/src/whisk/core/database/test/ReplicatorTests.scala
+8
-2
8 additions, 2 deletions
tests/src/whisk/core/database/test/ReplicatorTests.scala
with
21 additions
and
6 deletions
tests/src/whisk/core/database/test/ExtendedCouchDbRestClient.scala
+
13
−
4
View file @
5644e787
...
@@ -21,6 +21,7 @@ import akka.actor.ActorSystem
...
@@ -21,6 +21,7 @@ import akka.actor.ActorSystem
import
akka.http.scaladsl.model._
import
akka.http.scaladsl.model._
import
spray.json._
import
spray.json._
import
spray.json.DefaultJsonProtocol._
import
whisk.core.database.CouchDbRestClient
import
whisk.core.database.CouchDbRestClient
...
@@ -32,15 +33,23 @@ class ExtendedCouchDbRestClient(protocol: String, host: String, port: Int, usern
...
@@ -32,15 +33,23 @@ class ExtendedCouchDbRestClient(protocol: String, host: String, port: Int, usern
// http://docs.couchdb.org/en/1.6.1/api/server/common.html#get--
// http://docs.couchdb.org/en/1.6.1/api/server/common.html#get--
def
instanceInfo
()
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
def
instanceInfo
()
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
requestJson
(
mkRequest
(
HttpMethods
.
GET
,
Uri
./))
requestJson
[
JsObject
](
mkRequest
(
HttpMethods
.
GET
,
Uri
./))
// http://docs.couchdb.org/en/1.6.1/api/server/common.html#all-dbs
def
dbs
()
:
Future
[
Either
[
StatusCode
,
List
[
String
]]]
=
{
implicit
val
ec
=
system
.
dispatcher
requestJson
[
JsArray
](
mkRequest
(
HttpMethods
.
GET
,
uri
(
"_all_dbs"
))).
map
{
either
=>
either
.
right
.
map
(
_
.
convertTo
[
List
[
String
]])
}
}
// http://docs.couchdb.org/en/1.6.1/api/database/common.html#put--db
// http://docs.couchdb.org/en/1.6.1/api/database/common.html#put--db
def
createDb
()
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
def
createDb
()
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
requestJson
(
mkRequest
(
HttpMethods
.
PUT
,
uri
(
db
)))
requestJson
[
JsObject
]
(
mkRequest
(
HttpMethods
.
PUT
,
uri
(
db
)))
// http://docs.couchdb.org/en/1.6.1/api/database/common.html#delete--db
// http://docs.couchdb.org/en/1.6.1/api/database/common.html#delete--db
def
deleteDb
()
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
def
deleteDb
()
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
requestJson
(
mkRequest
(
HttpMethods
.
DELETE
,
uri
(
db
)))
requestJson
[
JsObject
]
(
mkRequest
(
HttpMethods
.
DELETE
,
uri
(
db
)))
// http://docs.couchdb.org/en/1.6.1/api/database/bulk-api.html#get--db-_all_docs
// http://docs.couchdb.org/en/1.6.1/api/database/bulk-api.html#get--db-_all_docs
def
getAllDocs
(
skip
:
Option
[
Int
]
=
None
,
limit
:
Option
[
Int
]
=
None
,
includeDocs
:
Option
[
Boolean
]
=
None
)
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
{
def
getAllDocs
(
skip
:
Option
[
Int
]
=
None
,
limit
:
Option
[
Int
]
=
None
,
includeDocs
:
Option
[
Boolean
]
=
None
)
:
Future
[
Either
[
StatusCode
,
JsObject
]]
=
{
...
@@ -55,6 +64,6 @@ class ExtendedCouchDbRestClient(protocol: String, host: String, port: Int, usern
...
@@ -55,6 +64,6 @@ class ExtendedCouchDbRestClient(protocol: String, host: String, port: Int, usern
}).
toMap
}).
toMap
val
url
=
uri
(
db
,
"_all_docs"
).
withQuery
(
Uri
.
Query
(
argMap
))
val
url
=
uri
(
db
,
"_all_docs"
).
withQuery
(
Uri
.
Query
(
argMap
))
requestJson
(
mkRequest
(
HttpMethods
.
GET
,
url
))
requestJson
[
JsObject
]
(
mkRequest
(
HttpMethods
.
GET
,
url
))
}
}
}
}
This diff is collapsed.
Click to expand it.
tests/src/whisk/core/database/test/ReplicatorTests.scala
+
8
−
2
View file @
5644e787
...
@@ -74,6 +74,12 @@ class ReplicatorTests extends FlatSpec
...
@@ -74,6 +74,12 @@ class ReplicatorTests extends FlatSpec
println
(
s
"Creating database: $name"
)
println
(
s
"Creating database: $name"
)
val
db
=
new
ExtendedCouchDbRestClient
(
config
.
dbProtocol
,
config
.
dbHost
,
config
.
dbPort
.
toInt
,
config
.
dbUsername
,
config
.
dbPassword
,
name
)
val
db
=
new
ExtendedCouchDbRestClient
(
config
.
dbProtocol
,
config
.
dbHost
,
config
.
dbPort
.
toInt
,
config
.
dbUsername
,
config
.
dbPassword
,
name
)
db
.
createDb
().
futureValue
shouldBe
'right
db
.
createDb
().
futureValue
shouldBe
'right
retry
({
val
list
=
db
.
dbs
().
futureValue
.
right
.
get
list
should
contain
(
name
)
},
N
=
10
,
waitBeforeRetry
=
Some
(
500.
milliseconds
))
db
db
}
}
...
@@ -82,8 +88,8 @@ class ReplicatorTests extends FlatSpec
...
@@ -82,8 +88,8 @@ class ReplicatorTests extends FlatSpec
println
(
s
"Removing database: $name"
)
println
(
s
"Removing database: $name"
)
val
db
=
new
ExtendedCouchDbRestClient
(
config
.
dbProtocol
,
config
.
dbHost
,
config
.
dbPort
.
toInt
,
config
.
dbUsername
,
config
.
dbPassword
,
name
)
val
db
=
new
ExtendedCouchDbRestClient
(
config
.
dbProtocol
,
config
.
dbHost
,
config
.
dbPort
.
toInt
,
config
.
dbUsername
,
config
.
dbPassword
,
name
)
retry
({
retry
({
val
delete
=
db
.
deleteDb
()
val
delete
=
db
.
deleteDb
()
.
futureValue
if
(!
ignoreFailure
)
delete
.
futureValue
shouldBe
'right
if
(!
ignoreFailure
)
delete
shouldBe
'right
},
N
=
10
,
waitBeforeRetry
=
Some
(
500.
milliseconds
))
},
N
=
10
,
waitBeforeRetry
=
Some
(
500.
milliseconds
))
db
db
}
}
...
...
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