Commit 84f998e9 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/compute-component' into 'develop'

First functional version of Compute component

See merge request teraflow-h2020/controller!53
parents cb66db4b d8b14fda
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ include:
  - local: '/manifests/.gitlab-ci.yml'
  - local: '/src/monitoring/.gitlab-ci.yml'
  #- local: '/src/centralizedattackdetector/.gitlab-ci.yml'
  - local: '/src/compute/.gitlab-ci.yml'
  - local: '/src/context/.gitlab-ci.yml'
  - local: '/src/device/.gitlab-ci.yml'
  - local: '/src/service/.gitlab-ci.yml'
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ spec:
        image: registry.gitlab.com/teraflow-h2020/controller/compute:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        - containerPort: 9090
        env:
        - name: LOG_LEVEL
@@ -44,7 +45,12 @@ spec:
  selector:
    app: computeservice
  ports:
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
  - name: grpc
    protocol: TCP
    port: 9090
    targetPort: 9090
---
@@ -59,6 +65,10 @@ spec:
  selector:
    app: computeservice
  ports:
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
  - name: grpc
    protocol: TCP
    port: 9090
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ spec:
        env:
        - name: DB_BACKEND
          value: "redis"
        - name: MB_BACKEND
          value: "redis"
        - name: REDIS_DATABASE_ID
          value: "0"
        - name: LOG_LEVEL
@@ -64,9 +66,11 @@ spec:
    app: contextservice
  ports:
  - name: grpc
    protocol: TCP
    port: 1010
    targetPort: 1010
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
---
+6 −1
Original line number Diff line number Diff line
import re
from typing import Any, Container, List, Optional, Pattern, Set, Sized, Tuple, Union
from typing import Any, Container, Dict, List, Optional, Pattern, Set, Sized, Tuple, Union

def chk_none(name : str, value : Any, reason=None) -> Any:
    if value is None: return value
@@ -11,6 +11,11 @@ def chk_not_none(name : str, value : Any, reason=None) -> Any:
    if reason is None: reason = 'must not be None.'
    raise ValueError('{}({}) {}'.format(str(name), str(value), str(reason)))

def chk_attribute(name : str, container : Dict, container_name : str, **kwargs):
    if name in container: return container[name]
    if 'default' in kwargs: return kwargs['default']
    raise AttributeError('Missing object({:s}) in container({:s})'.format(str(name), str(container_name)))

def chk_type(name : str, value : Any, type_or_types : Union[type, Set[type]] = set()) -> Any:
    if isinstance(value, type_or_types): return value
    msg = '{}({}) is of a wrong type({}). Accepted type_or_types({}).'
+4 −3
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ build compute:
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/
    - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
#  after_script:
#    - docker rmi $(docker images --quiet --filter=dangling=true)
  after_script:
    - docker images --filter="dangling=true" --quiet | xargs -r docker rmi
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
@@ -36,9 +36,10 @@ unit test compute:
    - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker run --name $IMAGE_NAME -d -p 9090:9090 --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - docker run --name $IMAGE_NAME -d -p 9090:9090 --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - sleep 5
    - docker ps -a
    - docker logs $IMAGE_NAME
    - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py"
  after_script:
    - docker rm -f $IMAGE_NAME
Loading