From b38ecccb8ab9cd1e631f89c92f6b88e420b2a1b0 Mon Sep 17 00:00:00 2001 From: "francois.cellier" Date: Tue, 13 Feb 2018 13:06:51 +0100 Subject: Add the moon_pythonfunctest container to perform functionnal tests Change-Id: I2be863862ce7df408f759664b10af45416b3d712 --- moon_forming/Dockerfile | 4 +-- moon_forming/switch.sh | 19 -------------- moon_manager/tests/functional_pod/test_models.py | 5 ++-- moon_pythonfunctest/Dockerfile | 9 +++++++ moon_pythonfunctest/README.md | 8 ++++++ moon_pythonfunctest/run_func_test.sh | 15 +++++++++++ moon_pythonunittest/run_tests.sh | 6 ++--- tests/functional/run_tests_for_component.sh | 4 +-- tools/moon_kubernetes/conf/moon.conf | 2 +- .../templates/moon_forming_functest.yaml | 30 ---------------------- tools/moon_kubernetes/templates/moon_functest.yaml | 27 +++++++++++++++++++ 11 files changed, 69 insertions(+), 60 deletions(-) delete mode 100644 moon_forming/switch.sh create mode 100644 moon_pythonfunctest/Dockerfile create mode 100644 moon_pythonfunctest/README.md create mode 100755 moon_pythonfunctest/run_func_test.sh delete mode 100644 tools/moon_kubernetes/templates/moon_forming_functest.yaml create mode 100644 tools/moon_kubernetes/templates/moon_functest.yaml diff --git a/moon_forming/Dockerfile b/moon_forming/Dockerfile index 74616c89..ffae02c5 100644 --- a/moon_forming/Dockerfile +++ b/moon_forming/Dockerfile @@ -3,9 +3,7 @@ FROM python:3 WORKDIR /usr/src/app RUN pip install --no-cache-dir --upgrade requests pytest pyyaml python_moonutilities python_moondb python_moonclient -ENV COMMAND "config" - ADD . /root WORKDIR /root -CMD /bin/bash /root/switch.sh ${COMMAND} +CMD /bin/bash /root/config_moon.sh diff --git a/moon_forming/switch.sh b/moon_forming/switch.sh deleted file mode 100644 index adb1ebe9..00000000 --- a/moon_forming/switch.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -CMD=$1 - -echo "COMMAND IS ${CMD}" - -if [ "${CMD}" = "functest" ]; then - echo "FUNCTIONAL TESTS" - ls -l /data - ls -l /data/tests - sh /data/tests/functional_pod/run_functional_tests.sh -#elif [ $CMD == "unittest" ]; then -# sh /data/tests/functional_pod/run_functional_tests.sh -else - echo "CONFIGURATION" - bash config_moon.sh -fi - -echo "" \ No newline at end of file diff --git a/moon_manager/tests/functional_pod/test_models.py b/moon_manager/tests/functional_pod/test_models.py index dcda9f32..8b4ceef5 100644 --- a/moon_manager/tests/functional_pod/test_models.py +++ b/moon_manager/tests/functional_pod/test_models.py @@ -32,9 +32,10 @@ def delete_models(context, name): request = None for key, value in models['models'].items(): if value['name'] == name: - request = requests.delete("http://{}:{}/models/{}".format(key, + request = requests.delete("http://{}:{}/models/{}".format( context.get("hostname"), - context.get("port")), + context.get("port"), + key), timeout=3) break return request diff --git a/moon_pythonfunctest/Dockerfile b/moon_pythonfunctest/Dockerfile new file mode 100644 index 00000000..8ae093b8 --- /dev/null +++ b/moon_pythonfunctest/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3 + +WORKDIR /usr/src/app +RUN pip install --no-cache-dir --upgrade requests pytest pyyaml python_moonutilities python_moondb python_moonclient + +ADD . /root +WORKDIR /root + +CMD /bin/bash /root/run_func_test.sh diff --git a/moon_pythonfunctest/README.md b/moon_pythonfunctest/README.md new file mode 100644 index 00000000..e2a4d14b --- /dev/null +++ b/moon_pythonfunctest/README.md @@ -0,0 +1,8 @@ +# Python Functional Test Docker + +## Build +- `docker image build -t wukongsun/moon_python_func_test .` + +## Push to DockerHub +- `docker login --username=wukongsun` +- `docker image push wukongsun/moon_python_func_test` diff --git a/moon_pythonfunctest/run_func_test.sh b/moon_pythonfunctest/run_func_test.sh new file mode 100755 index 00000000..acd0e1e9 --- /dev/null +++ b/moon_pythonfunctest/run_func_test.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +echo "Running functional tests :" + +#ls -l /data +ls -l /data/tests + +if [ -f /data/tests/functional_pod/run_functional_tests.sh ]; +then + echo "running script..." + bash /data/tests/functional_pod/run_functional_tests.sh; +fi + +echo "" + diff --git a/moon_pythonunittest/run_tests.sh b/moon_pythonunittest/run_tests.sh index 6c586f87..8175d00b 100644 --- a/moon_pythonunittest/run_tests.sh +++ b/moon_pythonunittest/run_tests.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash cd /data -pip3 install -r tests/unit_python/requirements.txt --upgrade -pip3 install . +#pip3 install -r tests/python_unit/requirements.txt --upgrade +#pip3 install . if [ -f /data/tests/unit_python/run_tests.sh ]; then bash /data/tests/unit_python/run_tests.sh; fi -cd /data/tests/unit_python +cd /data/tests/python_python pytest . diff --git a/tests/functional/run_tests_for_component.sh b/tests/functional/run_tests_for_component.sh index fd9ab7fa..6c6a0330 100644 --- a/tests/functional/run_tests_for_component.sh +++ b/tests/functional/run_tests_for_component.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash CUR_PWD=$(pwd) -INPUT_FILE=../tools/moon_kubernetes/templates/moon_forming_functest.yaml -OUTPUT_FILE=tests/functional_pod/moon_forming_functest.yaml +INPUT_FILE=../tools/moon_kubernetes/templates/moon_functest.yaml +OUTPUT_FILE=tests/functional_pod/moon_functest.yaml echo current working directory: ${CUR_PWD} diff --git a/tools/moon_kubernetes/conf/moon.conf b/tools/moon_kubernetes/conf/moon.conf index 28ad7a8e..e242125b 100644 --- a/tools/moon_kubernetes/conf/moon.conf +++ b/tools/moon_kubernetes/conf/moon.conf @@ -67,7 +67,7 @@ logging: handlers: console: class : logging.StreamHandler - formatter: brief + formatter: custom level : INFO stream : ext://sys.stdout file: diff --git a/tools/moon_kubernetes/templates/moon_forming_functest.yaml b/tools/moon_kubernetes/templates/moon_forming_functest.yaml deleted file mode 100644 index 4cb2c3a0..00000000 --- a/tools/moon_kubernetes/templates/moon_forming_functest.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: functest - namespace: moon -spec: - template: - metadata: - name: functest - spec: - containers: - - name: functest - image: wukongsun/moon_forming:dev - env: - - name: COMMAND - value: "functest" - volumeMounts: - - name: config-volume - mountPath: /etc/moon - - name: tests-volume - mountPath: /data - volumes: - - name: config-volume - configMap: - name: moon-config - - name: tests-volume - hostPath: - path: "{{PATH}}" - restartPolicy: Never - #backoffLimit: 4 \ No newline at end of file diff --git a/tools/moon_kubernetes/templates/moon_functest.yaml b/tools/moon_kubernetes/templates/moon_functest.yaml new file mode 100644 index 00000000..d70ebb96 --- /dev/null +++ b/tools/moon_kubernetes/templates/moon_functest.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: functest + namespace: moon +spec: + template: + metadata: + name: functest + spec: + containers: + - name: functest + image: wukongsun/moon_python_func_test:latest + volumeMounts: + - name: config-volume + mountPath: /etc/moon + - name: tests-volume + mountPath: /data + volumes: + - name: config-volume + configMap: + name: moon-config + - name: tests-volume + hostPath: + path: "{{PATH}}" + restartPolicy: Never + #backoffLimit: 4 -- cgit 1.2.3-korg