Skip to content

Commit 60032e0

Browse files
philwebbcbeams
authored andcommitted
Ignore performance-sensitive tests by default
Make use of the new JUnit functionality introduced in the previous commit to 'Assume' that perfomance- and timing-sensitive tests should run only when TestGroup.PERFORMANCE is selected, i.e. when -PtestGroups="performance" has been provided at the Gradle command line. The net effect is that these tests are now ignored by default, which will result in far fewer false-negative CI build failures due to resource contention and other external factors that cause slowdowns. We will set up a dedicated performance CI build to run these tests on an isolated machine, etc. Issue: SPR-9984
1 parent b083bbd commit 60032e0

File tree

11 files changed

+105
-62
lines changed

11 files changed

+105
-62
lines changed

spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
5050
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
5151
import org.springframework.beans.support.DerivedFromProtectedBaseBean;
52+
import org.springframework.build.junit.Assume;
53+
import org.springframework.build.junit.TestGroup;
5254
import org.springframework.core.convert.ConversionFailedException;
5355
import org.springframework.core.convert.TypeDescriptor;
5456
import org.springframework.core.convert.support.DefaultConversionService;
@@ -1139,10 +1141,8 @@ public void testPrimitiveArray() {
11391141

11401142
@Test
11411143
public void testLargeMatchingPrimitiveArray() {
1142-
if (LogFactory.getLog(BeanWrapperTests.class).isTraceEnabled()) {
1143-
// Skip this test: Trace logging blows the time limit.
1144-
return;
1145-
}
1144+
Assume.group(TestGroup.PERFORMANCE);
1145+
Assume.notLogging(LogFactory.getLog(BeanWrapperTests.class));
11461146

11471147
PrimitiveArrayBean tb = new PrimitiveArrayBean();
11481148
BeanWrapper bw = new BeanWrapperImpl(tb);

spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
import org.springframework.beans.factory.xml.ConstructorDependenciesBean;
7373
import org.springframework.beans.factory.xml.DependenciesBean;
7474
import org.springframework.beans.propertyeditors.CustomNumberEditor;
75+
import org.springframework.build.junit.Assume;
76+
import org.springframework.build.junit.TestGroup;
7577
import org.springframework.core.MethodParameter;
7678
import org.springframework.core.convert.converter.Converter;
7779
import org.springframework.core.convert.support.DefaultConversionService;
@@ -1693,10 +1695,8 @@ public void testPrototypeWithArrayConversionForFactoryMethod() {
16931695

16941696
@Test
16951697
public void testPrototypeCreationIsFastEnough() {
1696-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
1697-
// Skip this test: Trace logging blows the time limit.
1698-
return;
1699-
}
1698+
Assume.group(TestGroup.PERFORMANCE);
1699+
Assume.notLogging(factoryLog);
17001700
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
17011701
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
17021702
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1713,10 +1713,8 @@ public void testPrototypeCreationIsFastEnough() {
17131713

17141714
@Test
17151715
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
1716-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
1717-
// Skip this test: Trace logging blows the time limit.
1718-
return;
1719-
}
1716+
Assume.group(TestGroup.PERFORMANCE);
1717+
Assume.notLogging(factoryLog);
17201718
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
17211719
RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
17221720
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1759,10 +1757,8 @@ public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
17591757
@Test
17601758
@Ignore // TODO re-enable when ConstructorResolver TODO sorted out
17611759
public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
1762-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
1763-
// Skip this test: Trace logging blows the time limit.
1764-
return;
1765-
}
1760+
Assume.group(TestGroup.PERFORMANCE);
1761+
Assume.notLogging(factoryLog);
17661762
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
17671763
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
17681764
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1809,10 +1805,8 @@ public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
18091805

18101806
@Test
18111807
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
1812-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
1813-
// Skip this test: Trace logging blows the time limit.
1814-
return;
1815-
}
1808+
Assume.group(TestGroup.PERFORMANCE);
1809+
Assume.notLogging(factoryLog);
18161810
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
18171811
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
18181812
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1833,10 +1827,8 @@ public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough()
18331827

18341828
@Test
18351829
public void testPrototypeCreationWithPropertiesIsFastEnough() {
1836-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
1837-
// Skip this test: Trace logging blows the time limit.
1838-
return;
1839-
}
1830+
Assume.group(TestGroup.PERFORMANCE);
1831+
Assume.notLogging(factoryLog);
18401832
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
18411833
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
18421834
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1882,10 +1874,8 @@ public void testPrototypeCreationWithPropertiesIsFastEnough() {
18821874
*/
18831875
@Test
18841876
public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() {
1885-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
1886-
// Skip this test: Trace logging blows the time limit.
1887-
return;
1888-
}
1877+
Assume.group(TestGroup.PERFORMANCE);
1878+
Assume.notLogging(factoryLog);
18891879
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
18901880
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
18911881
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2200,6 +2190,7 @@ static class B { }
22002190
*/
22012191
@Test(timeout=1000)
22022192
public void testByTypeLookupIsFastEnough() {
2193+
Assume.group(TestGroup.PERFORMANCE);
22032194
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
22042195

22052196
for (int i = 0; i < 1000; i++) {

spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.junit.Assert.assertFalse;
2222
import static org.junit.Assert.assertNotSame;
2323
import static org.junit.Assert.assertTrue;
24+
import static org.junit.Assume.assumeFalse;
2425

2526
import java.lang.reflect.Method;
2627

@@ -50,6 +51,8 @@
5051
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
5152
import org.springframework.beans.factory.support.RootBeanDefinition;
5253
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
54+
import org.springframework.build.junit.Assume;
55+
import org.springframework.build.junit.TestGroup;
5356
import org.springframework.context.ApplicationContext;
5457
import org.springframework.context.support.ClassPathXmlApplicationContext;
5558
import org.springframework.context.support.GenericApplicationContext;
@@ -112,10 +115,8 @@ public void testAspectsAndAdvisorAreApplied() {
112115

113116
@Test
114117
public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
115-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
116-
// Skip this test: Trace logging blows the time limit.
117-
return;
118-
}
118+
Assume.group(TestGroup.PERFORMANCE);
119+
Assume.notLogging(factoryLog);
119120
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
120121
StopWatch sw = new StopWatch();
121122
sw.start("Prototype Creation");
@@ -134,10 +135,8 @@ public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
134135

135136
@Test
136137
public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
137-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
138-
// Skip this test: Trace logging blows the time limit.
139-
return;
140-
}
138+
Assume.group(TestGroup.PERFORMANCE);
139+
Assume.notLogging(factoryLog);
141140
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
142141
StopWatch sw = new StopWatch();
143142
sw.start("Prototype Creation");
@@ -156,10 +155,8 @@ public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
156155

157156
@Test
158157
public void testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough() {
159-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
160-
// Skip this test: Trace logging blows the time limit.
161-
return;
162-
}
158+
Assume.group(TestGroup.PERFORMANCE);
159+
Assume.notLogging(factoryLog);
163160
GenericApplicationContext ac = new GenericApplicationContext();
164161
new XmlBeanDefinitionReader(ac).loadBeanDefinitions(new ClassPathResource(qName("aspectsPlusAdvisor.xml"),
165162
getClass()));

spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.context.annotation;
1818

1919
import static org.junit.Assert.*;
20+
import static org.junit.Assume.assumeFalse;
2021

2122
import javax.annotation.Resource;
2223

@@ -30,6 +31,8 @@
3031
import org.springframework.beans.factory.config.RuntimeBeanReference;
3132
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
3233
import org.springframework.beans.factory.support.RootBeanDefinition;
34+
import org.springframework.build.junit.Assume;
35+
import org.springframework.build.junit.TestGroup;
3336
import org.springframework.context.support.GenericApplicationContext;
3437
import org.springframework.util.StopWatch;
3538

@@ -44,10 +47,8 @@ public class AnnotationProcessorPerformanceTests {
4447

4548
@Test
4649
public void testPrototypeCreationWithResourcePropertiesIsFastEnough() {
47-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
48-
// Skip this test: Trace logging blows the time limit.
49-
return;
50-
}
50+
Assume.group(TestGroup.PERFORMANCE);
51+
Assume.notLogging(factoryLog);
5152
GenericApplicationContext ctx = new GenericApplicationContext();
5253
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
5354
ctx.refresh();
@@ -70,10 +71,8 @@ public void testPrototypeCreationWithResourcePropertiesIsFastEnough() {
7071

7172
@Test
7273
public void testPrototypeCreationWithOverriddenResourcePropertiesIsFastEnough() {
73-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
74-
// Skip this test: Trace logging blows the time limit.
75-
return;
76-
}
74+
Assume.group(TestGroup.PERFORMANCE);
75+
Assume.notLogging(factoryLog);
7776
GenericApplicationContext ctx = new GenericApplicationContext();
7877
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
7978
ctx.refresh();
@@ -97,10 +96,8 @@ public void testPrototypeCreationWithOverriddenResourcePropertiesIsFastEnough()
9796

9897
@Test
9998
public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() {
100-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
101-
// Skip this test: Trace logging blows the time limit.
102-
return;
103-
}
99+
Assume.group(TestGroup.PERFORMANCE);
100+
Assume.notLogging(factoryLog);
104101
GenericApplicationContext ctx = new GenericApplicationContext();
105102
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
106103
ctx.refresh();
@@ -123,10 +120,8 @@ public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() {
123120

124121
@Test
125122
public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() {
126-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
127-
// Skip this test: Trace logging blows the time limit.
128-
return;
129-
}
123+
Assume.group(TestGroup.PERFORMANCE);
124+
Assume.notLogging(factoryLog);
130125
GenericApplicationContext ctx = new GenericApplicationContext();
131126
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
132127
ctx.refresh();

spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
3939
import org.springframework.beans.factory.support.GenericBeanDefinition;
4040
import org.springframework.beans.factory.support.RootBeanDefinition;
41+
import org.springframework.build.junit.Assume;
42+
import org.springframework.build.junit.TestGroup;
4143
import org.springframework.context.annotation.AnnotationConfigUtils;
4244
import org.springframework.context.support.GenericApplicationContext;
4345
import org.springframework.util.SerializationTestUtils;
@@ -218,10 +220,8 @@ public void prototypeCreationReevaluatesExpressions() {
218220

219221
@Test
220222
public void prototypeCreationIsFastEnough() {
221-
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
222-
// Skip this test: Trace logging blows the time limit.
223-
return;
224-
}
223+
Assume.group(TestGroup.PERFORMANCE);
224+
Assume.notLogging(factoryLog);
225225
GenericApplicationContext ac = new GenericApplicationContext();
226226
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
227227
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);

spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import java.util.Date;
2020
import java.util.concurrent.atomic.AtomicInteger;
2121

22+
import org.junit.Before;
2223
import org.junit.Test;
2324

25+
import org.springframework.build.junit.Assume;
26+
import org.springframework.build.junit.TestGroup;
2427
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2528
import org.springframework.context.annotation.Bean;
2629
import org.springframework.context.annotation.Configuration;
@@ -43,6 +46,11 @@
4346
*/
4447
public class EnableSchedulingTests {
4548

49+
@Before
50+
public void setUp() {
51+
Assume.group(TestGroup.PERFORMANCE);
52+
}
53+
4654
@Test
4755
public void withFixedRateTask() throws InterruptedException {
4856
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();

spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
import org.junit.Test;
3737

38+
import org.springframework.build.junit.Assume;
39+
import org.springframework.build.junit.TestGroup;
3840
import org.springframework.core.convert.ConversionFailedException;
3941
import org.springframework.core.convert.ConverterNotFoundException;
4042
import org.springframework.core.convert.TypeDescriptor;
@@ -398,6 +400,7 @@ public void testConvertUUID() throws Exception {
398400

399401
@Test
400402
public void testPerformance1() {
403+
Assume.group(TestGroup.PERFORMANCE);
401404
GenericConversionService conversionService = new DefaultConversionService();
402405
StopWatch watch = new StopWatch("integer->string conversionPerformance");
403406
watch.start("convert 4,000,000 with conversion service");
@@ -415,6 +418,7 @@ public void testPerformance1() {
415418

416419
@Test
417420
public void testPerformance2() throws Exception {
421+
Assume.group(TestGroup.PERFORMANCE);
418422
GenericConversionService conversionService = new DefaultConversionService();
419423
StopWatch watch = new StopWatch("list<string> -> list<integer> conversionPerformance");
420424
watch.start("convert 4,000,000 with conversion service");
@@ -442,6 +446,7 @@ public void testPerformance2() throws Exception {
442446

443447
@Test
444448
public void testPerformance3() throws Exception {
449+
Assume.group(TestGroup.PERFORMANCE);
445450
GenericConversionService conversionService = new DefaultConversionService();
446451
StopWatch watch = new StopWatch("map<string, string> -> map<string, integer> conversionPerformance");
447452
watch.start("convert 4,000,000 with conversion service");

spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import junit.framework.Assert;
2020
import org.junit.Test;
2121

22+
import org.springframework.build.junit.Assume;
23+
import org.springframework.build.junit.TestGroup;
2224
import org.springframework.expression.EvaluationContext;
2325
import org.springframework.expression.Expression;
2426
import org.springframework.expression.ExpressionParser;
@@ -43,6 +45,8 @@ public class PerformanceTests {
4345

4446
@Test
4547
public void testPerformanceOfPropertyAccess() throws Exception {
48+
Assume.group(TestGroup.PERFORMANCE);
49+
4650
long starttime = 0;
4751
long endtime = 0;
4852

@@ -89,7 +93,10 @@ public void testPerformanceOfPropertyAccess() throws Exception {
8993
}
9094
}
9195

96+
@Test
9297
public void testPerformanceOfMethodAccess() throws Exception {
98+
Assume.group(TestGroup.PERFORMANCE);
99+
93100
long starttime = 0;
94101
long endtime = 0;
95102

spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static org.junit.Assert.*;
2020

2121
import org.junit.Test;
22+
import org.springframework.build.junit.Assume;
23+
import org.springframework.build.junit.TestGroup;
2224
import org.springframework.mock.web.test.MockHttpServletRequest;
2325
import org.springframework.util.StopWatch;
2426

@@ -399,6 +401,7 @@ public void testGetIntParameterWithDefaultValueHandlingIsFastEnough() {
399401

400402
@Test
401403
public void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
404+
Assume.group(TestGroup.PERFORMANCE);
402405
MockHttpServletRequest request = new MockHttpServletRequest();
403406
StopWatch sw = new StopWatch();
404407
sw.start();
@@ -412,6 +415,7 @@ public void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
412415

413416
@Test
414417
public void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
418+
Assume.group(TestGroup.PERFORMANCE);
415419
MockHttpServletRequest request = new MockHttpServletRequest();
416420
StopWatch sw = new StopWatch();
417421
sw.start();
@@ -425,6 +429,7 @@ public void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
425429

426430
@Test
427431
public void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
432+
Assume.group(TestGroup.PERFORMANCE);
428433
MockHttpServletRequest request = new MockHttpServletRequest();
429434
StopWatch sw = new StopWatch();
430435
sw.start();
@@ -438,6 +443,7 @@ public void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
438443

439444
@Test
440445
public void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
446+
Assume.group(TestGroup.PERFORMANCE);
441447
MockHttpServletRequest request = new MockHttpServletRequest();
442448
StopWatch sw = new StopWatch();
443449
sw.start();
@@ -451,6 +457,7 @@ public void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
451457

452458
@Test
453459
public void testGetStringParameterWithDefaultValueHandlingIsFastEnough() {
460+
Assume.group(TestGroup.PERFORMANCE);
454461
MockHttpServletRequest request = new MockHttpServletRequest();
455462
StopWatch sw = new StopWatch();
456463
sw.start();

0 commit comments

Comments
 (0)