Auto test created for policy agent, cbs, consul
-Fix PA dockerfile using java command of adoptopenjdk
-Add initial test for autotest
-dockerize the process of PA reading config from consul/cbs
Issue-ID: NONRTRIC-79
Change-Id: I185f7459fbb59c2be1507b33e44f7d539ab4eeff
Signed-off-by: YongchaoWu <yongchao.wu@est.tech>
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/config.json b/near-rt-ric-simulator/simulator-group/consul_cbs/config.json
new file mode 100644
index 0000000..f75b2c5
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/consul_cbs/config.json
@@ -0,0 +1,13 @@
+ {
+ "//description": "Application configuration",
+ "ric": [
+ {
+ "name": "ric1",
+ "baseUrl": "http://localhost:8080/",
+ "managedElementIds": [
+ "kista_1",
+ "kista_2"
+ ]
+ }
+ ]
+ }
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_config.hcl b/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_config.hcl
new file mode 100644
index 0000000..9a9c0c4
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_config.hcl
@@ -0,0 +1,13 @@
+#server = true
+#bootstrap = true
+#client_addr = "0.0.0.0"
+
+service {
+ # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
+ # should be passed to policy agent app with this value
+ Name = "config-binding-service"
+ # Host name where CBS is running
+ Address = "config-binding-service"
+ # Port number where CBS is running
+ Port = 10000
+}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl b/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl
new file mode 100644
index 0000000..f6f3dac
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/consul_cbs/consul/cbs_localhost_config.hcl
@@ -0,0 +1,11 @@
+service {
+ # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
+ # should be passed to policy agent app with this value
+ # This is only to be used when contacting cbs via local host
+ # (typicall when policy agent is executed as an application without a container)
+ Name = "config-binding-service-localhost"
+ # Host name where CBS is running
+ Address = "localhost"
+ # Port number where CBS is running
+ Port = 10000
+}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose-template.yml b/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose-template.yml
new file mode 100644
index 0000000..1dcdb79
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose-template.yml
@@ -0,0 +1,30 @@
+version: '3'
+
+networks:
+ nonrtric-docker-net:
+ external:
+ name: nonrtric-docker-net
+
+services:
+
+ consul-server:
+ networks:
+ - nonrtric-docker-net
+ container_name: polman_consul
+ image: docker.io/consul:1.4.4
+ ports:
+ - "8500:8500"
+ volumes:
+ - ./consul/:/consul/config
+
+ config-binding-service:
+ networks:
+ - nonrtric-docker-net
+ container_name: polman_cbs
+ image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:2.3.0
+ ports:
+ - "10000:10000"
+ environment:
+ - CONSUL_HOST=consul-server
+ depends_on:
+ - consul-server
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose.yml b/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose.yml
new file mode 100644
index 0000000..2464b0e
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/consul_cbs/docker-compose.yml
@@ -0,0 +1,27 @@
+networks:
+ nonrtric-docker-net:
+ external:
+ name: nonrtric-docker-net
+services:
+ config-binding-service:
+ container_name: polman_cbs
+ depends_on:
+ - consul-server
+ environment:
+ CONSUL_HOST: consul-server
+ image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:2.3.0
+ networks:
+ nonrtric-docker-net: null
+ ports:
+ - 10000:10000/tcp
+ consul-server:
+ container_name: polman_consul
+ image: docker.io/consul:1.4.4
+ networks:
+ nonrtric-docker-net: null
+ ports:
+ - 8500:8500/tcp
+ volumes:
+ - /Users/yonwu/ORAN/nonrtric/near-rt-ric-simulator/simulator-group/consul_cbs/consul:/consul/config:rw
+version: '3.0'
+
diff --git a/near-rt-ric-simulator/simulator-group/consul_cbs/start.sh b/near-rt-ric-simulator/simulator-group/consul_cbs/start.sh
new file mode 100755
index 0000000..ed4f9e6
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/consul_cbs/start.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+DOCKER_SIM_NWNAME="nonrtric-docker-net"
+echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
+docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
+
+docker-compose -f docker-compose-template.yml config > docker-compose.yml
+
+docker-compose up -d
+
+CONSUL_PORT=8500
+
+APP="policy-agent"
+JSON_FILE="config.json"
+
+curl -s -v http://127.0.0.1:${CONSUL_PORT}/v1/kv/${APP}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$JSON_FILE
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/simulators-start.sh b/near-rt-ric-simulator/simulator-group/simulators-start.sh
new file mode 100755
index 0000000..7f83397
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/simulators-start.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+DOCKER_SIM_NWNAME="nonrtric-docker-net"
+echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
+docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
+
+docker-compose -f consul_cbs/docker-compose-template.yml config > docker-compose.yml
+
+docker-compose up -d
\ No newline at end of file