Commit ee19f062 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Forecaster component:

- Intermediate backup (not functional)
parent 70a40996
Loading
Loading
Loading
Loading
+35 −11
Original line number Diff line number Diff line
@@ -18,11 +18,21 @@ package forecaster;
import "context.proto";

service ForecasterService {
  rpc GetForecastOfTopology (context.TopologyId) returns (Forecast) {}
  rpc GetForecastOfLink(context.LinkId) returns (Forecast) {}
  rpc CheckService (context.ServiceId) returns (ForecastPrediction) {}
  rpc ComputeTopologyForecast(ForecastTopology) returns (ListLinkCapacity) {}
  rpc ComputeLinkForecast    (context.LinkId    ) returns (LinkCapacity    ) {}
}

message ForecastRequest {
  oneof uuid {
    context.TopologyId topology_id = 1;
    context.LinkId link_id = 2;
  }

  context.TopogyId topology_id             = 1;
  float            forecast_window_seconds = 2;
}


message SingleForecast {
  context.Timestamp timestamp= 1;
  double value = 2;    
@@ -40,6 +50,20 @@ enum AvailabilityPredictionEnum {
  FORECASTED_AVAILABILITY = 0;
  FORECASTED_UNAVAILABILITY = 1;
}

message ForecastPrediction {
  AvailabilityPredictionEnum prediction = 1;
}



message LinkCapacity {
  context.LinkId link_id                  = 1;
  float          total_capacity_gbps      = 2;
  float          current_capacity_gbps    = 3;
  float          forecasted_capacity_gbps = 4;
}

message ListLinkCapacity {
  repeated LinkCapacity forecasted_link_capacities = 1;
}

src/forecaster/.gitkeep

deleted100644 → 0
+0 −0

Empty file deleted.

+106 −0
Original line number Diff line number Diff line
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# 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.

# Build, tag, and push the Docker image to the GitLab Docker registry
build device:
  variables:
    IMAGE_NAME: 'device' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: build
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile .
    - 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 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"'
    - changes:
      - src/common/**/*.py
      - proto/*.proto
      - src/$IMAGE_NAME/**/*.{py,in,yml}
      - src/$IMAGE_NAME/Dockerfile
      - src/$IMAGE_NAME/tests/*.py
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml

# Apply unit test to the component
unit_test device:
  variables:
    IMAGE_NAME: 'device' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: unit_test
  needs:
    - build device
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi
    - 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 2020:2020 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --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 "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary_emulated.py --junitxml=/opt/results/${IMAGE_NAME}_report.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:
    - docker rm -f $IMAGE_NAME
    - docker network rm teraflowbridge
  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"'
    - changes:
      - src/common/**/*.py
      - proto/*.proto
      - src/$IMAGE_NAME/**/*.{py,in,yml}
      - src/$IMAGE_NAME/Dockerfile
      - src/$IMAGE_NAME/tests/*.py
      - src/$IMAGE_NAME/tests/Dockerfile
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml
  artifacts:
      when: always
      reports:
        junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml

## Deployment of the service in Kubernetes Cluster
#deploy device:
#  variables:
#    IMAGE_NAME: 'device' # name of the microservice
#    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#  stage: deploy
#  needs:
#    - unit test device
#    # - integ_test execute
#  script:
#    - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml'
#    - kubectl version
#    - kubectl get all
#    - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml"
#    - kubectl get all
#  # environment:
#  #   name: test
#  #   url: https://example.com
#  #   kubernetes:
#  #     namespace: test
#  rules:
#    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#      when: manual    
#    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#      when: manual
Loading