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 * SPDX-License-Identifier: Apache-2.0
*/ */
import com.netflix.hystrix.HystrixCommandProperties
import com.netflix.hystrix.HystrixObservableCommand import com.netflix.hystrix.HystrixObservableCommand
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import rx.Observable import rx.Observable
@ -17,7 +18,7 @@ class HystrixObservableChainTest extends AgentInstrumentationSpecification {
setup: setup:
def result = runWithSpan("parent") { def result = runWithSpan("parent") {
def val = new HystrixObservableCommand<String>(asKey("ExampleGroup")) { def val = new HystrixObservableCommand<String>(setter("ExampleGroup")) {
private String tracedMethod() { private String tracedMethod() {
runInternalSpan("tracedMethod") runInternalSpan("tracedMethod")
return "Hello" return "Hello"
@ -35,7 +36,7 @@ class HystrixObservableChainTest extends AgentInstrumentationSpecification {
.map { .map {
it.toUpperCase() it.toUpperCase()
}.flatMap { str -> }.flatMap { str ->
new HystrixObservableCommand<String>(asKey("OtherGroup")) { new HystrixObservableCommand<String>(setter("OtherGroup")) {
private String anotherTracedMethod() { private String anotherTracedMethod() {
runInternalSpan("anotherTracedMethod") runInternalSpan("anotherTracedMethod")
return "$str!" 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 * SPDX-License-Identifier: Apache-2.0
*/ */
import com.netflix.hystrix.HystrixCommandProperties
import com.netflix.hystrix.HystrixObservable import com.netflix.hystrix.HystrixObservable
import com.netflix.hystrix.HystrixObservableCommand import com.netflix.hystrix.HystrixObservableCommand
import com.netflix.hystrix.exception.HystrixRuntimeException import com.netflix.hystrix.exception.HystrixRuntimeException
@ -24,7 +25,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
def observeOnFn = observeOn def observeOnFn = observeOn
def subscribeOnFn = subscribeOn def subscribeOnFn = subscribeOn
def result = runWithSpan("parent") { def result = runWithSpan("parent") {
def val = operation new HystrixObservableCommand<String>(asKey("ExampleGroup")) { def val = operation new HystrixObservableCommand<String>(setter("ExampleGroup")) {
private String tracedMethod() { private String tracedMethod() {
runInternalSpan("tracedMethod") runInternalSpan("tracedMethod")
return "Hello!" return "Hello!"
@ -116,7 +117,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
def observeOnFn = observeOn def observeOnFn = observeOn
def subscribeOnFn = subscribeOn def subscribeOnFn = subscribeOn
def result = runWithSpan("parent") { def result = runWithSpan("parent") {
def val = operation new HystrixObservableCommand<String>(asKey("ExampleGroup")) { def val = operation new HystrixObservableCommand<String>(setter("ExampleGroup")) {
@Override @Override
protected Observable<String> construct() { protected Observable<String> construct() {
def err = Observable.defer { def err = Observable.defer {
@ -214,7 +215,7 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
when: when:
runWithSpan("parent") { runWithSpan("parent") {
operation new HystrixObservableCommand<String>(asKey("FailingGroup")) { operation new HystrixObservableCommand<String>(setter("FailingGroup")) {
@Override @Override
protected Observable<String> construct() { protected Observable<String> construct() {
@ -305,4 +306,11 @@ class HystrixObservableTest extends AgentInstrumentationSpecification {
throw ex 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.HystrixCommand
import com.netflix.hystrix.HystrixCommandProperties
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import java.util.concurrent.BlockingQueue import java.util.concurrent.BlockingQueue
@ -17,7 +18,7 @@ class HystrixTest extends AgentInstrumentationSpecification {
def "test command #action"() { def "test command #action"() {
setup: setup:
def command = new HystrixCommand<String>(asKey("ExampleGroup")) { def command = new HystrixCommand<String>(setter("ExampleGroup")) {
@Override @Override
protected String run() throws Exception { protected String run() throws Exception {
return tracedMethod() return tracedMethod()
@ -77,7 +78,7 @@ class HystrixTest extends AgentInstrumentationSpecification {
def "test command #action fallback"() { def "test command #action fallback"() {
setup: setup:
def command = new HystrixCommand<String>(asKey("ExampleGroup")) { def command = new HystrixCommand<String>(setter("ExampleGroup")) {
@Override @Override
protected String run() throws Exception { protected String run() throws Exception {
throw new IllegalArgumentException() throw new IllegalArgumentException()
@ -138,4 +139,11 @@ class HystrixTest extends AgentInstrumentationSpecification {
queue.take() queue.take()
} }
} }
def setter(String key) {
def setter = new HystrixCommand.Setter(asKey(key))
setter.andCommandPropertiesDefaults(new HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(10_000))
return setter
}
} }