Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add NATS executor #821

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d5ab991
feat(executor/nats): add pub/sub
LuBashQ Oct 31, 2024
8174a7c
feat(executor/nats): add integration test for subscriber cmd
LuBashQ Oct 31, 2024
4a09969
feat(executor/nats): remove request command
LuBashQ Oct 31, 2024
cf83503
feat(executor/nats): add jetstream consumer subscribe options
LuBashQ Oct 31, 2024
342dca0
refactor(executor/nats): extract consumer creation
LuBashQ Oct 31, 2024
859e775
refactor(executor/nats): add default url on executor creation
LuBashQ Oct 31, 2024
e6b1b81
feat(executor/nats): add jetstream message publishing
LuBashQ Nov 2, 2024
5b7e821
refactor(executor/nats): integration tests
LuBashQ Nov 2, 2024
8ae0d0c
refactor(executor/nats): add more debug logs
LuBashQ Nov 2, 2024
db411e4
feat(executor/nats): add nats server to test stack
LuBashQ Nov 2, 2024
b21e240
feat(executor/nats): remove request/reply test
LuBashQ Nov 2, 2024
4464b01
test(Makefile): add commands and args to docker_run
LuBashQ Nov 2, 2024
12da00f
Revert "feat(executor/nats): remove request/reply test"
LuBashQ Nov 2, 2024
1f56fdd
test(executor/nats): add more test cases
LuBashQ Nov 2, 2024
4d042c5
test(Makefile): add nats publisher and replier clients
LuBashQ Nov 2, 2024
3576949
docs(executor/nats): document structs and add debug logs
LuBashQ Nov 3, 2024
7047978
feat(executor/nats): add TLS support
LuBashQ Nov 3, 2024
7ec7c60
test(executor/nats): generate PKI
LuBashQ Nov 3, 2024
540a20b
test(Makefile): enable TLS in NATS integration tests
LuBashQ Nov 3, 2024
5ac9cd4
docs(executor/nats): add README.md
LuBashQ Nov 3, 2024
309b8b4
docs(executor/nats): specify better available commands
LuBashQ Nov 3, 2024
7103845
feat(executor/nats): add JSON support for message data
LuBashQ Nov 8, 2024
56afb19
refactor(executor/nats): use nil check to check if Jetstream is enabled
LuBashQ Nov 11, 2024
e24c5df
feat(executor/nats): Add delivery option to Jetstream
LuBashQ Nov 11, 2024
a4d8a3e
feat(executor/nats): Add ACK option to Jetstream
LuBashQ Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ tests/pki_variables.yml
*.xml
test_results*.html
!venom_output.html
tests/nats/pki
122 changes: 122 additions & 0 deletions executors/nats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Venom - Executor NATS

Step to publish and subscribe to NATS subjects.

Currently two commands are supported:

- `publish`
- `subscribe`

## Input

### Defaults

This step includes some default values:

- `url`: defaults to `nats://localhost:4222`
- `messageLimit`: defaults to 1
- `deadline`: defaults to 1 second

### Authentication

This step allows for connection with and without TLS. Without TLS, the step does not require additional options.

To connect to a NATS server with TLS, declare:

```yaml
tls:
selfSigned: true
serverVerify: true
certificatePath: "/path/to/client_certificate"
keyPath: "/path/to/client_key"
caPath: ""/path/to/ca_certificate""
```

Enable `selfSigned` only if the NATS server uses self-signed certificates. If enabled, `caPath` is mandatory.

Enable `serverVerify` only if the NATS server verifies the client certificates. If enabled `certificatePath` and `keyPath` are mandatory.

### publish command

The `publish` command allows to publish a payload to a specific NATS subject. Optionally it can wait for a reply.

Full configuration example:

```yaml
- type: nats
url: "{{.url}}" # defaults to nats://localhost:4222 if not set
command: publish
subject: "{{.subject}}" # mandatory
payload: '{{.message}}'
headers:
customHeader:
- "some-value"
assertions:
- result.error ShouldBeEmpty
```

Full configuration with reply example:

```yaml
- type: nats
url: "{{.url}}" # defaults to nats://localhost:4222 if not set
command: publish
request: true
subject: "{{.subject}}" # mandatory
replySubject: "{{.subject}}.reply" # mandatory if `request = true`
payload: '{{.message}}'
assertions:
- result.error ShouldBeEmpty
- result.messages.__Len__ ShouldEqual 1
```

It is possible to publish to a Jetstream stream by declaring `jetstream: true` in the step.

For example:

```yaml
- type: nats
command: publish
subject: "{{.subject}}.hello" # mandatory
deadline: 2
jetstream:
enabled: true
assertions:
- result.error ShouldNotBeEmpty
```

### subscribe command

The `subscribe` command allows to receive messages from a subject or a stream.

Full configuration example:

```yaml
- type: nats
command: subscribe
subject: "{{.subject}}.>" # mandatory
messageLimit: 2 # defaults to 1
deadline: 10 # in seconds, defaults to 1
assertions:
- result.error ShouldBeEmpty
- result.messages.__Len__ ShouldEqual 2
```

Full configuration example with Jetstream:

```yaml
- type: nats
command: subscribe
subject: "{{.subject}}.>" # mandatory
messageLimit: 2 # defaults to 1
deadline: 10 # in seconds, defaults to 1
jetstream:
enabled: true
stream: TEST # mandatory, stream must exist
filterSubjects:
- "{{.subject}}.js.hello"
- "{{.subject}}.js.world"
assertions:
- result.error ShouldBeEmpty
- result.messages.__Len__ ShouldEqual 2
```
Loading