Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Fix moquette tests on windows (#2217)

Rich Turner5a1b58fb4e59
diff --git a/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy
index 8aeb9cea2..307c4516b 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy
@@ -82,11 +82,12 @@ class ChirpStackTest extends Specification implements ManagerContainerTrait {
Mqtt3AsyncClient mqttClient
def setupSpec() {
- tempDataDir = File.createTempDir('moquette_data_', '').toPath()
+ tempDataDir = File.createTempDir('moquette_data', '').toPath()
mqttBrokerPort = findEphemeralPort()
def props = new Properties()
props.setProperty('port', mqttBrokerPort.toString())
- props.setProperty('persistent_store', tempDataDir.resolve('moquette_store.mapdb').toString())
+ // Moquette assumes linux paths so need to convert windows paths
+ props.setProperty('persistent_store', tempDataDir.resolve('moquette_store.mapdb').toString().replace('\\', '/'))
def config = new MemoryConfig(props)
mqttBroker = new Server()
mqttBroker.startServer(config)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy
index 0975add77..f560d5b66 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy
@@ -97,11 +97,12 @@ class TheThingsStackTest extends Specification implements ManagerContainerTrait
Mqtt3AsyncClient mqttClient
def setupSpec() {
- tempDataDir = File.createTempDir('moquette_data_', '').toPath()
+ tempDataDir = File.createTempDir('moquette_data', '').toPath()
mqttBrokerPort = findEphemeralPort()
def props = new Properties()
props.setProperty('port', mqttBrokerPort.toString())
- props.setProperty('persistent_store', tempDataDir.resolve('moquette_store.mapdb').toString())
+ // Moquette assumes linux paths so need to convert windows paths
+ props.setProperty('persistent_store', tempDataDir.resolve('moquette_store.mapdb').toString().replace('\\', '/'))
def config = new MemoryConfig(props)
mqttBroker = new Server()
mqttBroker.startServer(config)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy
index 81895631a..0b83e471d 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy
@@ -524,17 +524,18 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
def "Check MQTT client protocol wildcard subscriptions"() {
given: "expected conditions"
- def conditions = new PollingConditions(timeout: 10, delay: 0.2)
+ def conditions = new PollingConditions(timeout: 20, delay: 0.2)
when: "the container starts"
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
def agentService = container.getService(AgentService.class)
- def brokerService = container.getService(MQTTBrokerService.class)
+ def mqttBrokerService = container.getService(MQTTBrokerService.class)
def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
- def mqttHost = brokerService.host
- def mqttPort = brokerService.port
+ def mqttHost = mqttBrokerService.host
+ def mqttPort = mqttBrokerService.port
def mqttAgentClientId = UniqueIdentifierGenerator.generateId()
+ def defaultMQTTHandler = mqttBrokerService.getCustomHandlers().find {it instanceof DefaultMQTTHandler} as DefaultMQTTHandler
and: "test assets are created"
def testThing1 = new ThingAsset("Test thing 1")
@@ -643,6 +644,8 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
assert protocol.wildcardTopicConsumerMap.get(wildcardTopic2).size() == 1
assert protocol.wildcardTopicConsumerMap.get(wildcardTopic2).containsKey(pressureTopic)
assert protocol.wildcardTopicConsumerMap.get(wildcardTopic2).get(pressureTopic).size() == 1
+ def connection = mqttBrokerService.getUserConnections(keycloakTestSetup.serviceUser.id)[0]
+ assert defaultMQTTHandler.sessionSubscriptionConsumers.get(getConnectionIDString(connection)).size() == 3
}
when: "mqtt data is published"