Skip to content

Commit

Permalink
chore: adds new quick start targets and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
karel-rehor committed Nov 10, 2023
1 parent cb722dc commit 85e9cfe
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ For a quick peek at what this project does and how it works, try `scripts/quick
1. remove any copied plugins.
1. tear down the listener and broker.

It offers six simple scenarios.
It offers eight simple scenarios.

* `no args` - runs a simple scenario without plugins.
* `nrf9160` - runs with the `runner.conf` file set to `examples/nrf9160/thingy91.yml`
* `itemPlugin` - runs a scenario with the accelerator item plugin.
* `itemPluginRich` - runs a richer scenario with the simpleMovingAverage item plugin.
* `samplePlugin` - runs a scenario with the lpFileReader sample plugin.
* `tlsBasic` - runs the simple scenario without plugins but sets up mosquitto to accept only TLS connections at the default TLS port - 8883.
* `rxBasic` - runs a simple scenario using a Reactivex enabled client.
* `rxTlsBasic` - runs a simple scenario using a Reactivex enabled client, communicating with the broker over TLS.

For example:

Expand All @@ -82,11 +84,11 @@ RUNNING BASIC EXAMPLE
...
```

**Note on tlsBasic**
**Note on tlsBasic and rxTlsBasic**

The `tlsBasic` scenario generates a self-signed certificate used to configure a mosquitto MQTT server running in a docker container. The CN value of the generated certificates is defined as an IP address, which should match a host IP over which the mosquitto server is accessible. The script `scripts/selfSignCert.sh` attempts to get such an IP address from a running ethernet or wifi interface, however this is not always reliable. This value can also be declared using the environment variable `VD_HOST_IP`. For example declare `$ export VD_HOST_IP=192.168.101.102` before running either `selfSignCert.sh` or `quickStart.sh`. Other environment variables are available for setting subject values in certificates. To view them run `scripts/selfSignCert.sh --help`.
These scenarios generate a self-signed certificate used to configure a mosquitto MQTT server running in a docker container. The CN value of the generated certificates is defined as an IP address, which should match a host IP over which the mosquitto server is accessible. The script `scripts/selfSignCert.sh` attempts to get such an IP address from a running ethernet or wifi interface, however this is not always reliable. This value can also be declared using the environment variable `VD_HOST_IP`. For example declare `$ export VD_HOST_IP=192.168.101.102` before running either `selfSignCert.sh` or `quickStart.sh`. Other environment variables are available for setting subject values in certificates. To view them run `scripts/selfSignCert.sh --help`.

If the `tlsBasic` scenario fails, for example the subscriber fails to connect thus ending in an `SSLHandshakeException`, try stopping the mosquitto server and cleaning up the environment with these commands: `scripts/broker stop` and `sudo scripts/broker clean -certs`. Then try and run it again.
If either of these scenarios fails, for example the subscriber fails to connect thus ending in an `SSLHandshakeException`, try stopping the mosquitto server and cleaning up the environment with these commands: `scripts/broker stop` and `sudo scripts/broker clean -certs`. Then try and run it again.

## Basic Tasks

Expand Down Expand Up @@ -187,7 +189,10 @@ An alternate base property file can be defined through the environment variable

The file indicated by the `runner.conf` property must be a valid YAML file. It needs to define the following nodes.

