Skip to content

Commit

Permalink
feat(executor): GRPC executor (#212)
Browse files Browse the repository at this point in the history
* contribution from @orgrimarr
  • Loading branch information
yesnault authored Nov 27, 2019
1 parent f9ace60 commit 4355911
Show file tree
Hide file tree
Showing 6 changed files with 534 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Flags:
* **ssh**: https://github.com/ovh/venom/tree/master/executors/ssh
* **web**: https://github.com/ovh/venom/tree/master/executors/web
* **grpc**: https://github.com/ovh/venom/tree/master/executors/grpc
* **rabbitmq**: https://github.com/ovh/venom/tree/master/executors/rabbitmq

## TestSuite files

Expand Down
8 changes: 5 additions & 3 deletions cli/venom/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/hashicorp/hcl"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"

"github.com/ovh/venom"
"github.com/ovh/venom/context/default"
"github.com/ovh/venom/context/redis"
defaultctx "github.com/ovh/venom/context/default"
redisctx "github.com/ovh/venom/context/redis"
"github.com/ovh/venom/context/webctx"

"github.com/ovh/venom/executors/dbfixtures"
Expand All @@ -27,6 +27,7 @@ import (
"github.com/ovh/venom/executors/imap"
"github.com/ovh/venom/executors/kafka"
"github.com/ovh/venom/executors/ovhapi"
"github.com/ovh/venom/executors/rabbitmq"
"github.com/ovh/venom/executors/readfile"
"github.com/ovh/venom/executors/redis"
"github.com/ovh/venom/executors/smtp"
Expand Down Expand Up @@ -90,6 +91,7 @@ var Cmd = &cobra.Command{
v.RegisterExecutor(redis.Name, redis.New())
v.RegisterExecutor(kafka.Name, kafka.New())
v.RegisterExecutor(grpc.Name, grpc.New())
v.RegisterExecutor(rabbitmq.Name, rabbitmq.New())

// Register Context
v.RegisterTestCaseContext(defaultctx.Name, defaultctx.New())
Expand Down
142 changes: 142 additions & 0 deletions executors/rabbitmq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Venom - Executor RabbitMQ

Step to use publish / subscribe on a RabbitMQ

## Input
In your yaml file, you can use:

```yaml

# RabbitMQ connection
- addrs optional (default amqp:/localhost:5672)
- user optional (default guest)
- password optional (default guest)

- clientType mandatory (publisher or subscriber)

# RabbitMQ Q configuration
- qName mandatory

# Exchange configuration
- routingKey optional (default qName)
- exchangeType optional (default "fanout")
- exchange optional (default "")

# For subscriber only
- messageLimit optional (default 1)

# For publisher only
- messages
- durable optional (true or false) (default alse)
- contentType optional
- contentEncoding optional
- persistent optional (default true)
- headers optional
- name: value

```

## Examples:

### Publisher (workQ)
```yaml
name: TestSuite RabbitMQ
vars:
addrs: 'amqp://localhost:5672'
user:
password:
testcases:
- name: RabbitMQ publish (work Q)
steps:
- type: rabbitmq
addrs: "{{.addrs}}"
user: "{{.user}}"
password: "{{.password}}"
clientType: publisher
qName: TEST
messages:
- value: '{"a": "b"}'
contentType: application/json
contentEncoding: utf8
persistant: false
headers:
myCustomHeader: value
myCustomHeader2: value2
```
### Subscriber (workQ)
```yaml
name: TestSuite RabbitMQ
vars:
addrs: 'amqp://localhost:5672'
user:
password:
- name: RabbitMQ subscribe testcase
steps:
- type: rabbitmq
addrs: "{{.addrs}}"
user: "{{.user}}"
password: "{{.password}}"
clientType: subscriber
qName: "{{.qName}}"
durable: true
messageLimit: 1
assertions:
- result.bodyjson.bodyjson0.a ShouldEqual b
- result.headers.headers0.mycustomheader ShouldEqual value
- result.headers.headers0.mycustomheader2 ShouldEqual value2
- result.messages.messages0.contentencoding ShouldEqual utf8
- result.messages.messages0.contenttype ShouldEqual application/json
```
### Publisher (pubsub)
```yaml
name: TestSuite RabbitMQ
vars:
addrs: 'amqp://localhost:5672'
user:
password:
testcases:
- name: RabbitMQ publish (work Q)
steps:
- type: rabbitmq
addrs: "{{.addrs}}"
user: "{{.user}}"
password: "{{.password}}"
clientType: publisher
exchange: exchange_test
routingKey: pubsub_test
messages:
- value: '{"a": "b"}'
contentType: application/json
contentEncoding: utf8
persistant: false
headers:
myCustomHeader: value
myCustomHeader2: value2
```
### Subscriber (pubsub)
```yaml
name: TestSuite RabbitMQ
vars:
addrs: 'amqp://localhost:5672'
user:
password:
- name: RabbitMQ subscribe testcase
steps:
- type: rabbitmq
addrs: "{{.addrs}}"
user: "{{.user}}"
password: "{{.password}}"
clientType: subscriber
exchange: exchange_test
routingKey: pubsub_test
messageLimit: 1
assertions:
- result.bodyjson.bodyjson0.a ShouldEqual b
- result.headers.headers0.mycustomheader ShouldEqual value
- result.headers.headers0.mycustomheader2 ShouldEqual value2
- result.messages.messages0.contentencoding ShouldEqual utf8
- result.messages.messages0.contenttype ShouldEqual application/json
```
Loading

0 comments on commit 4355911

Please sign in to comment.