amqp

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

Venom - Executor AMQP

Step to publish / subscribe to AMQP 1.0 compatible broker (currently implemented by QPID and ActiveMQ, among others)

Input

- addr         (address of the amqp broker to connect to, in the format "amqp://<host>:<port>")
- clientType   (consumer or producer)

# Consumer Parameters
- sourceAddr   (source topic/queue to consume messages from)
- messageLimit (number of messages to read from the broker before returning result)

# Producer Parameters
- targetAddr   (topic/queue to which messages should be published)
- messages     (array of message bodies to send to the broker)

Output

Populated when ClientType is consumer

- result.messages     (array of strings, each containing the body of a response message)
- result.messagesJSON (if response is JSON, corresponding index will be populated with the navigable body of a response)

Examples

Publisher
name: AMQP
testcases:
  - name: Producer
    steps:
      - type: amqp
        addr: amqp://localhost:5673
        clientType: producer
        targetAddr: amqp-test
        messages:
          - '{"key1":"value1","key2":"value2"}'
          - '{"key3":"value3","key4":"value4"}'
          - 'not json'
          - '["value5","value6"]'
Consumer
name: AMQP
testcases:
  - name: Consumer
    steps:
     - type: amqp
        addr: amqp://localhost:5673
        clientType: consumer
        sourceAddr: amqp-test
        messageLimit: 4
        assertions:
          - result.messages.__len__ ShouldEqual 4
          - result.messages.messages0 ShouldEqual '{"key1":"value1","key2":"value2"}'
          - result.messages.messages1 ShouldEqual '{"key3":"value3","key4":"value4"}'
          - result.messages.messages2 ShouldEqual 'not json'
          - result.messages.messages3 ShouldEqual '["value5","value6"]'
          - result.messagesjson.__len__ ShouldEqual 4
          - result.messagesjson.messagesjson0.key1 ShouldEqual value1
          - result.messagesjson.messagesjson0.key2 ShouldEqual value2
          - result.messagesjson.messagesjson1.key3 ShouldEqual value3
          - result.messagesjson.messagesjson1.key4 ShouldEqual value4
          - result.messagesjson.messagesjson3.messagesjson30 ShouldEqual value5
          - result.messagesjson.messagesjson3.messagesjson31 ShouldEqual value6

Documentation

Index

Constants

View Source
const Name = "amqp"

Name of executor

Variables

This section is empty.

Functions

func New

func New() venom.Executor

New returns a new Executor

Types

type Executor

type Executor struct {
	Addr string `json:"addr" yaml:"addr"`

	// ClientType must be "consumer" or "producer"
	ClientType string `json:"clientType" yaml:"clientType"`

	// Used when ClientType is consumer
	// SourceAddr represents the source address from which to read incoming messages
	SourceAddr string `json:"sourceAddr" yaml:"sourceAddr"`
	// MessageLimit represents the limit of message will be read. After limit, consumer will stop reading
	MessageLimit uint `json:"messageLimit" yaml:"messageLimit"`

	// Used when ClientType is producer
	// TargetAddr represents the target address to which outgoing messages should be published
	TargetAddr string `json:"targetAddr" yaml:"targetAddr"`
	// Messages represents the messages to be sent by producer
	Messages []string `json:"messages" yaml:"messages"`
}

Executor represents a Test Exec

func (Executor) Run

func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, error)

Run execute TestStep

func (Executor) ZeroValueResult

func (Executor) ZeroValueResult() interface{}

ZeroValueResult returns an empty implementation of this executor result

type Result

type Result struct {
	Messages     []string      `json:"messages" yaml:"messages"`
	MessagesJSON []interface{} `json:"messagesJSON" yaml:"messagesJSON"`
}

Result represents a step result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL