Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
7672ee36
Commit
7672ee36
authored
Sep 21, 2017
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix hystrix command keys in tests to be unique
parent
7ca4f33d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
24 deletions
+51
-24
AdhocTestSuite.java
...ava/org/springframework/cloud/netflix/AdhocTestSuite.java
+4
-4
RibbonCommandCauseFallbackPropagationTest.java
...te/support/RibbonCommandCauseFallbackPropagationTest.java
+0
-0
RibbonCommandHystrixThreadPoolKeyTests.java
...route/support/RibbonCommandHystrixThreadPoolKeyTests.java
+47
-20
No files found.
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/AdhocTestSuite.java
View file @
7672ee36
...
...
@@ -21,8 +21,8 @@ import org.junit.runner.RunWith;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
org.springframework.cloud.netflix.zuul.
FormZuulServletProxyApplicationTests
;
import
org.springframework.cloud.netflix.zuul.filters.route.
LazyLoadOfZuulConfiguration
Tests
;
import
org.springframework.cloud.netflix.zuul.
filters.route.support.RibbonCommandCauseFallbackPropagationTest
;
import
org.springframework.cloud.netflix.zuul.filters.route.
support.RibbonCommandHystrixThreadPoolKey
Tests
;
/**
* A test suite for probing weird ordering problems in the tests.
...
...
@@ -30,8 +30,8 @@ import org.springframework.cloud.netflix.zuul.filters.route.LazyLoadOfZuulConfig
* @author Dave Syer
*/
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
FormZuulServletProxyApplication
Tests
.
class
,
LazyLoadOfZuulConfigurationTests
.
class
})
@SuiteClasses
({
RibbonCommandHystrixThreadPoolKey
Tests
.
class
,
RibbonCommandCauseFallbackPropagationTest
.
class
})
@Ignore
public
class
AdhocTestSuite
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/route/support/RibbonCommandCauseFallbackPropagationTest.java
View file @
7672ee36
This diff is collapsed.
Click to expand it.
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/route/support/RibbonCommandHystrixThreadPoolKeyTests.java
View file @
7672ee36
...
...
@@ -20,8 +20,12 @@ import com.netflix.client.AbstractLoadBalancerAwareClient;
import
com.netflix.client.ClientRequest
;
import
com.netflix.client.http.HttpResponse
;
import
com.netflix.hystrix.HystrixCommandProperties
;
import
com.netflix.hystrix.strategy.HystrixPlugins
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.cloud.netflix.zuul.filters.ZuulProperties
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -38,25 +42,38 @@ public class RibbonCommandHystrixThreadPoolKeyTests {
zuulProperties
=
new
ZuulProperties
();
}
@After
public
void
tearDown
()
throws
Exception
{
HystrixPlugins
.
reset
();
}
@Test
public
void
testDefaultHystrixThreadPoolKey
()
throws
Exception
{
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
THREAD
);
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
THREAD
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
// CommandGroupKey should be used as ThreadPoolKey as default.
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
()).
isEqualTo
(
ribbonCommand1
.
getCommandGroup
().
name
());
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
()).
isEqualTo
(
ribbonCommand2
.
getCommandGroup
().
name
());
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
())
.
isEqualTo
(
ribbonCommand1
.
getCommandGroup
().
name
());
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
())
.
isEqualTo
(
ribbonCommand2
.
getCommandGroup
().
name
());
}
@Test
public
void
testUseSeparateThreadPools
()
throws
Exception
{
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
THREAD
);
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
THREAD
);
zuulProperties
.
getThreadPool
().
setUseSeparateThreadPools
(
true
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
()).
isEqualTo
(
"testCommand1"
);
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
()).
isEqualTo
(
"testCommand2"
);
...
...
@@ -66,35 +83,45 @@ public class RibbonCommandHystrixThreadPoolKeyTests {
public
void
testThreadPoolKeyPrefix
()
throws
Exception
{
final
String
prefix
=
"zuulgw-"
;
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
THREAD
);
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
THREAD
);
zuulProperties
.
getThreadPool
().
setUseSeparateThreadPools
(
true
);
zuulProperties
.
getThreadPool
().
setThreadPoolKeyPrefix
(
prefix
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
()).
isEqualTo
(
prefix
+
"testCommand1"
);
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
()).
isEqualTo
(
prefix
+
"testCommand2"
);
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
())
.
isEqualTo
(
prefix
+
"testCommand1"
);
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
())
.
isEqualTo
(
prefix
+
"testCommand2"
);
}
@Test
public
void
testNoSideEffectOnSemaphoreIsolation
()
throws
Exception
{
final
String
prefix
=
"zuulgw-"
;
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
SEMAPHORE
);
zuulProperties
.
setRibbonIsolationStrategy
(
HystrixCommandProperties
.
ExecutionIsolationStrategy
.
SEMAPHORE
);
zuulProperties
.
getThreadPool
().
setUseSeparateThreadPools
(
true
);
zuulProperties
.
getThreadPool
().
setThreadPoolKeyPrefix
(
prefix
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand1
=
new
TestRibbonCommand
(
"testCommand1"
,
zuulProperties
);
TestRibbonCommand
ribbonCommand2
=
new
TestRibbonCommand
(
"testCommand2"
,
zuulProperties
);
// There should be no side effect on semaphore isolation
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
()).
isEqualTo
(
ribbonCommand1
.
getCommandGroup
().
name
());
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
()).
isEqualTo
(
ribbonCommand2
.
getCommandGroup
().
name
());
assertThat
(
ribbonCommand1
.
getThreadPoolKey
().
name
())
.
isEqualTo
(
ribbonCommand1
.
getCommandGroup
().
name
());
assertThat
(
ribbonCommand2
.
getThreadPoolKey
().
name
())
.
isEqualTo
(
ribbonCommand2
.
getCommandGroup
().
name
());
}
public
static
class
TestRibbonCommand
extends
AbstractRibbonCommand
<
AbstractLoadBalancerAwareClient
<
ClientRequest
,
HttpResponse
>,
ClientRequest
,
HttpResponse
>
{
public
static
class
TestRibbonCommand
extends
AbstractRibbonCommand
<
AbstractLoadBalancerAwareClient
<
ClientRequest
,
HttpResponse
>,
ClientRequest
,
HttpResponse
>
{
public
TestRibbonCommand
(
String
commandKey
,
ZuulProperties
zuulProperties
)
{
super
(
commandKey
,
null
,
null
,
zuulProperties
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment