Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cerebro
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
cerebro
Commits
dbd62ba2
Commit
dbd62ba2
authored
9 years ago
by
Leonardo Menezes
Browse files
Options
Downloads
Patches
Plain Diff
test for ClearIndexCacheController
parent
204ce46b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/controllers/ClearIndexCacheControllerSpec.scala
+24
-8
24 additions, 8 deletions
test/controllers/ClearIndexCacheControllerSpec.scala
with
24 additions
and
8 deletions
test/controllers/ClearIndexCacheControllerSpec.scala
+
24
−
8
View file @
dbd62ba2
package
controllers
import
elastic.ElasticClient
import
elastic.
{
ElasticClient
,
ElasticResponse
}
import
exceptions.MissingRequiredParamException
import
models.CerebroRequest
import
org.specs2.Specification
...
...
@@ -8,24 +8,40 @@ import org.specs2.mock.Mockito
import
play.api.libs.json.Json
import
play.api.test.FakeApplication
import
scala.concurrent.duration.Duration
import
scala.concurrent.
{
Await
,
Future
}
object
ClearIndexCacheControllerSpec
extends
Specification
with
Mockito
{
def
is
=
s2
"""
ClearIndexCacheController should ${step(play.api.Play.start(FakeApplication()))}
clear cache for given indices $clusterName
should throw exception if indices is missing $missingIndices
invoke clearIndexCache $clearIndexCache
should throw exception if indices param is missing $missingIndices
${step(play.api.Play.stop(FakeApplication()))}
"""
val
controller
=
new
ClearIndexCacheController
def
clusterName
=
{
def
clearIndexCache
=
{
val
expectedResponse
=
Json
.
parse
(
"""
|{
| "_shards": {
| "total": 10,
| "successful": 5,
| "failed": 0
| }
|}
"""
.
stripMargin
)
val
body
=
Json
.
obj
(
"host"
->
"somehost"
,
"indices"
->
"a,b,c"
)
val
client
=
mock
[
ElasticClient
]
controller
.
processElasticRequest
(
CerebroRequest
(
body
),
client
)
client
.
clearIndexCache
(
"a,b,c"
,
"somehost"
)
returns
Future
.
successful
(
ElasticResponse
(
200
,
expectedResponse
))
val
response
=
Await
.
result
(
controller
.
processElasticRequest
(
CerebroRequest
(
body
),
client
),
Duration
(
"1s"
))
there
was
one
(
client
).
clearIndexCache
(
"a,b,c"
,
"somehost"
)
response
.
body
mustEqual
expectedResponse
response
.
status
mustEqual
200
}
def
missingIndices
=
{
...
...
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