I/O Modules for Compass Test Automation, One of Libraries in CTA-OSS Framework
This I/O (Input / Output) Module provides communications between CTA-OSS Framework and outsides services via messaging.
We aim to give you brief guidelines here.
cta-io extends Brick (cta-brick). In order to use it, we need to provide a configuration. The cta-io depends on cta-messaging which provides messaging as a tool.
// a full sample code:
const config = {
tools: [{
name: 'sample.messaging',
module: 'cta-messaging',
properties: {
provider: 'rabbitmq',
parameters: {
url: 'amqp://localhost?heartbeat=60',
},
},
}],
bricks: [{
name: 'Receiver',
module: 'cta-io',
dependencies: {
messaging: 'sample.messaging',
},
properties: {
input: {
queue: 'input.queue',
},
},
publish: [{
topic: 'sample.topics',
data: [{}],
}],
}, {
name: 'Sender',
module: 'cta-io',
dependencies: {
messaging: 'sample.messaging',
},
properties: {},
subscribe: [{
topic: 'sample.topics',
data: [{}],
}],
}],
};
const config = {
tools: [{
name: 'sample.messaging',
module: 'cta-messaging',
properties: {
provider: 'rabbitmq',
parameters: {
url: 'amqp://localhost?heartbeat=60',
},
},
}],
...
};
It declares a tool named "sample.messaging" using cta-messaging module with specified properties.
const config = {
...
bricks: [{
name: 'Receiver',
module: 'cta-io',
dependencies: {
messaging: 'sample.messaging',
},
properties: {
input: {
queue: 'input.queue',
},
},
publish: [{
topic: 'sample.topics',
data: [{}],
}],
}, {
name: 'Sender',
module: 'cta-io',
dependencies: {
messaging: 'sample.messaging',
},
properties: {},
subscribe: [{
topic: 'sample.topics',
data: [{}],
}],
}],
};
It declares two bricks named "Receiver" and "Sender" using cta-io module with dependencies.messaging named "sample.messaging".
- "Receiver" Brick using cta-io module
const config = {
...
bricks: [{
name: 'Receiver',
module: 'cta-io',
dependencies: {
messaging: 'sample.messaging',
},
properties: {
input: {
queue: 'input.queue',
},
},
publish: [{
topic: 'sample.topics',
data: [{}],
}],
},
...
],
};
This "Receiver" Brick subscribes "input.queue" queue via "sample.messaging" and publish a content on "sample.topics" topic.
- "Sender" Brick using cta-io module
const config = {
...
bricks: [
...
{
name: 'Sender',
module: 'cta-io',
dependencies: {
messaging: 'sample.messaging',
},
properties: {},
subscribe: [{
topic: 'sample.topics',
data: [{}],
}],
}],
};
This "Sender" Brick subscribes "sample.topics" topic and processes a content according to the received payload via "sample.messaging".
In configuration, cta-io uses properties to manipulate the content as input / output.
- properties.input
const config = {
...
bricks: [{
...
properties: {
input: {
queue: 'input.queue',
topic: 'input.topic',
},
},
...
}],
};
The properties.input has two fields, queue and topic. They define the name of queue/topic which any content will be consumed from as the input.
- properties.output
const config = {
...
bricks: [{
...
properties: {
output: {
queue: 'output.queue',
topic: 'output.topic',
},
},
...
}],
};
The properties.output has two fields, queue and topic. They define the name of queue/topic which any content will be published to as the output.
nature.type | nature.quality | payload | description |
---|---|---|---|
message | produce | { status: 'ok' } | produce message { status: 'ok' } on default output queue |
message | produce | { queue: 'sample', message: { status: 'ok' }} | produce message on custom queue: 'sample' |
message | consume | { status: 'ok' } | |
message | get | { status: 'ok' } | |
message | publish | { status: 'ok' } | publish message { status: 'ok' } on default exchange and default output topic |
message | publish | { exchange: 'sample.exchange', topic: 'sample.topic', message: { status: 'ok' }} | publish message { status: 'ok' } on custom exchange 'sample.exchange' and custom topic 'sample.topic' |
message | subscribe | { topic: 'sample.topic' } | subscribe to messages on custom topic 'sample.topic' |
message | acknowledge | { id: '123' } | acknowledge consumed message with id '123' |