* `ttl` - time to live in milliseconds or how long the device runner should run.
* `ttl` - time to live in milliseconds or how long the device runner should run.
* `mode` - (Optional) the mode to use when communicating with a broker. The following values are currently supported.
* `Block`, `Blocking` - blocks when communicating with the broker, waiting for acknowledgements on publish. When this node is omitted the runner defaults to blocking mode.
* `Rx`, `Reactive`, `Reactivex` - uses reactive idioms when communicating asynchronously with the broker.
* `broker` - a configuration for connecting to an MQTT5 broker (see [below](#broker)).
* `items` - a list of items to be included in a sample. Item values will be generated randomly (see [below](#items)).
* `samples` - a list of samples bound to a topic and including a payload based on an internal item list (see [below](#samples)).
Expand Down
39 changes: 39 additions & 0 deletions scripts/quickStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ function help(){
echo "$MY_NAME samplePlugin - runs a configuration with a sample plugin"
echo "$MY_NAME nrf9160 - runs without plugins but with example runner.conf"
echo "$MY_NAME tlsBasic - runs the basic configuration against mosquitto with TLS."
echo "$MY_NAME rxBasic - runs a configuration using reactivex."
echo "$MY_NAME rxTlsBasic - runs a configuration using reactivex against a TLS broker."
echo "$MY_NAME help - returns this message"
}

Expand Down Expand Up @@ -349,6 +351,37 @@ function tlsBasic(){
shutdown
}

function rxBasic(){
setup
printf "\n\nRUNNING REACTIVEX BASIC EXAMPLE\n"
printf "===============================\n"

scripts/runner.sh src/test/resources/testRunnerRxConfig.yml

printf "\n\nDONE PUBLISHING REACTIVEX BASIC EXAMPLE\n"
printf "=======================================\n"

read_log

shutdown
}

function rxTlsBasic(){
setup_tls
printf "\n\nRUNNING REACTIVE WITH TLS BASIC EXAMPLE\n"
printf "=======================================\n"

scripts/runner.sh src/test/resources/testRunnerRxTlsConfig.yml

printf "\n\nDONE PUBLISHING REACTIVE WITH TLS BASIC EXAMPLE\n"
printf "===============================================\n"

read_log

shutdown

}

# TODO use case with special runner config only

case $1 in
Expand All @@ -367,6 +400,12 @@ case $1 in
"tlsBasic")
tlsBasic
;;
"rxBasic")
rxBasic
;;
"rxTlsBasic")
rxTlsBasic
;;
"")
base_example
;;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/io/bonitoo/qa/conf/RunnerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class RunnerConfig {
List<DeviceConfig> devices;
Long ttl;

// TODO add here rxOrBlocking config option.
Mode mode = Mode.BLOCKING;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public RunnerConfig deserialize(JsonParser jsonParser, DeserializationContext ct
JsonNode itemsNode = node.get("items"); // can be null
JsonNode samplesNode = node.get("samples"); // can be null
JsonNode devicesNode = node.get("devices");
// TODO node for mode - reactivex or blocking - default blocking
JsonNode modeNode = node.get("mode"); // can be null

if (ttlNode == null
Expand Down
80 changes: 80 additions & 0 deletions src/test/resources/testRunnerRxConfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
ttl: 10000
mode: RX
broker:
host: localhost
port: 1883
auth:
username: fred
password: changeit
items:
- name: "tension"
type: "Double"
label: "bar"
max: 2.0
min: -1.0
period: 1
- name: "nuts"
type: "Long"
label: "nutcount"
max: 100.0
min: 1.0
period: 1
- name: "label"
type: "String"
label: "label"
values:
- "Salted"
- "unsalted"
- "smoked"
samples:
- id: "random"
name: "alpha"
topic: "test/alpha"
items:
- "tension"
- "nuts"
- id: "random"
name: "beta"
topic: "test/beta"
items:
- "label"
- name: "flowRate"
label: "cmps"
type: Double
max: 30
min: 5
period: 2
devices:
- id: "random"
name: "Test Device 01"
description: "testing device configuration"
interval: 500
jitter: 0
count: 1
samples:
- "alpha"
- "beta"
- id: "random"
name: "Test Device 02"
description: "test device configuration"
interval: 1000
jitter: 500
count: 1
samples:
- beta
- id: "random"
name: "gammaInline"
topic: "test/gamma"
items:
- name: "radiance"
type: "Double"
label: "lumens"
max: 27
min: 0.1
period: 2
- name: "appLabel"
type: "String"
label: "app"
values:
- "luminescence"
83 changes: 83 additions & 0 deletions src/test/resources/testRunnerRxTlsConfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
ttl: 10000
mode: Reactive
broker:
host: localhost
port: 8883
auth:
username: fred
password: changeit
tls:
trustStore: "./scripts/keys/brokerTrust.jks"
trustPass: "ENCqTJZQarWDANjbiKQRH1R5/Dw3jNtSIYq12fIt67sIPEAAAAQmi6eCz/B3DynfmBHkC30s9n9/ynDhlcNo2yDA7ma90k="
items:
- name: "tension"
type: "Double"
label: "bar"
max: 2.0
min: -1.0
period: 1
- name: "nuts"
type: "Long"
label: "nutcount"
max: 100.0
min: 1.0
period: 1
- name: "label"
type: "String"
label: "label"
values:
- "Salted"
- "unsalted"
- "smoked"
samples:
- id: "random"
name: "alpha"
topic: "test/alpha"
items:
- "tension"
- "nuts"
- id: "random"
name: "beta"
topic: "test/beta"
items:
- "label"
- name: "flowRate"
label: "cmps"
type: Double
max: 30
min: 5
period: 2
devices:
- id: "random"
name: "Test Device 01"
description: "testing device configuration"
interval: 1000
jitter: 0
count: 1
samples:
- "alpha"
- "beta"
- id: "random"
name: "Test Device 02"
description: "test device configuration"
interval: 3000
jitter: 500
count: 1
samples:
- beta
- id: "random"
name: "gammaInline"
topic: "test/gamma"
items:
- name: "radiance"
type: "Double"
label: "lumens"
max: 27
min: 0.1
period: 2
- name: "appLabel"
type: "String"
label: "app"
values:
- "luminescence"

0 comments on commit 85e9cfe

Please sign in to comment.