Loading src/osm_client/.gitlab-ci.yml +9 −8 Original line number Diff line number Diff line Loading @@ -74,24 +74,23 @@ unit_test osm_client: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker images --filter="dangling=true" --quiet | xargs -r docker rmi - > docker run --name $IMAGE_NAME -d -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" docker run --name $MOCK_IMAGE_NAME -d --network=teraflowbridge --env LOG_LEVEL=DEBUG --env FLASK_ENV=development --env OSM_ADDRESS=mock_osm_nbi $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG $CI_REGISTRY_IMAGE/$MOCK_IMAGE_NAME:$IMAGE_TAG - > docker run --name $MOCK_IMAGE_NAME -d docker run --name $IMAGE_NAME -d -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge --env LOG_LEVEL=DEBUG --env FLASK_ENV=development $CI_REGISTRY_IMAGE/$MOCK_IMAGE_NAME:$IMAGE_TAG - while ! docker logs $IMAGE_NAME 2>&1 | grep -q 'Configured Rules'; do sleep 1; done - sleep 5 # Give extra time to container to get ready --env OSM_ADDRESS=mock_osm_nbi $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG - while ! docker logs $IMAGE_NAME 2>&1 | grep -q 'Running...'; do sleep 1; done - docker ps -a - docker logs $IMAGE_NAME - docker logs $MOCK_IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report_unitary.xml" - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report_unitary.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: Loading @@ -109,6 +108,8 @@ unit_test osm_client: - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - manifests/${IMAGE_NAME}service.yaml - src/tests/tools/$MOCK_IMAGE_NAME/**/*.{py,in,yml} - src/tests/tools/$MOCK_IMAGE_NAME/Dockerfile - .gitlab-ci.yml artifacts: when: always Loading src/osm_client/Dockerfile +5 −3 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ FROM python:3.10.16-slim # Install dependencies RUN apt-get --yes --quiet --quiet update RUN apt-get --yes --quiet --quiet install wget g++ git build-essential cmake make git \ libpcre2-dev python3-dev python3-pip python3-cffi curl software-properties-common libmagic1 libmagic-dev && \ # Unneeded: build-essential cmake libpcre2-dev python3-dev python3-pip python3-cffi curl software-properties-common libmagic-dev RUN apt-get --yes --quiet --quiet update && \ apt-get --yes --quiet --quiet install wget g++ git make libmagic1 && \ rm -rf /var/lib/apt/lists/* # Set Python to show logs as they occur Loading Loading @@ -62,9 +62,11 @@ WORKDIR /var/teraflow/osm_client ENV OSM_CLIENT_VERSION=v16.0 RUN python3 -m pip install -r "https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=${OSM_CLIENT_VERSION}" RUN python3 -m pip install "git+https://osm.etsi.org/gerrit/osm/IM.git@${OSM_CLIENT_VERSION}#egg=osm-im" --upgrade #Clone OsmCLient code RUN git clone https://osm.etsi.org/gerrit/osm/osmclient RUN git -C osmclient checkout ${OSM_CLIENT_VERSION} # Install osmClient using pip RUN python3 -m pip install -r osmclient/requirements.txt RUN python3 -m pip install ./osmclient Loading src/osm_client/service/OsmClientServiceServicerImpl.py +4 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ import grpc, logging from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method from common.tools.grpc.Tools import grpc_message_to_json_string from common.proto.context_pb2 import (Empty) from common.proto.osm_client_pb2 import CreateRequest, CreateResponse, NsiListResponse, GetRequest, GetResponse, DeleteRequest, DeleteResponse from common.proto.osm_client_pb2 import ( CreateRequest, CreateResponse, NsiListResponse, GetRequest, GetResponse, DeleteRequest, DeleteResponse ) from common.proto.osm_client_pb2_grpc import OsmServiceServicer from osmclient import client from osmclient.common.exceptions import ClientException Loading src/osm_client/service/__main__.py +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ def main(): grpc_service = OsmClientService() grpc_service.start() LOGGER.debug('Configured Rules:') LOGGER.info('Running...') # Wait for Ctrl+C or termination signal while not terminate.wait(timeout=1.0): pass Loading Loading
src/osm_client/.gitlab-ci.yml +9 −8 Original line number Diff line number Diff line Loading @@ -74,24 +74,23 @@ unit_test osm_client: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker images --filter="dangling=true" --quiet | xargs -r docker rmi - > docker run --name $IMAGE_NAME -d -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" docker run --name $MOCK_IMAGE_NAME -d --network=teraflowbridge --env LOG_LEVEL=DEBUG --env FLASK_ENV=development --env OSM_ADDRESS=mock_osm_nbi $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG $CI_REGISTRY_IMAGE/$MOCK_IMAGE_NAME:$IMAGE_TAG - > docker run --name $MOCK_IMAGE_NAME -d docker run --name $IMAGE_NAME -d -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge --env LOG_LEVEL=DEBUG --env FLASK_ENV=development $CI_REGISTRY_IMAGE/$MOCK_IMAGE_NAME:$IMAGE_TAG - while ! docker logs $IMAGE_NAME 2>&1 | grep -q 'Configured Rules'; do sleep 1; done - sleep 5 # Give extra time to container to get ready --env OSM_ADDRESS=mock_osm_nbi $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG - while ! docker logs $IMAGE_NAME 2>&1 | grep -q 'Running...'; do sleep 1; done - docker ps -a - docker logs $IMAGE_NAME - docker logs $MOCK_IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report_unitary.xml" - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report_unitary.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: Loading @@ -109,6 +108,8 @@ unit_test osm_client: - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - manifests/${IMAGE_NAME}service.yaml - src/tests/tools/$MOCK_IMAGE_NAME/**/*.{py,in,yml} - src/tests/tools/$MOCK_IMAGE_NAME/Dockerfile - .gitlab-ci.yml artifacts: when: always Loading
src/osm_client/Dockerfile +5 −3 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ FROM python:3.10.16-slim # Install dependencies RUN apt-get --yes --quiet --quiet update RUN apt-get --yes --quiet --quiet install wget g++ git build-essential cmake make git \ libpcre2-dev python3-dev python3-pip python3-cffi curl software-properties-common libmagic1 libmagic-dev && \ # Unneeded: build-essential cmake libpcre2-dev python3-dev python3-pip python3-cffi curl software-properties-common libmagic-dev RUN apt-get --yes --quiet --quiet update && \ apt-get --yes --quiet --quiet install wget g++ git make libmagic1 && \ rm -rf /var/lib/apt/lists/* # Set Python to show logs as they occur Loading Loading @@ -62,9 +62,11 @@ WORKDIR /var/teraflow/osm_client ENV OSM_CLIENT_VERSION=v16.0 RUN python3 -m pip install -r "https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=${OSM_CLIENT_VERSION}" RUN python3 -m pip install "git+https://osm.etsi.org/gerrit/osm/IM.git@${OSM_CLIENT_VERSION}#egg=osm-im" --upgrade #Clone OsmCLient code RUN git clone https://osm.etsi.org/gerrit/osm/osmclient RUN git -C osmclient checkout ${OSM_CLIENT_VERSION} # Install osmClient using pip RUN python3 -m pip install -r osmclient/requirements.txt RUN python3 -m pip install ./osmclient Loading
src/osm_client/service/OsmClientServiceServicerImpl.py +4 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ import grpc, logging from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method from common.tools.grpc.Tools import grpc_message_to_json_string from common.proto.context_pb2 import (Empty) from common.proto.osm_client_pb2 import CreateRequest, CreateResponse, NsiListResponse, GetRequest, GetResponse, DeleteRequest, DeleteResponse from common.proto.osm_client_pb2 import ( CreateRequest, CreateResponse, NsiListResponse, GetRequest, GetResponse, DeleteRequest, DeleteResponse ) from common.proto.osm_client_pb2_grpc import OsmServiceServicer from osmclient import client from osmclient.common.exceptions import ClientException Loading
src/osm_client/service/__main__.py +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ def main(): grpc_service = OsmClientService() grpc_service.start() LOGGER.debug('Configured Rules:') LOGGER.info('Running...') # Wait for Ctrl+C or termination signal while not terminate.wait(timeout=1.0): pass Loading