Increase timeout for hystrix tests (#4762)

* Increase timeout for hystrix tests

* remove unused import
This commit is contained in:
Lauri Tulmin 2021-12-01 18:25:13 +02:00 committed by GitHub
parent 1ff51fb2a8
commit b6aaa35813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 7 deletions

View File

@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import com.netflix.hystrix.HystrixCommandProperties
import com.netflix.hystrix.HystrixObservableCommand
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import rx.Observable
@ -17,7 +18,7 @@ class HystrixObservableChainTest extends AgentInstrumentationSpecification {
setup:
def result = runWithSpan("parent") {
def val = new HystrixObservableCommand<String>(asKey("ExampleGroup")) {
def val = new HystrixObservableCommand<String>(setter("ExampleGroup")) {
private String tracedMethod() {
runInternalSpan("tracedMethod")
return "Hello"
@ -35,7 +36,7 @@ class HystrixObservableChainTest extends AgentInstrumentationSpecification {
.map {
it.toUpperCase()
}.flatMap { str ->
new HystrixObservableCommand<String>(asKey("OtherGroup")) {
new HystrixObservableCommand<String>(setter("OtherGroup")) {
private String anotherTracedMethod() {
runInternalSpan("anotherTracedMethod")
return "$str!"
@ -98,4 +99,11 @@ class HystrixObservableChainTest extends AgentInstrumentationSpecification {
}
}
}
def setter(String key) {
def setter = new HystrixObservableCommand.Setter(asKey(key))
setter.andCommandPropertiesDefaults(new HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(10_000))
return setter
}
}

View File

@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import com.netflix.hystrix.HystrixCommandProperties
import com.netflix.hystrix.HystrixObservable
import com.netflix.hystrix.HystrixObservableCommand
import com.netflix.hystrix.exception.HystrixRuntimeException
@ -24,7 +25,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
def observeOnFn = observeOn
def subscribeOnFn = subscribeOn
def result = runWithSpan("parent") {
def val = operation new HystrixObservableCommand<String>(asKey("ExampleGroup")) {
def val = operation new HystrixObservableCommand<String>(setter("ExampleGroup")) {
private String tracedMethod() {
runInternalSpan("tracedMethod")
return "Hello!"
@ -116,7 +117,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
def observeOnFn = observeOn
def subscribeOnFn = subscribeOn
def result = runWithSpan("parent") {
def val = operation new HystrixObservableCommand<String>(asKey("ExampleGroup")) {
def val = operation new HystrixObservableCommand<String>(setter("ExampleGroup")) {
@Override
protected Observable<String> construct() {
def err = Observable.defer {
@ -214,7 +215,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
when:
runWithSpan("parent") {
operation new HystrixObservableCommand<String>(asKey("FailingGroup")) {
operation new HystrixObservableCommand<String>(setter("FailingGroup")) {
@Override
protected Observable<String> construct() {
@ -305,4 +306,11 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
throw ex
}
}
def setter(String key) {
def setter = new HystrixObservableCommand.Setter(asKey(key))
setter.andCommandPropertiesDefaults(new HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(10_000))
return setter
}
}

View File

@ -4,6 +4,7 @@
*/
import com.netflix.hystrix.HystrixCommand
import com.netflix.hystrix.HystrixCommandProperties
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import java.util.concurrent.BlockingQueue
@ -17,7 +18,7 @@ class HystrixTest extends AgentInstrumentationSpecification {
def "test command #action"() {
setup:
def command = new HystrixCommand<String>(asKey("ExampleGroup")) {
def command = new HystrixCommand<String>(setter("ExampleGroup")) {
@Override
protected String run() throws Exception {
return tracedMethod()
@ -77,7 +78,7 @@ class HystrixTest extends AgentInstrumentationSpecification {
def "test command #action fallback"() {
setup:
def command = new HystrixCommand<String>(asKey("ExampleGroup")) {
def command = new HystrixCommand<String>(setter("ExampleGroup")) {
@Override
protected String run() throws Exception {
throw new IllegalArgumentException()
@ -138,4 +139,11 @@ class HystrixTest extends AgentInstrumentationSpecification {
queue.take()
}
}
def setter(String key) {
def setter = new HystrixCommand.Setter(asKey(key))
setter.andCommandPropertiesDefaults(new HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(10_000))
return setter
}
}