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.

Polishing - Switch to TestWatcher

TestWatchMan is deprecated.

INT-3152 Polishing Show Skipped Tests as 'Ignored'

In test report.

JIRA: https://jira.springsource.org/browse/INT-3152
This commit is contained in:
Gary Russell
2013-09-27 20:12:11 +03:00
committed by Artem Bilan
parent b81e9255d2
commit bddbc5b6fb
10 changed files with 123 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
*
@@ -59,6 +61,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

@@ -24,10 +24,12 @@ import static org.junit.Assert.assertTrue;
import java.net.Socket;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.ip.util.TestingUtilities;
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;
@@ -38,6 +40,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

@@ -23,12 +23,14 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
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;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
/**
* @author Oleg Zhurakousky
*/
@@ -36,6 +38,15 @@ public class PipelineJmsTests {
private final Executor executor = Executors.newFixedThreadPool(30);
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);
}
int requests = 50;
/**

View File

@@ -24,12 +24,14 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
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;
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
@@ -39,6 +41,15 @@ public class PipelineNamedReplyQueuesJmsTests {
private final Executor executor = Executors.newFixedThreadPool(30);
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);
}
int requests = 50;
/**

View File

@@ -28,13 +28,16 @@ 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;
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;
@@ -49,6 +52,9 @@ public class RequestReplyScenariosWithCachedConsumersTests {
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,6 +17,7 @@ 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;
@@ -24,12 +25,16 @@ import org.springframework.integration.gateway.RequestReplyExchanger;
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
*/
public class RequestReplyScenariosWithCorrelationKeyProvidedTests {
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test
public void messageCorrelationBasedCustomCorrelationKey() throws Exception{
ActiveMqTestUtils.prepare();

View File

@@ -24,13 +24,16 @@ 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;
import org.springframework.integration.gateway.RequestReplyExchanger;
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;
/**
@@ -38,6 +41,9 @@ import org.springframework.jms.core.MessageCreator;
*/
public class RequestReplyScenariosWithNonCachedConsumersTests {
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@Test(expected=MessageTimeoutException.class)
public void messageCorrelationBasedOnRequestMessageIdOptimized() throws Exception{
ActiveMqTestUtils.prepare();

View File

@@ -36,6 +36,7 @@ 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;
@@ -43,6 +44,7 @@ import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.gateway.RequestReplyExchanger;
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;
@@ -57,6 +59,9 @@ public class RequestReplyScenariosWithTempReplyQueuesTests {
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,55 @@
/*
* 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.TestWatcher;
import org.junit.runner.Description;
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 TestWatcher {
private final static Log logger = LogFactory.getLog(LongRunningIntegrationTest.class);
@Override
public Statement apply(Statement base, Description description) {
boolean shouldRun = "true".equalsIgnoreCase(System.getenv("RUN_LONG_INTEGRATION_TESTS"));
if (!shouldRun) {
logger.info("Skipping long running test " + description.getDisplayName());
return new Statement() {
@Override
public void evaluate() throws Throwable {
Assume.assumeTrue(false);
}
};
}
else {
return super.apply(base, description);
}
}
}