From 3bf4fd687d609e62bd94c99dafa25150fa891aca Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 9 Dec 2020 10:26:13 -0500 Subject: [PATCH] More GH Actions goodies (#3441) * More GH Actions goodies * Add RabbitMQ, MongoDB & Redis services into GH actions * Remove Travis * * Add `distributionSha256Sum` into `gradle-wrapper.properties` * Try `TERM: dumb` to see difference for Gradle output in GH action * Add `-S` to see the reason of test failure * * Try MQTT plugin for RabbitMQ image * * Try `-i` for test failure in Gradle on Actions * * Use `eclipse-mosquitto` image for MQTT on actions * Fix `FtpServerOutboundTests` for the proper FTP file list * Output file list for the failed session in the `RotatingServersTests` * * Adjust SOUT in the test for Checkstyle * * Make some change to `RotatingServersTests`. Looks like the order for `@BeforeAll` methods is not determined and we may start to interaction with FTP server which is not started yet * Fix SSL Handshake Test - we already made this change for the NIO test, but the NET test is failing the same way - the cert failure switched to the server so the expected exception was not thrown on the client side. Due to JVM changes. * * Fix SFTP tests for wrong host and auto-startup state * Remove `-i` for Gradle in the GH Actions * * Try `--no-parallel` for Gradle in the GH Actions * * Try GH actions without Mosquitto * * Try `cyrilix/rabbitmq-mqtt` for GH Actions Co-authored-by: Gary Russell --- .github/workflows/pr-build-workflow.yml | 16 +++++++++- .travis.yml | 18 ----------- gradle/wrapper/gradle-wrapper.properties | 1 + .../outbound/AmqpOutboundEndpointTests2.java | 3 -- .../ftp/inbound/RotatingServersTests.java | 29 +++++++++-------- .../ftp/outbound/FtpServerOutboundTests.java | 4 +-- .../ip/tcp/connection/SocketSupportTests.java | 15 +++++---- .../tcp/connection/TcpNioConnectionTests.java | 2 +- ...annelAdapterParserCachingTests-context.xml | 2 +- ...terParserTests-context-fail-autocreate.xml | 3 +- ...ChannelAdapterParserTests-context-fail.xml | 32 ++++++++----------- ...boundChannelAdapterParserTests-context.xml | 6 +++- .../InboundChannelAdapterParserTests.java | 2 ++ .../sftp/config/MessageHistory-context.xml | 2 +- .../config/SftpInboundAutostartup-context.xml | 2 +- 15 files changed, 70 insertions(+), 67 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/pr-build-workflow.yml b/.github/workflows/pr-build-workflow.yml index d6b15aec25..ff7401e73e 100644 --- a/.github/workflows/pr-build-workflow.yml +++ b/.github/workflows/pr-build-workflow.yml @@ -10,12 +10,26 @@ jobs: runs-on: ubuntu-latest services: + rabbitmq: - image: rabbitmq + image: cyrilix/rabbitmq-mqtt ports: - 5672:5672 + - 15672:15672 + - 1883:1883 + + mongodb: + image: mongo + ports: + - 27017:27017 + + redis: + image: redis + ports: + - 6379:6379 steps: + - uses: actions/checkout@v2 - name: Set up JDK 11 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b158382b9b..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -dist: trusty -language: java -jdk: oraclejdk11 -sudo: false -services: - - mongodb - - rabbitmq -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ -install: true -env: - - TERM=dumb SI_FATAL_WHEN_NO_BEANFACTORY=true NO_REFERENCE_TASK=true -script: - - ./gradlew checkAsciidocLinks check --refresh-dependencies --no-daemon diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4d9ca16491..77c9546f78 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,3 +3,4 @@ distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionSha256Sum=3239b5ed86c3838a37d983ac100573f64c1f3fd8e1eb6c89fa5f9529b5ec091d \ No newline at end of file diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java index b0156fa60f..a10fcae392 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java @@ -46,7 +46,6 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.support.GenericMessage; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.DisabledIf; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** @@ -90,8 +89,6 @@ public class AmqpOutboundEndpointTests2 { } @Test - @DisabledIf("#{systemEnvironment['TRAVIS'] ?: false}") - // needs RabbitMQ 3.7 void testWithReject(@Autowired IntegrationFlow flow, @Autowired RabbitAdmin admin, @Autowired RabbitTemplate template) { diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java index bc11430437..5698571e28 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java @@ -29,7 +29,6 @@ import java.util.stream.Collectors; import org.apache.commons.net.ftp.FTPFile; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; @@ -73,8 +72,8 @@ public class RotatingServersTests extends FtpTestSupport { private static String tmpDir = getLocalTempFolder().getAbsolutePath() + File.separator + "multiSF"; - @BeforeAll - public static void setup() { + @BeforeEach + public void setup() { FtpRemoteFileTemplate rft = new FtpRemoteFileTemplate(sessionFactory()); rft.execute(s -> { s.mkdir("foo"); @@ -117,15 +116,18 @@ public class RotatingServersTests extends FtpTestSupport { @AfterEach public void extraCleanUp(TestInfo info) { - if (info.getTestMethod().get().getName().equals("testFairStreaming")) { - FtpRemoteFileTemplate rft = new FtpRemoteFileTemplate(sessionFactory()); - rft.execute(s -> { + FtpRemoteFileTemplate rft = new FtpRemoteFileTemplate(sessionFactory()); + rft.execute(s -> { + if (info.getTestMethod().get().getName().equals("testFairStreaming")) { s.remove("foo/f4"); s.remove("baz/f5"); s.remove("fiz/f6"); - return null; - }); - } + } + s.remove("foo/f1"); + s.remove("baz/f2"); + s.remove("fiz/f3"); + return null; + }); } @Test @@ -326,7 +328,7 @@ public class RotatingServersTests extends FtpTestSupport { .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .localDirectory(localDir()) .remoteDirectory("."), - e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) + e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) .channel(MessageChannels.queue("files")) .get(); } @@ -349,6 +351,7 @@ public class RotatingServersTests extends FtpTestSupport { protected File localDir() { return new File(tmpDir, "fair"); } + } @Configuration @@ -362,7 +365,7 @@ public class RotatingServersTests extends FtpTestSupport { .localDirectory(new File(tmpDir, "variable")) .localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root") .remoteDirectory("."), - e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) + e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) .channel(MessageChannels.queue("files")) .get(); } @@ -378,7 +381,7 @@ public class RotatingServersTests extends FtpTestSupport { return IntegrationFlows.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf())) .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .remoteDirectory("."), - e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) + e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) .channel(MessageChannels.queue("files")) .get(); } @@ -405,7 +408,7 @@ public class RotatingServersTests extends FtpTestSupport { .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .remoteDirectory(".") .maxFetchSize(1), - e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) + e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) .channel(MessageChannels.queue("files")) .get(); } diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java index c1406e907d..b36e5d5374 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java @@ -668,10 +668,10 @@ public class FtpServerOutboundTests extends FtpTestSupport { assertThat(files.size()).isEqualTo(3); assertThat(files).contains("subFtpSource", " ftpSource1.txt", "ftpSource2.txt"); - FTPFile[] ftpFiles = ftpSessionFactory.getSession().list(null); + FTPFile[] ftpFiles = ftpSessionFactory.getSession().list("ftpSource"); for (FTPFile ftpFile : ftpFiles) { if (!ftpFile.isDirectory()) { - assertThat(files.contains(ftpFile.getName())).isTrue(); + assertThat(files).contains(ftpFile.getName()); } } } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java index 6ad716ab43..5a5961b061 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java @@ -57,6 +57,7 @@ import org.springframework.integration.ip.util.TestingUtilities; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; +import org.springframework.messaging.support.ErrorMessage; import org.springframework.messaging.support.GenericMessage; /** @@ -415,10 +416,11 @@ public class SocketSupportTests { .isThrownBy(() -> testNetClientAndServerSSLDifferentContexts(true)); } - private void testNetClientAndServerSSLDifferentContexts(boolean badClient) throws Exception { + private void testNetClientAndServerSSLDifferentContexts(boolean badServer) throws Exception { System.setProperty("javax.net.debug", "all"); // SSL activity in the console TcpNetServerConnectionFactory server = new TcpNetServerConnectionFactory(0); - TcpSSLContextSupport serverSslContextSupport = new DefaultTcpSSLContextSupport("server.ks", + TcpSSLContextSupport serverSslContextSupport = new DefaultTcpSSLContextSupport( + badServer ? "client.ks" : "server.ks", "server.truststore.ks", "secret", "secret"); DefaultTcpNetSSLSocketFactorySupport serverTcpSocketFactorySupport = new DefaultTcpNetSSLSocketFactorySupport(serverSslContextSupport); @@ -426,8 +428,10 @@ public class SocketSupportTests { final List> messages = new ArrayList>(); final CountDownLatch latch = new CountDownLatch(1); server.registerListener(message -> { - messages.add(message); - latch.countDown(); + if (!(message instanceof ErrorMessage)) { + messages.add(message); + latch.countDown(); + } return false; }); server.setTcpSocketSupport(new DefaultTcpSocketSupport(false) { @@ -442,8 +446,7 @@ public class SocketSupportTests { TestingUtilities.waitListening(server, null); TcpNetClientConnectionFactory client = new TcpNetClientConnectionFactory("localhost", server.getPort()); - TcpSSLContextSupport clientSslContextSupport = new DefaultTcpSSLContextSupport( - badClient ? "server.ks" : "client.ks", + TcpSSLContextSupport clientSslContextSupport = new DefaultTcpSSLContextSupport("client.ks", "client.truststore.ks", "secret", "secret"); DefaultTcpNetSSLSocketFactorySupport clientTcpSocketFactorySupport = new DefaultTcpNetSSLSocketFactorySupport(clientSslContextSupport); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java index a31c6c0a6c..cb47906f12 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java @@ -816,7 +816,7 @@ public class TcpNioConnectionTests { } @Test - @Disabled("Timing is too short for CI/Travis") + @Disabled("Timing is too short for CI") public void testNoDelayOnClose() throws Exception { TcpNioServerConnectionFactory cf = new TcpNioServerConnectionFactory(0); final CountDownLatch reading = new CountDownLatch(1); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml index 245f1dfe99..8e3f17e7b5 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml @@ -15,7 +15,7 @@ - + diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail-autocreate.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail-autocreate.xml index 414edc9192..27e4014c4c 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail-autocreate.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail-autocreate.xml @@ -11,7 +11,7 @@ - + @@ -25,6 +25,7 @@ channel="requestChannel" session-factory="sftpSessionFactory" filter="filter" + auto-startup="false" remote-directory="/foo" local-directory="file:foo" auto-create-local-directory="false" diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail.xml index 05127a2498..3aedcf3ec5 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context-fail.xml @@ -3,24 +3,19 @@ xmlns="http://www.springframework.org/schema/integration" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:p="http://www.springframework.org/schema/p" - xmlns:context="http://www.springframework.org/schema/context" - xmlns:util="http://www.springframework.org/schema/util" - xmlns:tool="http://www.springframework.org/schema/tool" - xmlns:lang="http://www.springframework.org/schema/lang" xmlns:sftp="http://www.springframework.org/schema/integration/sftp" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd - http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd - http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd - http://www.springframework.org/schema/tool https://www.springframework.org/schema/tool/spring-tool.xsd - http://www.springframework.org/schema/lang https://www.springframework.org/schema/lang/spring-lang.xsd + + + + http://www.springframework.org/schema/integration/sftp https://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd"> - + @@ -30,14 +25,15 @@ + channel="requestChannel" + session-factory="sftpSessionFactory" + filter="filter" + filename-pattern="." + auto-startup="false" + remote-directory="/foo" + local-directory="file:local-test-dir" + auto-create-local-directory="false" + auto-delete-remote-files-on-sync="false"> diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml index 9db6599f83..20c4282798 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests-context.xml @@ -21,7 +21,7 @@ - + @@ -76,6 +76,7 @@ session-factory="sftpSessionFactory" filter="filter" remote-directory="/foo" + auto-startup="false" local-directory="file:local-test-dir" auto-create-local-directory="true" delete-remote-files="false"> @@ -87,6 +88,7 @@ channel="requestChannel" filename-pattern="pattern" remote-directory="/foo" + auto-startup="false" local-directory="file:local-test-dir" auto-create-local-directory="false" delete-remote-files="false"> @@ -99,6 +101,7 @@ filename-pattern="pattern" remote-directory="/foo" local-directory="file:foo" + auto-startup="false" auto-create-local-directory="true" delete-remote-files="false"> @@ -113,6 +116,7 @@ filter="filter" remote-directory="/foo" local-directory="file:foo" + auto-startup="false" auto-create-local-directory="false" delete-remote-files="false"> diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java index 424e570ee0..87b9f1d9b7 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserTests.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.Lifecycle; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.expression.Expression; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; @@ -97,6 +98,7 @@ public class InboundChannelAdapterParserTests { assertThat(remoteFileSeparator).isNotNull(); assertThat(remoteFileSeparator).isEqualTo("."); PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class); + ((Lifecycle) adapter).start(); assertThat(requestChannel.receive(10000)).isNotNull(); FileListFilter acceptAllFilter = context.getBean("acceptAllFilter", FileListFilter.class); @SuppressWarnings("unchecked") diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/MessageHistory-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/MessageHistory-context.xml index 20ea6b5771..9d4d2eaf91 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/MessageHistory-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/MessageHistory-context.xml @@ -11,7 +11,7 @@ - + diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpInboundAutostartup-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpInboundAutostartup-context.xml index ff5217b979..a0f06d92df 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpInboundAutostartup-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpInboundAutostartup-context.xml @@ -8,7 +8,7 @@ http://www.springframework.org/schema/integration/sftp https://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd"> - +