-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test triggered circuit breaker during multisearch
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...4s-tests/src/test/scala/com/sksamuel/elastic4s/search/MultiSearchCircuitBreakerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.sksamuel.elastic4s.search | ||
|
||
import scala.util.Try | ||
|
||
import com.sksamuel.elastic4s.testkit.DockerTests | ||
import org.scalatest.BeforeAndAfterAll | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class MultiSearchCircuitBreakerTest | ||
extends AnyFlatSpec | ||
with DockerTests | ||
with Matchers | ||
with BeforeAndAfterAll { | ||
|
||
override def beforeAll(): Unit = | ||
Try { | ||
client.execute { | ||
clusterTransientSettings(Map("indices.breaker.total.limit" -> "1b")) | ||
}.await | ||
} | ||
|
||
"a multi search request" should "return an error when the circuit breaker is triggered" in { | ||
val request = multi(search("_all")) | ||
val response = client.execute(request).await | ||
response.isError shouldBe true | ||
response.status shouldEqual 429 | ||
response.error.`type` shouldBe "circuit_breaking_exception" | ||
} | ||
|
||
override def afterAll(): Unit = | ||
Try { | ||
client.execute { | ||
clusterTransientSettings(Map("indices.breaker.total.limit" -> null)) | ||
}.await | ||
} | ||
} |