From b6aaa3581339dfb7f46af76a65a9a37d3f77ffa2 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Wed, 1 Dec 2021 18:25:13 +0200 Subject: [PATCH] Increase timeout for hystrix tests (#4762) * Increase timeout for hystrix tests * remove unused import --- .../test/groovy/HystrixObservableChainTest.groovy | 12 ++++++++++-- .../src/test/groovy/HystrixObservableTest.groovy | 14 +++++++++++--- .../javaagent/src/test/groovy/HystrixTest.groovy | 12 ++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableChainTest.groovy b/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableChainTest.groovy index 97e6700705..6185581e9f 100644 --- a/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableChainTest.groovy +++ b/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableChainTest.groovy @@ -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(asKey("ExampleGroup")) { + def val = new HystrixObservableCommand(setter("ExampleGroup")) { private String tracedMethod() { runInternalSpan("tracedMethod") return "Hello" @@ -35,7 +36,7 @@ class HystrixObservableChainTest extends AgentInstrumentationSpecification { .map { it.toUpperCase() }.flatMap { str -> - new HystrixObservableCommand(asKey("OtherGroup")) { + new HystrixObservableCommand(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 + } } diff --git a/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableTest.groovy b/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableTest.groovy index 1356191096..13705971dc 100644 --- a/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableTest.groovy +++ b/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixObservableTest.groovy @@ -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(asKey("ExampleGroup")) { + def val = operation new HystrixObservableCommand(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(asKey("ExampleGroup")) { + def val = operation new HystrixObservableCommand(setter("ExampleGroup")) { @Override protected Observable construct() { def err = Observable.defer { @@ -214,7 +215,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification { when: runWithSpan("parent") { - operation new HystrixObservableCommand(asKey("FailingGroup")) { + operation new HystrixObservableCommand(setter("FailingGroup")) { @Override protected Observable 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 + } } diff --git a/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixTest.groovy b/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixTest.groovy index 97f22252de..b27cb9e1b3 100644 --- a/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixTest.groovy +++ b/instrumentation/hystrix-1.4/javaagent/src/test/groovy/HystrixTest.groovy @@ -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(asKey("ExampleGroup")) { + def command = new HystrixCommand(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(asKey("ExampleGroup")) { + def command = new HystrixCommand(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 + } }