Skip to content

Commit

Permalink
Increase timeout for hystrix tests (#4762)
Browse files Browse the repository at this point in the history
* Increase timeout for hystrix tests

* remove unused import
  • Loading branch information
laurit committed Dec 1, 2021
1 parent 1ff51fb commit b6aaa35
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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!"
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
}

0 comments on commit b6aaa35

Please sign in to comment.