Skip to content
Snippets Groups Projects
Commit 10622d4d authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark
Browse files

switch to new gitlab-runner server

<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->

## Related Issue
<!--- This project only accepts merge requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
parent 3e658022
No related branches found
Tags
2 merge requests!256switch to new gitlab-runner server,!247Develop
Pipeline #98257 passed
...@@ -8,7 +8,6 @@ stages: ...@@ -8,7 +8,6 @@ stages:
- build - build
- test - test
- analyze - analyze
- apply
- integration-test - integration-test
- build-release - build-release
- .post - .post
...@@ -18,7 +17,7 @@ include: ...@@ -18,7 +17,7 @@ include:
- local: "/.gitlab/ci/.code-quality-ci.yml" - local: "/.gitlab/ci/.code-quality-ci.yml"
- local: "/.gitlab/ci/.security-and-compliance-ci.yml" - local: "/.gitlab/ci/.security-and-compliance-ci.yml"
- local: "/.gitlab/ci/.test.yml" - local: "/.gitlab/ci/.test.yml"
- local: "/.gitlab/ci/.containerlab-ci.yml" - local: "/.gitlab/ci/.integration-test-containerlab.yml"
- local: "/.gitlab/ci/.integration-test.yml" - local: "/.gitlab/ci/.integration-test.yml"
- local: "/.gitlab/ci/.uml-autogen-ci.yml" - local: "/.gitlab/ci/.uml-autogen-ci.yml"
- local: "/.gitlab/ci/.build-release.yml" - local: "/.gitlab/ci/.build-release.yml"
variables: variables:
CLAB_DIR: "/mnt" CLAB_TEMPLATE: "${CI_PROJECT_DIR}/controller/test/containerlab/int01.clab.tmpl.yml"
CLAB_DIR: "/home/gitlab-runner/clab"
CLAB_NAME: "clab${CI_PIPELINE_IID}" CLAB_NAME: "clab${CI_PIPELINE_IID}"
# Templates for Job Types containerlab-deploy:
.containerlab_deploy: &containerlab_deploy stage: integration-test
stage: apply
rules: rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"' - if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never when: never
- when: on_success - when: on_success
tags: tags:
- shell - shell-containerlab
before_script: needs: ["build-image", "build-testing-image"]
- cd ${CLAB_DIR}
- export PATH="${PATH}:${CI_PROJECT_DIR}/.gitlab/ci/scripts"
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- echo ${GOSDN_IMAGE}
- docker pull ${GOSDN_IMAGE}
- docker pull ${CEOS_IMAGE}
.containerlab_template: &containerlab_template
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine:latest
stage: build
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: on_success
before_script:
- export PATH="${PATH}:${CI_PROJECT_DIR}/.gitlab/ci/scripts"
- firstOctet=$(generate_octet.sh $CI_COMMIT_SHA)
- secondOctet=$(generate_octet.sh $CI_PIPELINE_ID)
- export CLAB_MGMT_SUBNET="172.$firstOctet.$secondOctet.0/24"
script: script:
- firstOctet=$(python3 ${CI_PROJECT_DIR}/.gitlab/ci/scripts/generate_octet.py $CI_COMMIT_SHA)
- secondOctet=$(python3 ${CI_PROJECT_DIR}/.gitlab/ci/scripts/generate_octet.py $CI_PIPELINE_ID)
- export CLAB_MGMT_SUBNET="172.$firstOctet.$secondOctet.0/24"
- cd ${CLAB_DIR}
- ls -la
- | - |
sed -e "s|@@CEOS_CONTAINER_IMAGE@@|${CEOS_IMAGE}|g" \ sed -e "s|@@CEOS_CONTAINER_IMAGE@@|${CEOS_IMAGE}|g" \
-e "s|@@GOSDN_CONTAINER_IMAGE@@|${GOSDN_IMAGE}|g" \ -e "s|@@GOSDN_CONTAINER_IMAGE@@|${GOSDN_IMAGE}|g" \
...@@ -39,91 +25,60 @@ variables: ...@@ -39,91 +25,60 @@ variables:
-e "s|@@CLAB_MGMT_SUBNET@@|${CLAB_MGMT_SUBNET}|g" \ -e "s|@@CLAB_MGMT_SUBNET@@|${CLAB_MGMT_SUBNET}|g" \
${CLAB_TEMPLATE} > ${CLAB_NAME}.clab.yml ${CLAB_TEMPLATE} > ${CLAB_NAME}.clab.yml
- cat ${CLAB_NAME}.clab.yml - cat ${CLAB_NAME}.clab.yml
artifacts: - echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
name: ${CLAB_NAME} - echo ${GOSDN_IMAGE}
paths: - docker pull ${GOSDN_IMAGE}
- ${CLAB_NAME}.clab.yml - docker pull ${CEOS_IMAGE}
- sudo containerlab deploy --topo ${CLAB_DIR}/${CLAB_NAME}.clab.yml --reconfigure
# JOBS
containerlab:template:integration:
extends: .containerlab_template
variables:
CLAB_TEMPLATE: "${CI_PROJECT_DIR}/controller/test/containerlab/int01.clab.tmpl.yml"
containerlab:deploy:integration:
extends: .containerlab_deploy
needs: ["containerlab:template:integration", "build-image"]
script:
- sudo containerlab deploy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml --reconfigure
- | - |
echo -e "\ echo -e "\
GOSDN_HTTP_PORT=$(docker_host_port 8080 clab-${CLAB_NAME}-gosdn)\n\ GOSDN_HTTP_PORT=$(${CI_PROJECT_DIR}/.gitlab/ci/scripts/docker_host_port 8080 clab-${CLAB_NAME}-gosdn)\n\
GOSDN_GRPC_PORT=$(docker_host_port 55055 clab-${CLAB_NAME}-gosdn)\n\ GOSDN_GRPC_PORT=$(${CI_PROJECT_DIR}/.gitlab/ci/scripts/docker_host_port 55055 clab-${CLAB_NAME}-gosdn)\n\
CEOS1_PORT=$(docker_host_port 6030 clab-${CLAB_NAME}-ceos1)" \ CEOS1_PORT=$(${CI_PROJECT_DIR}/.gitlab/ci/scripts/docker_host_port 6030 clab-${CLAB_NAME}-ceos1)" \
> ${CI_PROJECT_DIR}/build.env > ${CI_PROJECT_DIR}/build.env
- cat ${CI_PROJECT_DIR}/build.env - cat ${CI_PROJECT_DIR}/build.env
artifacts: artifacts:
reports: reports:
dotenv: ${CI_PROJECT_DIR}/build.env dotenv: ${CI_PROJECT_DIR}/build.env
containerlab:destroy:
containerlab-destroy:
rules: rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"' - if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never when: never
- when: always - when: always
stage: .post stage: integration-test
tags: tags:
- shell - shell-containerlab
needs: needs:
[ [
"containerlab:deploy:integration", "containerlab-deploy",
"integration-test:nucleus", "integration-test:nucleus",
"integration-test:api", "integration-test:api"
"containerlab:template:integration",
] ]
before_script: before_script:
- cd ${CLAB_DIR} - cd ${CLAB_DIR}
script: script:
- sudo containerlab destroy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml - sudo containerlab destroy --topo ${CLAB_DIR}/${CLAB_NAME}.clab.yml
- docker volume rm -f ${CLAB_NAME}-volume - docker volume rm -f ${CLAB_NAME}-volume
- docker image rm -f ${GOSDN_IMAGE} - rm ${CLAB_DIR}/${CLAB_NAME}.clab.yml
allow_failure: true allow_failure: true
#containerlab:template:develop:
# extends: .containerlab_template
# variables:
# CLAB_NAME: "dev"
# CLAB_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/dev.clab.tmpl.yml"
# GOSDN_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:develop"
# rules:
# - if: $CI_COMMIT_BRANCH == 'develop' && $CI_NIGHTLY == null
#
#
#containerlab:deploy:develop:
# extends:
# - .containerlab_deploy
# needs: ["containerlab:template:develop", "build-image"]
# variables:
# CLAB_NAME: "dev"
# GOSDN_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:develop"
# script:
# - sudo containerlab deploy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml --reconfigure
# rules:
# - if: $CI_COMMIT_BRANCH == 'develop' && $CI_NIGHTLY == null
containerlab:clean: #containerlab:clean:
stage: .post # stage: .post
tags: # tags:
- shell # - shell-containerlab
before_script: # before_script:
- cd ${CLAB_DIR} # - cd ${CLAB_DIR}
script: # script:
- docker kill $(docker ps -q) || true # - docker kill $(docker ps -q) || true
- docker rm $(docker ps -a -q) || true # - docker rm $(docker ps -a -q) || true
- docker rmi $(docker images | grep 'registry.code.fbi.h-da.de/danet/gosdn ' | awk '{print $3}') || true # - docker rmi $(docker images | grep 'registry.code.fbi.h-da.de/danet/gosdn ' | awk '{print $3}') || true
- sudo rm -rf ${CLAB_DIR}/clab-* || true # - sudo rm -rf ${CLAB_DIR}/clab-* || true
- sudo sed -i 's|.*clab.*||g' /etc/hosts # - sudo sed -i 's|.*clab.*||g' /etc/hosts
allow_failure: true # allow_failure: true
rules: # rules:
- if: $CI_SCHEDULE_CLEAN # - if: $CI_SCHEDULE_CLEAN
when: always # when: always
...@@ -6,13 +6,11 @@ ...@@ -6,13 +6,11 @@
when: never when: never
- when: on_success - when: on_success
needs: needs:
- job: "containerlab:deploy:integration" ["containerlab-deploy"]
tags:
- integration-test-docker
variables: variables:
GOSDN_LOG: "nolog" GOSDN_LOG: "nolog"
GOSDN_TEST_API_ENDPOINT: "${CI_SERVER_IP}:${GOSDN_GRPC_PORT}" GOSDN_TEST_API_ENDPOINT: "10.254.254.105:${GOSDN_GRPC_PORT}"
CEOS_TEST_ENDPOINT: "${CI_SERVER_IP}:${CEOS1_PORT}" CEOS_TEST_ENDPOINT: "10.254.254.105:${CEOS1_PORT}"
GOSDN_TEST_USER: "admin" GOSDN_TEST_USER: "admin"
GOSDN_TEST_PASSWORD: "admin" GOSDN_TEST_PASSWORD: "admin"
...@@ -30,3 +28,9 @@ integration-test:api: ...@@ -30,3 +28,9 @@ integration-test:api:
script: script:
- cd controller/ - cd controller/
- make integration-test-api - make integration-test-api
integration-test:cli:
<<: *integration-test
script:
- cd cli/
- echo "Your tests here"
File mode changed from 100644 to 100755
import sys
from hashlib import sha256
input_data = sys.argv[1]
# Hash input and store it as string
hashed_string = sha256(bytes(input_data, encoding='utf8')).hexdigest()
final_string = ""
# Iterate over hash and take out all chars that are a number
for character in hashed_string:
if character.isdigit():
final_string += character
final_int = int(final_string)
# Print number mod 256 to get a number between 0 and 255 for ip adress
print(final_int % 256)
#!/bin/sh
input=$1
hashed_value=$(echo $input | sha256sum | awk '{print $1}' )
decimal_value=$((16#$hashed_value))
decimal_value=${decimal_value/-/}
octet=$(((decimal_value % 255)))
echo -n $octet
...@@ -118,7 +118,7 @@ func bufDialer(context.Context, string) (net.Conn, error) { ...@@ -118,7 +118,7 @@ func bufDialer(context.Context, string) (net.Conn, error) {
const testPath = "/system/config/hostname" const testPath = "/system/config/hostname"
var testAddress = "141.100.70.170:6030" var testAddress = "10.254.254.105:6030"
var testAPIEndpoint = "gosdn-latest.apps.ocp.fbi.h-da.de" var testAPIEndpoint = "gosdn-latest.apps.ocp.fbi.h-da.de"
var testUsername = "admin" var testUsername = "admin"
var testPassword = "arista" var testPassword = "arista"
......
...@@ -29,7 +29,7 @@ const unreachable = "203.0.113.10:6030" ...@@ -29,7 +29,7 @@ const unreachable = "203.0.113.10:6030"
const testPath = "/system/config/hostname" const testPath = "/system/config/hostname"
var modifiedHostname = "ceos3000" var modifiedHostname = "ceos3000"
var testAddress = "141.100.70.170:6030" var testAddress = "10.254.254.105:6030"
var testUsername = "admin" var testUsername = "admin"
var testPassword = "arista" var testPassword = "arista"
var opt *tpb.TransportOption var opt *tpb.TransportOption
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment