diff --git a/near-rt-ric-simulator/Dockerfile b/near-rt-ric-simulator/Dockerfile index 4eaf9ed161ca179253b14338de69b412336f98ea..05a75fd1e3dfbcd95258f5f4b24dd11be62071de 100644 --- a/near-rt-ric-simulator/Dockerfile +++ b/near-rt-ric-simulator/Dockerfile @@ -21,8 +21,16 @@ WORKDIR /usr/src/app RUN pip install connexion[swagger-ui] -COPY src src +#install nginx +RUN apt-get update +RUN apt-get install -y nginx=1.14.* + +#install curl +RUN apt-get install -y curl +COPY src src COPY api api +COPY nginx.conf nginx.conf +RUN chmod +x src/start.sh CMD src/start.sh ${A1_VERSION} diff --git a/near-rt-ric-simulator/certificate/pass b/near-rt-ric-simulator/certificate/pass new file mode 100644 index 0000000000000000000000000000000000000000..30d74d258442c7c65512eafab474568dd706c430 --- /dev/null +++ b/near-rt-ric-simulator/certificate/pass @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/near-rt-ric-simulator/nginx.conf b/near-rt-ric-simulator/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..5ba9dbe34481b2863f1215cd9c9e0a7623c8ffc4 --- /dev/null +++ b/near-rt-ric-simulator/nginx.conf @@ -0,0 +1,100 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { # simple reverse-proxy + listen 8085; + listen [::]:8085; + listen 8185 ssl; + listen [::]:8185 ssl; + server_name localhost; + ssl_certificate /usr/src/app/cert/cert.crt; + ssl_certificate_key /usr/src/app/cert/key.crt; + ssl_password_file /usr/src/app/cert/pass; + + # serve dynamic requests + location / { + proxy_pass http://localhost:2222; + } + } + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} + + +#mail { +# # See sample authentication script at: +# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript +# +# # auth_http localhost/auth.php; +# # pop3_capabilities "TOP" "USER"; +# # imap_capabilities "IMAP4rev1" "UIDPLUS"; +# +# server { +# listen localhost:110; +# protocol pop3; +# proxy on; +# } +# +# server { +# listen localhost:143; +# protocol imap; +# proxy on; +# } +#} \ No newline at end of file diff --git a/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py b/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py index e979bd850152a63b7a4a498109e5603e447b8740..ddba11e3c08ffb63b1dda151961c73d0adec638a 100644 --- a/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py +++ b/near-rt-ric-simulator/src/1.1.x-alpha.2/main.py @@ -130,18 +130,11 @@ def getCounter(countername): return "Counter name: "+countername+" not found.",404 -port_number = 8085 +port_number = 2222 if len(sys.argv) >= 2: if isinstance(sys.argv[1], int): port_number = sys.argv[1] -port_number_secure=8185 - app.add_api('a1-openapi.yaml') -context=get_security_context() -if (context == None): - print("Start on non-secure port: "+str(port_number)) - app.run(port=port_number, host="::") -else: - print("Start on secure port: "+str(port_number_secure)) - app.run(port=port_number_secure, host="::", ssl_context=context) \ No newline at end of file + +app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/main.py b/near-rt-ric-simulator/src/OSC_2.1.0/main.py index 2614ada5e7d1fb21b09a5f639ae0fabf71f9f320..dc25626847cbf811cbdba7b770e3399778e6c47e 100644 --- a/near-rt-ric-simulator/src/OSC_2.1.0/main.py +++ b/near-rt-ric-simulator/src/OSC_2.1.0/main.py @@ -26,11 +26,28 @@ from flask import Flask, escape, request, Response from jsonschema import validate from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings, hosts_set from maincommon import * +from time import sleep check_apipath() app = connexion.FlaskApp(__name__, specification_dir=apipath) +t=[] ##varialbe for test purpose + +#long poll +@app.route('/long', methods=['GET']) +def longpoll(): + global t + sleep(10) + t.append(1) + return Response(str(t), 200, mimetype='text/plain') + +#short poll +@app.route('/short', methods=['GET']) +def shortpoll(): + global t + t.append(2) + return Response(str(t), 200, mimetype='text/plain') #Check alive function @app.route('/', methods=['GET']) @@ -199,18 +216,11 @@ def getCounter(countername): else: return Response("Counter name: "+countername+" not found.",404, mimetype='text/plain') -port_number = 8085 +port_number = 2222 if len(sys.argv) >= 2: if isinstance(sys.argv[1], int): port_number = sys.argv[1] -port_number_secure=8185 - app.add_api('openapi.yaml') -context=get_security_context() -if (context == None): - print("Start on non-secure port: "+str(port_number)) - app.run(port=port_number, host="::") -else: - print("Start on secure port: "+str(port_number_secure)) - app.run(port=port_number_secure, host="::", ssl_context=context) \ No newline at end of file + +app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_1.1.3/main.py b/near-rt-ric-simulator/src/STD_1.1.3/main.py index c46d9501b6388959a05fb47cf0b910400190db65..ce0854ec0574ea82f6e91b58beb48449023b84de 100644 --- a/near-rt-ric-simulator/src/STD_1.1.3/main.py +++ b/near-rt-ric-simulator/src/STD_1.1.3/main.py @@ -164,18 +164,11 @@ def getCounter(countername): else: return Response("Counter name: "+countername+" not found.",404, mimetype='text/plain') -port_number = 8085 +port_number = 2222 if len(sys.argv) >= 2: if isinstance(sys.argv[1], int): port_number = sys.argv[1] -port_number_secure=8185 - app.add_api('STD_A1.yaml') -context=get_security_context() -if (context == None): - print("Start on non-secure port: "+str(port_number)) - app.run(port=port_number, host="::") -else: - print("Start on secure port: "+str(port_number_secure)) - app.run(port=port_number_secure, host="::", ssl_context=context) + +app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/common/maincommon.py b/near-rt-ric-simulator/src/common/maincommon.py index 79cda3b78bf6e039e19e7c15a7277cad59712008..ee52d55412e08202d46f5ed721a9b4024608e8cd 100644 --- a/near-rt-ric-simulator/src/common/maincommon.py +++ b/near-rt-ric-simulator/src/common/maincommon.py @@ -40,6 +40,7 @@ def get_supported_interfaces_response(): arr = os.listdir("../") del arr[arr.index('common')] # Remove the common lib del arr[arr.index('start.sh')] # Remove the start script + arr.sort() return Response("Current interface: " + str(pp[len(pp)-1]) + " All supported A1 interface yamls in this container: "+str(arr), 200, mimetype='text/plain') # Remote host lookup and store host name in a set diff --git a/near-rt-ric-simulator/src/start.sh b/near-rt-ric-simulator/src/start.sh index a424b5abe5b3bd31bc93d46af97eb7a927494f00..73491bd952d1cf5a6ce234fc758547163c5eba97 100755 --- a/near-rt-ric-simulator/src/start.sh +++ b/near-rt-ric-simulator/src/start.sh @@ -37,5 +37,9 @@ echo "PYTHONPATH set to: "$PYTHONPATH cd $1 +#start nginx +nginx -c /usr/src/app/nginx.conf + +#start near-rt-ric-simulator echo "Path to main.py: "$PWD python -u main.py diff --git a/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh b/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh index 413ea89bb1b1cd95d262b91cba2f08bf47abe2b4..4cabff3a00e70fa96f149f5afd44801daff7dc3b 100755 --- a/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh +++ b/near-rt-ric-simulator/test/1.1.x-alpha.2/build_and_start.sh @@ -18,16 +18,6 @@ # # Script to build and start the container -# Args: nonsecure|secure - -if [ $# -ne 1 ]; then - echo "Usage: ./build_and_start.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./build_and_start.sh nonsecure|secure" - exit 1 -fi echo "Building image" cd ../../ @@ -36,12 +26,7 @@ cd ../../ docker build -t a1test . echo "Starting $1 mode" -if [ $1 == "nonsecure" ]; then - #Run the container in interactive mode, unsecure port - docker run -it -p 8085:8085 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 a1test -else - #Run the container in interactive mode, secure port. - docker run -it -p 8185:8185 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test -fi +#Run the container in interactive mode, unsecure port 8085, secure port 8185. +docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" a1test diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh index 8d205f0992737e4ac800406dbc8f9e4d79f099c8..f77e3476a38c9b997a8cd06193ccf2beeb6e4f83 100755 --- a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh +++ b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh @@ -47,7 +47,7 @@ RESULT="OK" do_curl GET / 200 echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'STD_1.1.3', 'OSC_2.1.0']" +RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'OSC_2.1.0', 'STD_1.1.3']" do_curl GET /container_interfaces 200 echo "=== Reset simulator instances ===" @@ -60,7 +60,7 @@ do_curl POST /deleteall 200 echo "=== API: Healthcheck ===" RESULT="" -do_curl get /a1-p/healthcheck 200 +do_curl GET /a1-p/healthcheck 200 echo "=== API: Get policy types, shall be empty array ==" RESULT="json:[]" diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh b/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh index 89907d6093ab1e6f279e65af39fa74dcfdc04d06..9537d3064f31aa6733675637c42a2481a740a4c6 100755 --- a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh +++ b/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh @@ -18,16 +18,6 @@ # # Script to build and start the container -# Args: nonsecure|secure - -if [ $# -ne 1 ]; then - echo "Usage: ./build_and_start.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./build_and_start.sh nonsecure|secure" - exit 1 -fi echo "Building image" cd ../../ @@ -36,11 +26,6 @@ cd ../../ docker build -t a1test . echo "Starting $1 mode" -if [ $1 == "nonsecure" ]; then - #Run the container in interactive mode, unsecure port - docker run -it -p 8085:8085 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 a1test -else - #Run the container in interactive mode, secure port. - docker run -it -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test -fi +#Run the container in interactive mode, unsecure port 8085, secure port 8185. +docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" a1test diff --git a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh index 7dbe131dc31f72bfa5b9a2990935e8b155f011a5..2b34cf3c7772bda4af5308f09b8452c347ca11d0 100755 --- a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh +++ b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh @@ -48,7 +48,7 @@ RESULT="OK" do_curl GET / 200 echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'STD_1.1.3', 'OSC_2.1.0']" +RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'OSC_2.1.0', 'STD_1.1.3']" do_curl GET /container_interfaces 200 echo "=== Reset simulator instances ===" diff --git a/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh b/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh index 1dcacc4b6c06e51eaf8c480aa6b730d0f9594c83..0d48fbf361957f2f03dc98998622169a5dc5f33a 100755 --- a/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh +++ b/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh @@ -18,16 +18,6 @@ # # Script to build and start the container -# Args: nonsecure|secure - -if [ $# -ne 1 ]; then - echo "Usage: ./build_and_start.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./build_and_start.sh nonsecure|secure" - exit 1 -fi echo "Building image" cd ../../ @@ -35,11 +25,6 @@ cd ../../ #Build the image docker build -t a1test . -echo "Starting $1 mode" -if [ $1 == "nonsecure" ]; then - #Run the container in interactive mode, unsecure port - docker run -it -p 8085:8085 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 a1test -else - #Run the container in interactive mode, secure port. - docker run -it -p 8185:8185 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test -fi \ No newline at end of file +echo "Starting ric-sim" +#Run the container in interactive mode, unsecure port 8085, secure port 8185 +docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" a1test \ No newline at end of file