INT-3152 Speed Up Build Times

Add a `@Rule` to skip long-runing tests during normal builds.

Add the rule to long-running tests in gemfire, ip, jms, jmx.

Add an environment variable `RUN_LONG_INTEGRATION_TESTS`; when set
to true, all tests are run.

Set the environment variable to true on all nightly builds.

Build now runs in 13 minutes on my 3 year old laptop.
This commit is contained in:
Gary Russell
2013-09-26 17:36:09 -04:00
parent 65e84030fb
commit be87cfc365
10 changed files with 105 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2011 the original author or authors
* Copyright 2007-2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,12 @@
*/
package org.springframework.integration.gemfire.store;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -28,6 +34,7 @@ import junit.framework.AssertionFailedError;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -41,16 +48,11 @@ import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.util.Assert;
import com.gemstone.gemfire.cache.Cache;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* @author Oleg Zhurakousky
* @author David Turanski
@@ -60,6 +62,9 @@ public class GemfireGroupStoreTests {
private Cache cache;
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test
public void testNonExistingEmptyMessageGroup() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(this.cache);

View File

@@ -27,6 +27,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.ApplicationEvent;
@@ -35,6 +36,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.message.ErrorMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.SocketUtils;
import org.springframework.integration.test.util.TestUtils;
@@ -44,6 +46,9 @@ import org.springframework.integration.test.util.TestUtils;
*/
public class ConnectionTimeoutTests {
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test
public void testDefaultTimeout() throws Exception {
int port = SocketUtils.findAvailableServerSocket();

View File

@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -36,6 +37,7 @@ import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
@@ -47,6 +49,9 @@ public class PipelineJmsTests extends ActiveMQMultiContextTests {
private static final Log logger = LogFactory.getLog(PipelineJmsTests.class);
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Before
public void setLogLevel() {
LogManager.getLogger(getClass()).setLevel(Level.INFO);

View File

@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -37,6 +38,7 @@ import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
@@ -49,6 +51,9 @@ public class PipelineNamedReplyQueuesJmsTests extends ActiveMQMultiContextTests
private static final Log logger = LogFactory.getLog(PipelineJmsTests.class);
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Before
public void setLogLevel() {
LogManager.getLogger(getClass()).setLevel(Level.INFO);

View File

@@ -28,7 +28,9 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.MessageTimeoutException;
import org.springframework.integration.gateway.RequestReplyExchanger;
@@ -36,6 +38,7 @@ import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.JmsOutboundGateway;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
@@ -51,6 +54,9 @@ public class RequestReplyScenariosWithCachedConsumersTests extends ActiveMQMulti
private final SimpleMessageConverter converter = new SimpleMessageConverter();
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test(expected=MessageTimeoutException.class)
public void messageCorrelationBasedOnRequestMessageIdOptimized() throws Exception{
ActiveMqTestUtils.prepare();

View File

@@ -17,13 +17,16 @@ package org.springframework.integration.jms.request_reply;
import static org.junit.Assert.assertEquals;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.JmsOutboundGateway;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
/**
* @author Oleg Zhurakousky
@@ -31,6 +34,9 @@ import org.springframework.integration.test.util.TestUtils;
*/
public class RequestReplyScenariosWithCorrelationKeyProvidedTests extends ActiveMQMultiContextTests {
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test
public void messageCorrelationBasedCustomCorrelationKey() throws Exception{
ActiveMqTestUtils.prepare();

View File

@@ -24,7 +24,9 @@ import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.MessageTimeoutException;
@@ -32,6 +34,7 @@ import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
/**
@@ -40,6 +43,9 @@ import org.springframework.jms.core.MessageCreator;
*/
public class RequestReplyScenariosWithNonCachedConsumersTests extends ActiveMQMultiContextTests {
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test(expected=MessageTimeoutException.class)
public void messageCorrelationBasedOnRequestMessageIdOptimized() throws Exception{
ActiveMqTestUtils.prepare();

View File

@@ -36,13 +36,16 @@ import javax.jms.TextMessage;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQDestination;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
@@ -58,6 +61,9 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
private final SimpleMessageConverter converter = new SimpleMessageConverter();
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test
public void messageCorrelationBasedOnRequestMessageId() throws Exception{
ActiveMqTestUtils.prepare();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -22,8 +22,11 @@ import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectInstance;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jmx.export.MBeanExporter;
@@ -34,6 +37,9 @@ import org.springframework.jmx.export.MBeanExporter;
*/
public class Int2307Tests {
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@SuppressWarnings("unchecked")
@Test
public void testInt2307_DefaultMBeanExporter() throws Exception{

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.test.support;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assume;
import org.junit.rules.TestWatchman;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
/**
* Rule to prevent long running tests from running on every build; set environment
* variable RUN_LONG_INTEGRATION_TESTS on a CI nightly build to ensure coverage.
*
* @author Gary Russell
* @since 3.0
*
*/
public class LongRunningIntegrationTest extends TestWatchman {
private final static Log logger = LogFactory.getLog(LongRunningIntegrationTest.class);
@Override
public Statement apply(Statement base, FrameworkMethod method, Object target) {
boolean shouldRun = "true".equalsIgnoreCase(System.getenv("RUN_LONG_INTEGRATION_TESTS"));
if (!shouldRun) {
logger.info("Skipping long running test " + this.getClass().getSimpleName() + "." + method.getName());
}
Assume.assumeTrue(shouldRun);
return super.apply(base, method, target);
}
}