Merge "Two minor bugfies"
authorHenrik Andersson <henrik.b.andersson@est.tech>
Tue, 19 May 2020 10:45:36 +0000 (10:45 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Tue, 19 May 2020 10:45:36 +0000 (10:45 +0000)
test/common/testcase_common.sh
test/simulator-group/ric/cert/generate_cert_and_key.sh [new file with mode: 0755]
test/simulator-group/ric/cert/pass [new file with mode: 0644]
test/simulator-group/ric/docker-compose.yml

index 28c65d2..57344fb 100755 (executable)
@@ -63,7 +63,7 @@ G3_COUNT=0
 export RIC_SIM_HTTPX="http"
 export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
 export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
-export RIC_SIM_CERT_MOUNT_DIR="./fakedir"  #Fake dir so that the sim container does not find any cert
+export RIC_SIM_CERT_MOUNT_DIR="./cert"
 
 export MR_HTTPX="http"
 export MR_PORT=$MR_INTERNAL_PORT
@@ -715,10 +715,8 @@ __print_err() {
 # (Not for test scripts)
 __find_sim_port() {
     name=$1" " #Space appended to prevent matching 10 if 1 is desired....
-    cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'"
-       cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | cut -f 3 -d ',' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'"
-
-       res=$(eval $cmdstr)
+    cmdstr="docker inspect --format='{{(index (index .NetworkSettings.Ports \"$RIC_SIM_PORT/tcp\") 0).HostPort}}' ${name}"
+    res=$(eval $cmdstr)
        if [[ "$res" =~ ^[0-9]+$ ]]; then
                echo $res
        else
@@ -1079,7 +1077,6 @@ use_simulator_http() {
        export RIC_SIM_HTTPX="http"
        export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
        export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
-       export RIC_SIM_CERT_MOUNT_DIR="./fakedir"  #Fake dir so that the sim container does not find any cert
        echo ""
 }
 
@@ -1088,7 +1085,6 @@ use_simulator_https() {
        export RIC_SIM_HTTPX="https"
        export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
        export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT
-       export RIC_SIM_CERT_MOUNT_DIR="./cert"
        echo ""
 }
 
diff --git a/test/simulator-group/ric/cert/generate_cert_and_key.sh b/test/simulator-group/ric/cert/generate_cert_and_key.sh
new file mode 100755 (executable)
index 0000000..0f79bbf
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 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=================================================
+#
+
+# This will generate a self-signed certificate with password 'test'
+openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999
diff --git a/test/simulator-group/ric/cert/pass b/test/simulator-group/ric/cert/pass
new file mode 100644 (file)
index 0000000..30d74d2
--- /dev/null
@@ -0,0 +1 @@
+test
\ No newline at end of file
index fd8fc00..701a7f5 100644 (file)
@@ -29,7 +29,8 @@ services:
     networks:
       - default
     ports:
-      - ${RIC_SIM_PORT}/tcp
+      - ${RIC_SIM_INTERNAL_PORT}/tcp
+      - ${RIC_SIM_INTERNAL_SECURE_PORT}/tcp
     environment:
       - A1_VERSION=${G1_A1_VERSION}
       - REMOTE_HOSTS_LOGGING=1
@@ -40,7 +41,8 @@ services:
     networks:
       - default
     ports:
-      - ${RIC_SIM_PORT}/tcp
+      - ${RIC_SIM_INTERNAL_PORT}/tcp
+      - ${RIC_SIM_INTERNAL_SECURE_PORT}/tcp
     environment:
       - A1_VERSION=${G2_A1_VERSION}
       - REMOTE_HOSTS_LOGGING=1
@@ -51,7 +53,8 @@ services:
     networks:
       - default
     ports:
-      - ${RIC_SIM_PORT}/tcp
+      - ${RIC_SIM_INTERNAL_PORT}/tcp
+      - ${RIC_SIM_INTERNAL_SECURE_PORT}/tcp
     environment:
       - A1_VERSION=${G3_A1_VERSION}
       - REMOTE_HOSTS_LOGGING=1