Skip to content

Commit

Permalink
Merge pull request #163 from milanlenco/doc-apis2
Browse files Browse the repository at this point in the history
ODPM 568: Automatic testing of simple-agent.
  • Loading branch information
jozef-slezak committed Sep 22, 2017
2 parents de800fa + 364aff9 commit d4a56eb
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 8 deletions.
6 changes: 5 additions & 1 deletion examples/datasync-plugin/Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Datasync example

To start the examples you have to have ETCD running first.
### Requirements

To start the example you have to have ETCD running first.
if you don't have it installed locally you can use the following docker
image.
```
Expand All @@ -12,6 +14,8 @@ sudo docker run -p 2379:2379 --name etcd --rm \

It will bring up ETCD listening on port 2379 for client communication.

### Usage

In the example, the location of the ETCD configuration file is defined
with the `-etcdv3-config` argument or through the `ETCDV3_CONFIG`
environment variable.
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-lib/asyncproducer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ an asynchronous Kafka producer.

### Requirements

To start the examples you have to have Kafka broker running first.
To start the example you have to have Kafka broker running first.
if you don't have it installed locally you can use the following docker
image.
```
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-lib/consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ the received messages to the stdout.

### Requirements

To start the examples you have to have Kafka broker running first.
To start the example you have to have Kafka broker running first.
if you don't have it installed locally you can use the following docker
image.
```
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-lib/mux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ the minimal number of connections needed.

### Requirements

To start the examples you have to have Kafka broker running first.
To start the example you have to have Kafka broker running first.
if you don't have it installed locally you can use the following docker
image.
```
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-lib/syncproducer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ a synchronous Kafka producer.

### Requirements

To start the examples you have to have Kafka broker running first.
To start the example you have to have Kafka broker running first.
if you don't have it installed locally you can use the following docker
image.
```
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-plugin/hash-partitioner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ automatic (hash-based) partitioning.

### Requirements

To start the examples you have to have Kafka broker running first.
To start the example you have to have Kafka broker running first.
if you don't have it installed locally you can use the following docker
image.
```
Expand Down
13 changes: 12 additions & 1 deletion examples/simple-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
This application demonstrates how easily a set of CN-infra based plugins
can be turned into an application.

### Usage

To run the example, simply type:
```
go run agent.go
go run agent.go [-kafka-config <config-filepath>] [-etcdv3-config <config-filepath>] \
[-cassandra-config <config-filepath>] [-redis-config <config-filepath>]
```

All four data sources (kafka, etcd, redis, cassandra) are optional.
If a particular config file path is left unspecified, the application
will first try to look for the default configuration filename
in the current working directory before skipping the initialization
of the associated plugin.
Default configuration file names for data sources can be found
[here](../../flavors/connectors/connectors_util.go).
3 changes: 3 additions & 0 deletions examples/simple-agent/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Example simple-agent shows how easily a set of CN-infra based plugins
// can be turned into an application.
package main
39 changes: 38 additions & 1 deletion scripts/test_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ PREV_IFS="$IFS"
# arguments
# 1-st command to run
# 2-nd array of expected strings in the command output
# 3-rd argument is an optional command runtime limit
function testOutput {
IFS="${PREV_IFS}"

#run the command
$1 > ${TMP_FILE} 2>&1
if [ $# -ge 3 ]; then
$1 > ${TMP_FILE} 2>&1 &
CMD_PID=$!
sleep $3
kill $CMD_PID
else
$1 > ${TMP_FILE} 2>&1
fi

IFS="
"
Expand Down Expand Up @@ -247,6 +255,35 @@ Stopping agent...

testOutput examples/logs-plugin/logs-plugin "${expected}"

#### Simple-agent ########################################################

expected=("etcd config not found - skip loading this plugin
kafka config not found - skip loading this plugin
redis config not found - skip loading this plugin
cassandra client config not found - skip loading this plugin
All plugins initialized successfully
")

testOutput examples/simple-agent/simple-agent "${expected}" 5

#### Simple-agent with Kafka and ETCD ####################################

startEtcd
startKafka

expected=("Plugin etcdv3: status check probe registered
Plugin kafka: status check probe registered
redis config not found - skip loading this plugin
cassandra client config not found - skip loading this plugin
All plugins initialized successfully
")

cmd="examples/simple-agent/simple-agent --etcdv3-config=examples/datasync-plugin/etcd.conf --kafka-config examples/kafka-plugin/hash-partitioner/kafka.conf"
testOutput "${cmd}" "${expected}" 5

stopEtcd
stopKafka

##########################################################################

exit ${exitCode}

0 comments on commit d4a56eb

Please sign in to comment.