-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added workflow for testing a broker in container
- Loading branch information
1 parent
f70e933
commit a13c18d
Showing
3 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Polypheny-DB MQTT Client Test | ||
|
||
on: | ||
push: { branches: mqtt-interface } | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: MQTT Client Tests (Java 17) | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 17 | ||
- name: Set env variable | ||
run: | | ||
echo "POLYPHENY_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV | ||
- name: Create folders for certs | ||
run: | | ||
mkdir $POLYPHENY_HOME/.polypheny | ||
mkdir $POLYPHENY_HOME/.polypheny/certs | ||
- name: Start Mosquitto broker in docker container | ||
uses: namoshek/mosquitto-github-action@v1 | ||
with: | ||
version: '5' | ||
ports: '1883:1883' | ||
container-name: 'mqttBroker' | ||
|
||
- name: Assemble | ||
uses: nick-invision/retry@v2 | ||
with: | ||
max_attempts: 2 | ||
timeout_minutes: 60 | ||
command: ./gradlew assemble | ||
|
||
- name: Build Plugins | ||
uses: nick-invision/retry@v2 | ||
with: | ||
max_attempts: 1 | ||
timeout_minutes: 60 | ||
command: ./gradlew assemblePlugins | ||
|
||
- name: Execute MQTT client tests | ||
uses: nick-invision/retry@v2 | ||
with: | ||
max_attempts: 1 | ||
timeout_minutes: 30 | ||
command: ./gradlew mqttTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
plugins/mqtt-stream/src/test/java/org/polypheny/db/mqtt/MqttClientBrokerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2019-2023 The Polypheny Project | ||
* | ||
* 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.polypheny.db.mqtt; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.polypheny.db.TestHelper; | ||
import org.polypheny.db.iface.QueryInterface; | ||
import org.polypheny.db.iface.QueryInterfaceManager; | ||
import org.polypheny.db.mqtt.MqttStreamPlugin.MqttStreamClient; | ||
import org.polypheny.db.transaction.Transaction; | ||
import org.polypheny.db.transaction.TransactionManager; | ||
|
||
public class MqttClientBrokerTest { | ||
|
||
|
||
static TransactionManager transactionManager; | ||
static Transaction transaction; | ||
static Map<String, String> initialSettings = new HashMap<>(); | ||
static Map<String, String> changedSettings = new HashMap<>(); | ||
static MqttStreamClient client; | ||
|
||
@BeforeClass | ||
public static void init() { | ||
TestHelper testHelper = TestHelper.getInstance(); | ||
transactionManager = testHelper.getTransactionManager(); | ||
transaction = testHelper.getTransaction(); | ||
initialSettings.clear(); | ||
initialSettings.put( "brokerAddress", "1883" ); | ||
initialSettings.put( "brokerPort", "1883" ); | ||
initialSettings.put( "commonCollectionName", "testCollection" ); | ||
initialSettings.put( "commonCollection", "true" ); | ||
initialSettings.put( "namespace", "testNamespace" ); | ||
initialSettings.put( "namespaceType", "DOCUMENT" ); | ||
initialSettings.put( "topics", "button" ); | ||
initialSettings.put( "Tsl/SslConnection", "false" ); | ||
initialSettings.put( "filterQuery", "" ); | ||
|
||
QueryInterface iface = QueryInterfaceManager.getInstance().getQueryInterface( "mqtt" ); | ||
|
||
client = new MqttStreamClient( | ||
transactionManager, | ||
null, | ||
iface.getQueryInterfaceId(), | ||
iface.getUniqueName(), | ||
initialSettings ); | ||
|
||
} | ||
|
||
/* | ||
@Before | ||
public void resetSettings() { | ||
initialSettings.clear(); | ||
initialSettings.put( "brokerAddress", "1883" ); | ||
initialSettings.put( "brokerPort", "1883" ); | ||
initialSettings.put( "commonCollectionName", "testCollection" ); | ||
initialSettings.put( "commonCollection", "true" ); | ||
initialSettings.put( "namespace", "testNamespace" ); | ||
initialSettings.put( "namespaceType", "DOCUMENT" ); | ||
initialSettings.put( "topics", "" ); | ||
initialSettings.put( "Tsl/SslConnection", "false" ); | ||
initialSettings.put( "filterQuery", "" ); | ||
QueryInterface iface = QueryInterfaceManager.getInstance().getQueryInterface( "mqtt" ); | ||
client = new MqttStreamClient( | ||
transactionManager, | ||
null, | ||
iface.getQueryInterfaceId(), | ||
iface.getUniqueName(), | ||
initialSettings ); | ||
changedSettings.clear(); | ||
changedSettings.put( "commonCollectionName", "testCollection" ); | ||
changedSettings.put( "commonCollection", "true" ); | ||
changedSettings.put( "namespace", "testNamespace" ); | ||
changedSettings.put( "topics", "" ); | ||
changedSettings.put( "filterQuery", "" ); | ||
} | ||
*/ | ||
|
||
@Test | ||
public void connectionTest() { | ||
Map<String, AtomicLong> topicsMap = client.getTopicsMap(); | ||
assertEquals( 1, topicsMap.size() ); | ||
assertEquals( 0, topicsMap.get( "button" ) ); | ||
} | ||
|
||
|
||
|
||
|
||
} |