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
This commit is contained in:
Phillip Webb
2012-12-11 18:07:48 -08:00
committed by Chris Beams
parent b083bbdec7
commit 60032e0012
11 changed files with 105 additions and 62 deletions

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import java.lang.reflect.Method;
@@ -50,6 +51,8 @@ import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.build.junit.Assume;
import org.springframework.build.junit.TestGroup;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
@@ -112,10 +115,8 @@ public final class AspectJAutoProxyCreatorTests {
@Test
public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
StopWatch sw = new StopWatch();
sw.start("Prototype Creation");
@@ -134,10 +135,8 @@ public final class AspectJAutoProxyCreatorTests {
@Test
public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
StopWatch sw = new StopWatch();
sw.start("Prototype Creation");
@@ -156,10 +155,8 @@ public final class AspectJAutoProxyCreatorTests {
@Test
public void testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ac = new GenericApplicationContext();
new XmlBeanDefinitionReader(ac).loadBeanDefinitions(new ClassPathResource(qName("aspectsPlusAdvisor.xml"),
getClass()));

View File

@@ -17,6 +17,7 @@
package org.springframework.context.annotation;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeFalse;
import javax.annotation.Resource;
@@ -30,6 +31,8 @@ import org.springframework.beans.factory.annotation.Required;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.build.junit.Assume;
import org.springframework.build.junit.TestGroup;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.util.StopWatch;
@@ -44,10 +47,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithResourcePropertiesIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
@@ -70,10 +71,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithOverriddenResourcePropertiesIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
@@ -97,10 +96,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
@@ -123,10 +120,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();

View File

@@ -38,6 +38,8 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.build.junit.Assume;
import org.springframework.build.junit.TestGroup;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.util.SerializationTestUtils;
@@ -218,10 +220,8 @@ public class ApplicationContextExpressionTests {
@Test
public void prototypeCreationIsFastEnough() {
if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
// Skip this test: Trace logging blows the time limit.
return;
}
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ac = new GenericApplicationContext();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);

View File

@@ -19,8 +19,11 @@ package org.springframework.scheduling.annotation;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Before;
import org.junit.Test;
import org.springframework.build.junit.Assume;
import org.springframework.build.junit.TestGroup;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -43,6 +46,11 @@ import static org.junit.Assert.*;
*/
public class EnableSchedulingTests {
@Before
public void setUp() {
Assume.group(TestGroup.PERFORMANCE);
}
@Test
public void withFixedRateTask() throws InterruptedException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();