Test Harness to Publish Event History Message to NATS Streams for ST-EH. The harness publishes a configurable rate of messages for a specified amount of time.
The Stream and the Durable Consumer are both expected to be created prior to running the test.
In order to distribute connections across the cluster all endpoints need to be passed via the cli. (using -s)
- -s is the location of the NATs URL, if passing multiples, separate them by a space and enclose the entire list in quotes.
- -stream The Name of the Stream to Publish to or Consume From
- -tst is one of:
- loadTest - this is used to publish messages at a fixed rate for a set amount of time
- consumeOnSchedule this is used to launch a consumer every 30 seconds to read the number of messages in the -bs or until there are no more messages
- neverClosingSingleConsumer - this is used to launch a never ending consumer that simply continues to wait until more messages show up , but will read them in batches of -bs
- -ttm Total Time in Minutes to run the loadTest
- -mps Messages Per Second per Publisher during the loadTest
- -nps Number of Publishers to be used in the loadTest
- -consName the name of the durable consumer that should be used when consuming messages
- -bs batch size, the total number of messages to consume per connection. not to be confused with the batch size that NATs uses internally
- -subject The subject used when filtering the Events from the Consumer
In order to execute the test harness easily in a deployed env where NATS is not exposed to an external IP.
- Execute the fatJar gradle task, this will create a jar file under build/libs/PopulateEventToNats-1.0-SNAPSHOT.jar (or something very similar)
- Copy the jar file to a temporary directory on one of the pods that has java already available (for example ocs-aio-0)
- if you have kubectl configured locally to access a remote env then you can use the following command from the build/libs directory
kubectl cp -n oce-dc01 PopulateEventToNats-1.0-SNAPSHOT.jar ocs-aio-0:/tmp/PopulateEventToNats-1.0-SNAPSHOT.jar -c main
- if you have kubectl configured locally to access a remote env then you can use the following command from the build/libs directory
- Once copied to the remote pod, log into the pod
- if you have the oc cli tooling installed and configured you can use something like the following command
oc -n oce-dc01 -it exec ocs-aio-0 -c main -- bash
- if you have the oc cli tooling installed and configured you can use something like the following command
- Run the loadTest at 800 messages per second for 10 minutes using 8 publishers, notice how all 3 nats pod endpoints are passed using -s, this distributes the connections evenly
java -jar /tmp/PopulateEventToNats-1.0-SNAPSHOT.jar -s='ocernd06-eh-nats-0.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-1.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-2.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222' -tst=loadTest -ttm=120 -mps=100 -np=8
- Consume the messages using a scheduled consumer - the connections will be opened and closed repeatedly
- Two things to note about the consumer - the subject really needs to match what the stream is configured with, otherwise there will be an error. If in doubt leave it out and use the default. Second is that the subject is surrounded with quotes because of the .> at the end
java -jar /tmp/PopulateEventToNats-1.0-SNAPSHOT.jar -s='ocernd06-eh-nats-0.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-1.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-2.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222' -tst=consumeOnSchedule -stream=Events -consName=zdataDurName -bs=100000 -subject="Events.>"
- Two things to note about the consumer - the subject really needs to match what the stream is configured with, otherwise there will be an error. If in doubt leave it out and use the default. Second is that the subject is surrounded with quotes because of the .> at the end
- Consume the messages using a single never ending consumer - using a single durable connection
java -jar /tmp/PopulateEventToNats-1.0-SNAPSHOT.jar -s='ocernd06-eh-nats-0.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-1.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-2.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222' -tst=neverClosingSingleConsumer -stream=Events -consName=zdataDurName -bs=100000 -subject="Events.>"java -jar /tmp/PopulateEventToNats-1.0-SNAPSHOT.jar -s='ocernd06-eh-nats-0.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-1.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-2.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222' -tst=scheduleBasedEphemeralPullConsumer -subject="Events.>"java -jar /tmp/PopulateEventToNats-1.0-SNAPSHOT.jar -s='ocernd06-eh-nats-0.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-1.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222 ocernd06-eh-nats-2.ocernd06-eh-nats.ocernd06-eh.svc.cluster.local:4222' -tst=scheduleBasedEphemeralPushConsumer -subject="Events.>"