diff --git a/README.md b/README.md index 549ea1a..a52d145 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ 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` @@ -66,6 +66,8 @@ It offers six simple scenarios. * `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: @@ -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 @@ -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)). diff --git a/scripts/quickStart.sh b/scripts/quickStart.sh index 45c33ed..328e11f 100755 --- a/scripts/quickStart.sh +++ b/scripts/quickStart.sh @@ -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" } @@ -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 @@ -367,6 +400,12 @@ case $1 in "tlsBasic") tlsBasic ;; + "rxBasic") + rxBasic + ;; + "rxTlsBasic") + rxTlsBasic + ;; "") base_example ;; diff --git a/src/main/java/io/bonitoo/qa/conf/RunnerConfig.java b/src/main/java/io/bonitoo/qa/conf/RunnerConfig.java index ae91040..1de44a6 100644 --- a/src/main/java/io/bonitoo/qa/conf/RunnerConfig.java +++ b/src/main/java/io/bonitoo/qa/conf/RunnerConfig.java @@ -26,7 +26,6 @@ public class RunnerConfig { List devices; Long ttl; - // TODO add here rxOrBlocking config option. Mode mode = Mode.BLOCKING; @Override diff --git a/src/main/java/io/bonitoo/qa/conf/RunnerConfigDeserializer.java b/src/main/java/io/bonitoo/qa/conf/RunnerConfigDeserializer.java index 6d0c3dc..d857f11 100644 --- a/src/main/java/io/bonitoo/qa/conf/RunnerConfigDeserializer.java +++ b/src/main/java/io/bonitoo/qa/conf/RunnerConfigDeserializer.java @@ -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 diff --git a/src/test/resources/testRunnerRxConfig.yml b/src/test/resources/testRunnerRxConfig.yml new file mode 100644 index 0000000..d7eb97a --- /dev/null +++ b/src/test/resources/testRunnerRxConfig.yml @@ -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" \ No newline at end of file diff --git a/src/test/resources/testRunnerRxTlsConfig.yml b/src/test/resources/testRunnerRxTlsConfig.yml new file mode 100644 index 0000000..0c9b5fd --- /dev/null +++ b/src/test/resources/testRunnerRxTlsConfig.yml @@ -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" \ No newline at end of file