From bcc368ee42423f93ffec5b67da602921b42f34a5 Mon Sep 17 00:00:00 2001 From: Michael Dombrowski Date: Thu, 14 Sep 2023 14:12:40 -0400 Subject: [PATCH] fix(test): set persistence to h2 by default so tests can pass on windows --- .github/workflows/build.yml | 2 +- .../broker/subscriptions/CTrieSpeedTest.java | 12 ++++-- .../integration/IntegrationUtils.java | 2 +- .../ServerIntegrationDBAuthenticatorTest.java | 10 +++-- .../ServerIntegrationOpenSSLTest.java | 3 +- ...nPahoCanPublishOnReadBlockedTopicTest.java | 10 +---- .../ServerIntegrationSSLClientAuthTest.java | 42 +++++++------------ .../integration/ServerIntegrationSSLTest.java | 42 +++++++------------ .../ServerIntegrationWebSocketTest.java | 9 ++-- .../SegmentPersistentQueueTest.java | 3 ++ 10 files changed, 57 insertions(+), 78 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2468e08e..1555f75d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v2 with: diff --git a/moquette-0.17/broker/src/test/java/io/moquette/broker/subscriptions/CTrieSpeedTest.java b/moquette-0.17/broker/src/test/java/io/moquette/broker/subscriptions/CTrieSpeedTest.java index 7dfc9104..6d696cf0 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/broker/subscriptions/CTrieSpeedTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/broker/subscriptions/CTrieSpeedTest.java @@ -15,16 +15,20 @@ */ package io.moquette.broker.subscriptions; -import static io.moquette.broker.subscriptions.Topic.asTopic; import io.netty.handler.codec.mqtt.MqttQoS; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import static io.moquette.broker.subscriptions.Topic.asTopic; + +@Disabled("No perf testing") public class CTrieSpeedTest { private static final Logger LOGGER = LoggerFactory.getLogger(CTrieSpeedTest.class.getName()); diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/IntegrationUtils.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/IntegrationUtils.java index 219e8fdb..0cb30a2d 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/IntegrationUtils.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/IntegrationUtils.java @@ -63,7 +63,7 @@ public static Properties prepareTestProperties(String dbPath) { testProperties.put(PERSISTENCE_ENABLED_PROPERTY_NAME, "true"); testProperties.put(PORT_PROPERTY_NAME, "1883"); testProperties.put(ENABLE_TELEMETRY_NAME, "false"); - testProperties.put(PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "segmented"); + testProperties.put(PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "h2"); return testProperties; } diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationDBAuthenticatorTest.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationDBAuthenticatorTest.java index 74b88518..10a9b670 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationDBAuthenticatorTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationDBAuthenticatorTest.java @@ -17,12 +17,17 @@ package io.moquette.integration; import io.moquette.BrokerConstants; -import io.moquette.broker.config.IConfig; import io.moquette.broker.Server; +import io.moquette.broker.config.IConfig; import io.moquette.broker.config.MemoryConfig; import io.moquette.broker.security.DBAuthenticator; import io.moquette.broker.security.DBAuthenticatorTest; -import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.IMqttClient; +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttClientPersistence; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttSecurityException; import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -39,7 +44,6 @@ import java.sql.SQLException; import java.util.Properties; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationOpenSSLTest.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationOpenSSLTest.java index 3b7df70d..f07dc45d 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationOpenSSLTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationOpenSSLTest.java @@ -37,7 +37,7 @@ public class ServerIntegrationOpenSSLTest extends ServerIntegrationSSLTest { private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationOpenSSLTest.class); @BeforeAll - public static void beforeTests() { + public static void checkForOpenSSL() { Assumptions.assumeTrue(new OpensslChecker(), "OpenSSL is available"); } @@ -57,6 +57,7 @@ protected void startServer() throws IOException { sslProps.put(IConfig.KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv"); sslProps.put(IConfig.DATA_PATH_PROPERTY_NAME, dbPath); sslProps.put(IConfig.PERSISTENCE_ENABLED_PROPERTY_NAME, "true"); + sslProps.put(IConfig.PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "h2"); sslProps.put(IConfig.ENABLE_TELEMETRY_NAME, "false"); m_server.startServer(sslProps); diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationPahoCanPublishOnReadBlockedTopicTest.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationPahoCanPublishOnReadBlockedTopicTest.java index afd5e62a..b7e2bde5 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationPahoCanPublishOnReadBlockedTopicTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationPahoCanPublishOnReadBlockedTopicTest.java @@ -29,12 +29,7 @@ import io.netty.handler.codec.mqtt.MqttQoS; import org.awaitility.Awaitility; import org.awaitility.Durations; -import org.eclipse.paho.client.mqttv3.IMqttClient; -import org.eclipse.paho.client.mqttv3.MqttClient; -import org.eclipse.paho.client.mqttv3.MqttClientPersistence; -import org.eclipse.paho.client.mqttv3.MqttConnectOptions; -import org.eclipse.paho.client.mqttv3.MqttException; -import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -51,7 +46,6 @@ import static io.moquette.broker.ConnectionTestUtils.EMPTY_OBSERVERS; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; public class ServerIntegrationPahoCanPublishOnReadBlockedTopicTest { @@ -79,7 +73,7 @@ protected void startServer(String dbPath) throws IOException { final Properties configProps = IntegrationUtils.prepareTestProperties(dbPath); configProps.setProperty(BrokerConstants.REAUTHORIZE_SUBSCRIPTIONS_ON_CONNECT, "true"); configProps.setProperty(IConfig.ENABLE_TELEMETRY_NAME, "false"); - configProps.setProperty(IConfig.PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "segmented"); + configProps.setProperty(IConfig.PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "h2"); m_config = new MemoryConfig(configProps); canRead = true; diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLClientAuthTest.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLClientAuthTest.java index ba99da29..8234b258 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLClientAuthTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLClientAuthTest.java @@ -16,42 +16,27 @@ package io.moquette.integration; +import io.moquette.BrokerConstants; import io.moquette.broker.Server; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; +import io.moquette.broker.config.IConfig; +import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.io.TempDir; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.net.ssl.*; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; +import java.security.*; import java.security.cert.CertificateException; import java.util.Properties; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import io.moquette.BrokerConstants; -import io.moquette.broker.config.IConfig; -import org.eclipse.paho.client.mqttv3.IMqttClient; -import org.eclipse.paho.client.mqttv3.MqttClient; -import org.eclipse.paho.client.mqttv3.MqttClientPersistence; -import org.eclipse.paho.client.mqttv3.MqttConnectOptions; -import org.eclipse.paho.client.mqttv3.MqttException; -import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; -import org.junit.jupiter.api.AfterAll; -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.io.TempDir; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Check that Moquette could also handle SSL with client authentication. @@ -184,6 +169,7 @@ protected void startServer(String dbPath) throws IOException { sslProps.put(IConfig.KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv"); sslProps.put(IConfig.DATA_PATH_PROPERTY_NAME, dbPath); sslProps.put(IConfig.PERSISTENCE_ENABLED_PROPERTY_NAME, "true"); + sslProps.put(IConfig.PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "h2"); sslProps.put(BrokerConstants.NEED_CLIENT_AUTH, "true"); sslProps.put(IConfig.ENABLE_TELEMETRY_NAME, "false"); m_server.startServer(sslProps); diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLTest.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLTest.java index 73099e22..39851e51 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationSSLTest.java @@ -17,41 +17,26 @@ package io.moquette.integration; import io.moquette.broker.Server; +import io.moquette.broker.config.IConfig; +import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.io.TempDir; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.jupiter.api.Assertions.assertFalse; +import javax.net.ssl.*; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; +import java.security.*; import java.security.cert.CertificateException; import java.util.Properties; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import io.moquette.broker.config.IConfig; -import org.eclipse.paho.client.mqttv3.IMqttClient; -import org.eclipse.paho.client.mqttv3.MqttClient; -import org.eclipse.paho.client.mqttv3.MqttClientPersistence; -import org.eclipse.paho.client.mqttv3.MqttConnectOptions; -import org.eclipse.paho.client.mqttv3.MqttMessage; -import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; -import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; -import org.junit.jupiter.api.AfterAll; -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.io.TempDir; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * Check that Moquette could also handle SSL. @@ -115,6 +100,7 @@ protected void startServer() throws IOException { sslProps.put(IConfig.KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv"); sslProps.put(IConfig.DATA_PATH_PROPERTY_NAME, dbPath); sslProps.put(IConfig.PERSISTENCE_ENABLED_PROPERTY_NAME, "true"); + sslProps.put(IConfig.PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "h2"); sslProps.put(IConfig.ENABLE_TELEMETRY_NAME, "false"); m_server.startServer(sslProps); } diff --git a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationWebSocketTest.java b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationWebSocketTest.java index 2911cdda..43a12373 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationWebSocketTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/integration/ServerIntegrationWebSocketTest.java @@ -16,24 +16,24 @@ package io.moquette.integration; -import io.moquette.broker.Server; import io.moquette.BrokerConstants; +import io.moquette.broker.Server; import io.moquette.broker.config.FluentConfig; -import io.moquette.broker.config.MemoryConfig; +import io.moquette.broker.config.IConfig; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; -import io.moquette.broker.config.IConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import java.io.IOException; import java.net.URI; import java.nio.file.Path; -import java.util.Properties; import java.util.concurrent.TimeUnit; + import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -64,6 +64,7 @@ protected void startServer(String dbPath) throws IOException { .withConfig() .dataPath(dbPath) .enablePersistence() + .persistentQueueType(FluentConfig.PersistentQueueType.H2) .disableTelemetry() .websocketPort(BrokerConstants.WEBSOCKET_PORT) .startServer(); diff --git a/moquette-0.17/broker/src/test/java/io/moquette/persistence/SegmentPersistentQueueTest.java b/moquette-0.17/broker/src/test/java/io/moquette/persistence/SegmentPersistentQueueTest.java index 4d94a773..25bb6e85 100644 --- a/moquette-0.17/broker/src/test/java/io/moquette/persistence/SegmentPersistentQueueTest.java +++ b/moquette-0.17/broker/src/test/java/io/moquette/persistence/SegmentPersistentQueueTest.java @@ -29,6 +29,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.io.TempDir; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,6 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +@DisabledOnOs(OS.WINDOWS) public class SegmentPersistentQueueTest { private static final Logger LOGGER = LoggerFactory.getLogger(SegmentPersistentQueueTest.class.getName());