Skip to content

Commit

Permalink
fix(test): set persistence to h2 by default so tests can pass on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo committed Sep 14, 2023
1 parent aea8746 commit bcc368e
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -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");

Check failure

Code scanning / CodeQL

Hard-coded credential in API call Critical library test

Hard-coded value flows to
sensitive API call
.
Hard-coded value flows to
sensitive API call
.
Hard-coded value flows to
sensitive API call
.
sslProps.put(IConfig.PERSISTENT_QUEUE_TYPE_PROPERTY_NAME, "h2");

Check failure

Code scanning / CodeQL

Hard-coded credential in API call Critical library test

Hard-coded value flows to
sensitive API call
.
Hard-coded value flows to
sensitive API call
.
Hard-coded value flows to
sensitive API call
.

sslProps.put(IConfig.ENABLE_TELEMETRY_NAME, "false");
m_server.startServer(sslProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down

0 comments on commit bcc368e

Please sign in to comment.