Simulator integration for CSIT of generalized DfC
[integration.git] / test / mocks / datafilecollector-testharness / simulator-group / consul_config.sh
1 #!/bin/bash
2 bash -x 
3
4 # Script to configure consul with json configuration files with 'localhost' urls. This
5 # is needed when running the simulator as as a stand-alone app or via a dfc container in 'host' network mode. 
6 # Assuming the input json files hostnames for MR and DR simulators are given as 'mrsim'/'drsim'
7 # See available consul files in the consul dir
8 # The script stores a json config for 'dfc_app'<dfc-instance-id>' if arg 'app' is given.
9 # And for 'dfc_app'<dfc-instance-id>':dmaap' if arg 'dmaap' is given.
10 # Instance id shall be and integer in the range 0..5
11
12 . ../common/test_env.sh
13
14 if [ $# != 3 ]; then
15         echo "Script needs three args, app|dmaap <dfc-instance-id> <json-file-path>"
16         exit 1
17 fi
18
19 if [ $2 -lt 0 ] || [ $2 -gt $DFC_MAX_IDX ]; then
20         __print_err "dfc-instance-id should be 0.."$DFC_MAX_IDX
21         exit 1
22 fi
23 if ! [ -f $3 ]; then
24         __print_err "json file does not extis: "$3
25         exit 1
26 fi
27
28 echo "Configuring consul for " $appname " from " $3
29 curl -s http://127.0.0.1:${CONSUL_PORT}/v1/kv/${appname}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$3
30
31 echo "Reading back from consul:"
32 curl "http://127.0.0.1:${CONSUL_PORT}/v1/kv/${appname}?dc=dc1&raw=0"
33
34 echo "done"