Add scripts & docker-compose file for oru app and related components 79/6079/2
authorecaiyanlinux <martin.c.yan@est.tech>
Mon, 17 May 2021 08:40:15 +0000 (16:40 +0800)
committerecaiyanlinux <martin.c.yan@est.tech>
Mon, 17 May 2021 11:18:24 +0000 (19:18 +0800)
docker-compose file contains:
dmaap-mr
oru-app
sdnr-simulator
message-generator

Issue-ID: NONRTRIC-496
Change-Id: I3692e402d1ac9b846802ad2c6f67cef633742a57
Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech>
test/usecases/linkfailure/README.md
test/usecases/linkfailure/docker-compose/docker-compose.yaml [new file with mode: 0644]
test/usecases/linkfailure/docker-compose/start.sh [new file with mode: 0755]

index f9e0248..88d0b88 100644 (file)
@@ -46,13 +46,23 @@ using the command, with available params listed:
  `docker run --network [NETWORK NAME] --name message-generator -e MR-HOST=[HOST NAME OF MR] -e MR-PORT=[PORT OF MR] message-generator`.
 
 To build the image for the SDNR simulator, run the following command from the `simulators` folder:
-`docker build -f Dockerfile-sdnr-sim -t message-generator .`
+`docker build -f Dockerfile-sdnr-sim -t sdnr-simulator .`
 
 The SDNR simulator's container must be connected to the same network as the the other components are running in. Some of the
 parameters to the application can be provided with the `-e PARAM_NAME=PARAM_VALUE` notation. Start the container by
 using the command, with available params listed:
  `docker run --network [NETWORK NAME] --name sdnr-simulator -e MR-HOST=[HOST NAME OF MR] -e MR-PORT=[PORT OF MR] sdnr-simulator`.
 
+# Use docker-compose
+Go to the `docker-compose/` folder and run `bash start.sh`.
+
+This scripts will start up four components:
+dmaap-mr
+oru-app
+sdnr-simulator
+message-generator
+
+
 ## License
 
 Copyright (C) 2021 Nordix Foundation.
diff --git a/test/usecases/linkfailure/docker-compose/docker-compose.yaml b/test/usecases/linkfailure/docker-compose/docker-compose.yaml
new file mode 100644 (file)
index 0000000..5fa6094
--- /dev/null
@@ -0,0 +1,60 @@
+#  Copyright (C) 2021 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+version: '3.5'
+
+networks:
+  default:
+    driver: bridge
+    name: nonrtric-docker-net
+
+services:
+  message-generator:
+    image: message-generator
+    container_name: message-generator
+    networks:
+      default:
+        aliases:
+          - message-generator
+    environment:
+      - MR-HOST=http://dmaap-mr
+      - MR-PORT=3904
+
+  sdnr-simulator:
+    image: sdnr-simulator
+    container_name: sdnr-simulator
+    networks:
+      default:
+        aliases:
+          - sdnr-simulator
+    ports:
+      - 9990:9990
+    environment:
+      - MR-HOST=http://dmaap-mr
+      - MR-PORT=3904
+
+  oru-app:
+    image: oru-app
+    container_name: oru-app
+    networks:
+      default:
+        aliases:
+          - oru-app
+    environment:
+      - MR-HOST=http://dmaap-mr
+      - MR-PORT=3904
+      - SDNR-HOST=http://sdnr-simulator
+      - SDNR-PORT=9990
+      - VERBOSE=on
\ No newline at end of file
diff --git a/test/usecases/linkfailure/docker-compose/start.sh b/test/usecases/linkfailure/docker-compose/start.sh
new file mode 100755 (executable)
index 0000000..5dba4fe
--- /dev/null
@@ -0,0 +1,51 @@
+#  Copyright (C) 2021 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+docker stop $(docker ps -aq)
+docker system prune -f
+
+# build o-ru application image
+cd ${SHELL_FOLDER}/../app/
+docker build -t oru-app .
+
+# build simulator image of sdnr
+cd ${SHELL_FOLDER}/../simulators/
+docker build -f Dockerfile-sdnr-sim -t sdnr-simulator .
+
+# build message generator image
+docker build -f Dockerfile-message-generator -t message-generator .
+
+# start up dmaap message router
+cd ${SHELL_FOLDER}/../../../../docker-compose/
+docker-compose -f docker-compose.yaml -f mr/docker-compose.yml up -d
+
+# wait until mr up & running
+for i in {1..60}; do
+    res=$(curl -o /dev/null -sw %{http_code} http://localhost:3904/topics)
+    echo "$res"
+    expect="200"
+    if [ "$res" == "$expect" ]; then
+        echo -e "dmaap-mr is alive!\n"
+        break;
+    else
+        sleep $i
+    fi
+done
+
+# start up oru, message-generator and sdnr-simulator
+cd ${SHELL_FOLDER}
+docker-compose up -d
\ No newline at end of file