#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/e2eorchestratorservice -c server
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/forecasterservice -c server
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/nbiservice -c server
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/opticalcontrollerservice -c server
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG/SDG (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.
......@@ -27,39 +27,70 @@ FILE_PATH_SKIPPED = 'out-skipped.txt'
FILE_PATH_NO_HEADER = 'out-no-header.txt'
FILE_PATH_UPDATED = 'out-updated.txt'
RE_OLD_COPYRIGHT = re.compile(r'Copyright\ 2021\-2023\ H2020\ TeraFlow\ \(https\:\/\/www\.teraflow\-h2020\.eu\/\)')
STR_NEW_COPYRIGHT = 'Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)'
STR_NEW_COPYRIGHT = 'Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)'
RE_OLD_COPYRIGHTS = [
r'Copyright\ 2021\-2023\ H2020\ TeraFlow\ \(https\:\/\/www\.teraflow\-h2020\.eu\/\)',
r'Copyright\ 2022\-2023\ ETSI\ TeraFlowSDN\ \-\ TFS\ OSG\ \(https\:\/\/tfs\.etsi\.org\/\)',
]
RE_OLD_COPYRIGHTS = [
(re.compile(r'.*{}.*'.format(re_old_copyright)), re.compile(re_old_copyright))
for re_old_copyright in RE_OLD_COPYRIGHTS
]
def skip_file(file_path : str) -> bool:
if os.path.islink(file_path): return True
if file_path.endswith('.pyc'): return True
if file_path.endswith('_pb2_grpc.py'): return True
if file_path.endswith('_pb2.py'): return True
if file_path.endswith('.class'): return True
if file_path.endswith('.md'): return True
if file_path.endswith('.png'): return True
if file_path.endswith('.json'): return True
if file_path.endswith('.csv'): return True
if file_path.endswith('.zip'): return True
if file_path.endswith('.zip'): return True
if file_path.endswith('.jar'): return True
if file_path.endswith('.onnx'): return True
if file_path.endswith('/tstat'): return True
if file_path.endswith('/.gitignore'): return True
if file_path.endswith('/.gitkeep'): return True
if file_path.endswith('/coverage/.coverage'): return True
if file_path.endswith('/grpc/grpcurl/grpcurl'): return True
if file_path.endswith('/probe/probe-tfs/target/x86_64-unknown-linux-musl/release/tfsagent'): return True
if file_path.endswith('/probe/probe-tfs/target/x86_64-unknown-linux-musl/release/tfsping'): return True
if file_path.startswith('./libyang/'): return True
if file_path.startswith('./netconf_openconfig/'): return True
if file_path.startswith('./tmp/'): return True
if '/manifests/cttc-ols/' in file_path: return True
if '/hackfest/netconf-oc/openconfig/' in file_path: return True
if '/hackfest/tapi/server/tapi_server/' in file_path: return True
if '/hackfest/kafka/kafka_2.13-2.8.0/' in file_path: return True
if '/.git/' in file_path: return True
if '/.vscode/' in file_path: return True
if '/.pytest_cache/' in file_path: return True
if '/__pycache__/' in file_path: return True
if '/.mvn/' in file_path: return True
if '/hackfest/kafka/kafka_2.13-2.8.0' in file_path: return True
if '/src/device/service/drivers/openconfig/templates/' in file_path: return True
if '/automation/target/generated-sources/grpc/' in file_path: return True
if '/automation/target/kubernetes/' in file_path: return True
if '/policy/target/generated-sources/grpc/' in file_path: return True
if '/policy/target/kubernetes/' in file_path: return True
if '/src/dlt/gateway/' in file_path: return True
if '/bgpls_speaker/service/java/netphony-topology/.settings/' in file_path: return True
if '/bgpls_speaker/service/java/netphony-topology/' in file_path:
file_path_parts = file_path.split('/')
file_name = file_path_parts[-1]
return file_name in {'LICENSE', 'VERSION'}
if '/device/service/drivers/gnmi_openconfig/git/' in file_path: return True
if '/device/service/drivers/openconfig/templates/' in file_path:
if file_path.endswith('.xml'): return True
file_path_parts = file_path.split('/')
file_name = file_path_parts[-1]
if file_name.startswith('openconfig_') and file_name.endswith('.py'): return True
return False
if '/nbi/service/rest_server/nbi_plugins/ietf_network/bindings/' in file_path: return True
if '/nbi/service/rest_server/nbi_plugins/ietf_network_slice/bindings/' in file_path: return True
if '/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/yang/' in file_path: return True
if '/nbi/service/rest_server/nbi_plugins/ietf_network/yang/' in file_path: return True
if '/ztp/target/' in file_path: return True
if '/policy/target/' in file_path: return True
if '/dlt/gateway/Dockerfile' in file_path: return False
if '/dlt/gateway/' in file_path: return True
if FILE_PATH_SKIPPED in file_path: return True
if FILE_PATH_NO_HEADER in file_path: return True
if FILE_PATH_UPDATED in file_path: return True
......@@ -67,8 +98,11 @@ def skip_file(file_path : str) -> bool:
return False
def process_line(line_in : str) -> str:
line_out = RE_OLD_COPYRIGHT.sub(STR_NEW_COPYRIGHT, line_in)
if line_out != line_in: return line_out
for re_match, re_sub in RE_OLD_COPYRIGHTS:
match = re_match.match(line_in)
if match is None: continue
line_out = re_sub.sub(STR_NEW_COPYRIGHT, line_in)
return line_out
return line_in
def process_file(
......@@ -82,13 +116,18 @@ def process_file(
temp_file_path = file_path + '.temp'
replaced = False
file_stat = os.stat(file_path)
try:
with open(file_path, encoding='UTF-8') as source:
with open(temp_file_path, 'w', encoding='UTF-8') as target:
with open(file_path, encoding='UTF-8', newline='') as source:
with open(temp_file_path, 'w', encoding='UTF-8', newline='') as target:
for line_in in source:
line_out = process_line(line_in)
target.write(line_out)
replaced = replaced or (line_out != line_in)
if STR_NEW_COPYRIGHT in line_in:
replaced = True
target.write(line_in)
else:
line_out = process_line(line_in)
replaced = replaced or (line_out != line_in)
target.write(line_out)
except: # pylint: disable=bare-except
replaced = False
......@@ -98,6 +137,7 @@ def process_file(
file_updated.write(file_path + '\n')
os.rename(temp_file_path, file_path)
os.chmod(file_path, file_stat.st_mode)
def main() -> int:
with open(FILE_PATH_NO_HEADER, 'w', encoding='UTF-8') as file_no_header:
......
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
while ! kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server 2>&1 | grep -q 'Subscriber is Ready? True'; do sleep 1; done
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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.
......
# 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.
variables:
IMAGE_NAME: 'automation'
REPORTS_PATH: "src/${IMAGE_NAME}/reports"
BUILD_ENV: build.env
# Package application needed to run tests & build the image on next stage
build automation:
stage: build
script:
- export IMAGE_TAG=$(grep -m1 '<version>' ./src/$IMAGE_NAME/pom.xml | grep -oP '(?<=>).*(?=<)')
- echo "IMAGE_TAG=${IMAGE_TAG}" >> ${BUILD_ENV}
- cat ${BUILD_ENV}
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target builder
after_script:
- docker images --filter="dangling=true" --quiet | xargs -r docker rmi
artifacts:
reports:
dotenv: ${BUILD_ENV}
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/$IMAGE_NAME/**
- manifests/${IMAGE_NAME}service.yaml
- .gitlab-ci.yml
# Run tests, build & push the image
unit_test automation:
variables:
REPORTS_CONTAINER: "${IMAGE_NAME}-reports"
stage: unit_test
needs:
- build automation
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker rm ${REPORTS_CONTAINER} || true
script:
- echo "Running tests for image ${IMAGE_TAG}"
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target unit-test
# Transfer JaCoCo and Surefire reports from within tests image
- docker create --name ${REPORTS_CONTAINER} "$IMAGE_NAME:$IMAGE_TAG"
- mkdir -p ${REPORTS_PATH}
- docker cp ${REPORTS_CONTAINER}:/app/target/site/jacoco/index.html ${REPORTS_PATH}/coverage.html
- docker cp ${REPORTS_CONTAINER}:/app/target/site/jacoco/jacoco.xml ${REPORTS_PATH}/jacoco.xml
- docker cp ${REPORTS_CONTAINER}:/app/target/surefire-reports/ ${REPORTS_PATH}/
- cat ${REPORTS_PATH}/coverage.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total/JaCoCo Coverage Total:/'
- docker run -v "$(pwd)/src/${IMAGE_NAME}:/${IMAGE_NAME}" --rm registry.gitlab.com/haynes/jacoco2cobertura:1.0.7 python /opt/cover2cover.py ${IMAGE_NAME}/reports/jacoco.xml ${IMAGE_NAME}/src/main/java > ${REPORTS_PATH}/cobertura.xml
# Build final image
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target release
- 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 rm ${REPORTS_CONTAINER}
- docker rm -f "$IMAGE_NAME:$IMAGE_TAG"
coverage: '/JaCoCo Coverage Total: ([0-9]{1,3})%/'
artifacts:
reports:
junit:
- ${REPORTS_PATH}/surefire-reports/TEST-*.xml
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/$IMAGE_NAME/**
- manifests/${IMAGE_NAME}service.yaml
- .gitlab-ci.yml
## Deployment of automation service in Kubernetes Cluster
#deploy automation:
# stage: deploy
# needs:
# - build automation
# - unit_test automation
# script:
# - kubectl version
# - kubectl get all
# - kubectl delete --ignore-not-found=true -f "manifests/automationservice.yaml"
# - kubectl apply -f "manifests/automationservice.yaml"
# - kubectl delete pods --selector app=automationservice
# - kubectl get all
# 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