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

Create new integration-test setup


See merge request !574

Co-authored-by: default avatarMalte Bauch <malte.bauch@stud.h-da.de>
Co-authored-by: default avatarFabian Seidl <fabian.seidl@h-da.de>
parent adbe2f72
No related branches found
No related tags found
1 merge request!574Create new integration-test setup
Pipeline #171896 passed
Showing
with 242 additions and 119 deletions
# The devcontainer will be based on Python # The devcontainer will be based on debian
# The base container already has entrypoint, vscode user account, etc. out of the box # The base container already has entrypoint, vscode user account, etc. out of the box
FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye
...@@ -6,17 +6,17 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye ...@@ -6,17 +6,17 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye
ARG _CLAB_VERSION ARG _CLAB_VERSION
# Set permissions for mounts in devcontainer.json # Set permissions for mounts in devcontainer.json
RUN mkdir /home/vscode/.vscode-server/ RUN mkdir -p /home/vscode/.vscode-server/bin
RUN mkdir /home/vscode/.vscode-server/bin
RUN chown -R vscode:vscode /home/vscode/.vscode-server RUN chown -R vscode:vscode /home/vscode/.vscode-server
# Update and install some basic tools inside the container # Update and install some basic tools inside the container
# Adjust this list based on your demands # Adjust this list based on your demands
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y \ && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \ && apt-get install -y \
sshpass \ sshpass \
curl \ curl \
wget \
iputils-ping \ iputils-ping \
htop \ htop \
zsh \ zsh \
...@@ -29,7 +29,7 @@ RUN apt-get update \ ...@@ -29,7 +29,7 @@ RUN apt-get update \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \ && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
&& apt-get clean && apt-get clean
# Install oh-my-zsh for more terminal features and set is as primary shell # Install oh-my-zsh for more terminal features and set it as primary shell
ENV SHELL /bin/zsh ENV SHELL /bin/zsh
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
...@@ -39,4 +39,3 @@ RUN echo "export EDITOR='nano'" >> /home/vscode/.zshrc ...@@ -39,4 +39,3 @@ RUN echo "export EDITOR='nano'" >> /home/vscode/.zshrc
# Install preferred version of the containerlab # Install preferred version of the containerlab
RUN bash -c "$(curl -sL https://get.containerlab.dev)" -- -v ${_CLAB_VERSION} RUN bash -c "$(curl -sL https://get.containerlab.dev)" -- -v ${_CLAB_VERSION}
#&& pip3 install --user yamllint
// For format details, see https://aka.ms/devcontainer.json. For config options, see the // For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python // README at: https://github.com/devcontainers/templates/tree/main/src/python
{ {
"name": "goSDN-develop-clab-go", "name": "goSDN-develop-clab-go",
"build": { "build": {
"dockerfile": "Dockerfile", "dockerfile": "Dockerfile",
"args": { "args": {
"_CLAB_VERSION": "0.47.2" "_CLAB_VERSION": "0.48.6"
} }
}, },
"features": { "features": {
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
}, },
"ghcr.io/devcontainers/features/go:1": { "ghcr.io/devcontainers/features/go:1": {
"version": "1.21" "version": "1.21"
} }
}, },
// Add any required extensions that must be pre-installed in the devcontainer // Add any required extensions that must be pre-installed in the devcontainer
"customizations": { "customizations": {
......
.git .git
.gitlab
build build
documentation documentation
mocks mocks
......
...@@ -4,8 +4,8 @@ artifacts/ ...@@ -4,8 +4,8 @@ artifacts/
# containerlab # containerlab
clab-gosdn*/ clab-gosdn*/
*clab.yml.bak *.yml.bak
dev_env_data/clab/*clab.yaml.bak dev_env_data/clab/*.yaml.bak
# non vimmers # non vimmers
.vscode/ .vscode/
...@@ -74,4 +74,4 @@ plugin-registry/plugins/ ...@@ -74,4 +74,4 @@ plugin-registry/plugins/
# lab-vm # lab-vm
lab-vm/vm-with-packer/VM/ lab-vm/vm-with-packer/VM/
lab-vm/vm-with-vagrant/.vagrant/ lab-vm/vm-with-vagrant/.vagrant/
\ No newline at end of file
variables: variables:
GOSDN_IMAGE: "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}" DOCKER_TAG: $CI_COMMIT_SHA
GOSDN_TESTING_IMAGE: "${CI_REGISTRY_IMAGE}:testing_${CI_COMMIT_SHA}" GOSDN_IMAGE: "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}"
GOSDN_TESTING_IMAGE: "${CI_REGISTRY_IMAGE}:testing_${DOCKER_TAG}"
GOSDN_INTEGRATION_TEST_IMAGE: "${CI_REGISTRY_IMAGE}/integration-tests:${DOCKER_TAG}"
CEOS_IMAGE: "${CI_PCONTAINERS_REGISTRY_IMAGE}/ceos:4.28.2F" CEOS_IMAGE: "${CI_PCONTAINERS_REGISTRY_IMAGE}/ceos:4.28.2F"
CLAB_VERSION: "0.48.6"
GOLANG_VERSION: "1.21" GOLANG_VERSION: "1.21"
GNMI_TARGET_IMAGE: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master
GNMI_TARGET_INTEGRATION_IMAGE: "registry.code.fbi.h-da.de/danet/gosdn/gnmi-target-integration-test:${CI_COMMIT_SHA}"
workflow: workflow:
rules: rules:
...@@ -12,10 +17,11 @@ workflow: ...@@ -12,10 +17,11 @@ workflow:
stages: stages:
- tools - tools
- build - build
- build-testing
- build-release
- test - test
- analyze - analyze
- integration-test - test-legacy
- build-release
- deploy - deploy
- .post - .post
...@@ -25,8 +31,9 @@ include: ...@@ -25,8 +31,9 @@ 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/.integration-test-containerlab.yml"
- local: "/.gitlab/ci/.integration-test.yml"
- local: "/.gitlab/ci/.uml-autogen-ci.yml" - local: "/.gitlab/ci/.uml-autogen-ci.yml"
- local: "/.gitlab/ci/.renovate.yml" - local: "/.gitlab/ci/.renovate.yml"
- local: "/.gitlab/ci/.mk-docs-deploy.yml" - local: "/.gitlab/ci/.mk-docs-deploy.yml"
- local: "/.gitlab/ci/legacy/.test.yml"
#- local: "/.gitlab/ci/legacy/.integration-test-containerlab.yml"
#- local: "/.gitlab/ci/legacy/.integration-test.yml"
.build: &build .build: &build
stage: build stage: build
tags: image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest
- shell-builder services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest
alias: docker
variables: variables:
TAG: $CI_COMMIT_SHA DOCKER_TLS_CERTDIR: "/certs"
before_script:
- apk add git
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker login -u $CI_DEPENDENCY_PROXY_USER -p $CI_DEPENDENCY_PROXY_PASSWORD $CI_DEPENDENCY_PROXY_SERVER
needs: [] needs: []
build-controller-testing-image:
script: .build-testing: &build-testing
- docker buildx build -t "$GOSDN_TESTING_IMAGE" -f "${CI_PROJECT_DIR}/controller/controller.Dockerfile" --target "builder" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" . stage: build-testing
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest
- docker push "$GOSDN_TESTING_IMAGE" services:
<<: *build - name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest
alias: docker
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- apk add git
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker login -u $CI_DEPENDENCY_PROXY_USER -p $CI_DEPENDENCY_PROXY_PASSWORD $CI_DEPENDENCY_PROXY_SERVER
build-controller-image: build-controller-image:
script: script:
- docker buildx build -t "$CI_REGISTRY_IMAGE:$TAG" -f "${CI_PROJECT_DIR}/controller/controller.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" . - docker buildx build -t "$CI_REGISTRY_IMAGE:$DOCKER_TAG" -f "${CI_PROJECT_DIR}/controller/controller.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker push "$CI_REGISTRY_IMAGE:$DOCKER_TAG"
- docker push "$CI_REGISTRY_IMAGE:$TAG"
<<: *build <<: *build
build-cli-image: build-cli-image:
script: script:
- CLI_IMAGE_NAME="${CI_REGISTRY_IMAGE}/gosdnc" - CLI_IMAGE_NAME="${CI_REGISTRY_IMAGE}/gosdnc"
- docker buildx build -t "$CLI_IMAGE_NAME:$TAG" -f "${CI_PROJECT_DIR}/cli/cli.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" . - docker buildx build -t "$CLI_IMAGE_NAME:$DOCKER_TAG" -f "${CI_PROJECT_DIR}/cli/cli.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker push "$CLI_IMAGE_NAME:$DOCKER_TAG"
- docker push "$CLI_IMAGE_NAME:$TAG"
<<: *build <<: *build
build-venv-manager-image: build-venv-manager-image:
script: script:
- VENV_MANAGER_IMAGE_NAME="${CI_REGISTRY_IMAGE}/venv-manager" - VENV_MANAGER_IMAGE_NAME="${CI_REGISTRY_IMAGE}/venv-manager"
- docker buildx build -t "$VENV_MANAGER_IMAGE_NAME:$TAG" -f "${CI_PROJECT_DIR}/applications/venv-manager/venv-manager.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" . - docker buildx build -t "$VENV_MANAGER_IMAGE_NAME:$DOCKER_TAG" -f "${CI_PROJECT_DIR}/applications/venv-manager/venv-manager.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker push "$VENV_MANAGER_IMAGE_NAME:$DOCKER_TAG"
- docker push "$VENV_MANAGER_IMAGE_NAME:$TAG"
<<: *build <<: *build
build-arista-routing-engine-image: build-arista-routing-engine-image:
script: script:
- ARISTA_ROUTING_ENGINE_IMAGE_NAME="${CI_REGISTRY_IMAGE}/arista-routing-engine" - ARISTA_ROUTING_ENGINE_IMAGE_NAME="${CI_REGISTRY_IMAGE}/arista-routing-engine"
- docker buildx build -t "$ARISTA_ROUTING_ENGINE_IMAGE_NAME:$TAG" -f "${CI_PROJECT_DIR}/applications/arista-routing-engine/arista-routing-engine.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" . - docker buildx build -t "$ARISTA_ROUTING_ENGINE_IMAGE_NAME:$DOCKER_TAG" -f "${CI_PROJECT_DIR}/applications/arista-routing-engine/arista-routing-engine.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker push "$ARISTA_ROUTING_ENGINE_IMAGE_NAME:$DOCKER_TAG"
- docker push "$ARISTA_ROUTING_ENGINE_IMAGE_NAME:$TAG"
<<: *build <<: *build
build-plugin-registry-image: build-plugin-registry-image:
script: script:
- PLUGIN_REGISTRY_IMAGE_NAME="${CI_REGISTRY_IMAGE}/plugin-registry" - PLUGIN_REGISTRY_IMAGE_NAME="${CI_REGISTRY_IMAGE}/plugin-registry"
- docker buildx build -t "$PLUGIN_REGISTRY_IMAGE_NAME:$TAG" -f "${CI_PROJECT_DIR}/plugin-registry/plugin-registry.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" . - docker buildx build -t "$PLUGIN_REGISTRY_IMAGE_NAME:$DOCKER_TAG" -f "${CI_PROJECT_DIR}/plugin-registry/plugin-registry.Dockerfile" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker push "$PLUGIN_REGISTRY_IMAGE_NAME:$DOCKER_TAG"
- docker push "$PLUGIN_REGISTRY_IMAGE_NAME:$TAG"
<<: *build <<: *build
build-integration-test-images:
needs: ["build-controller-image"]
script:
# Build certs
- apk add openssl make
- make generate-certs
# Build gosdn with ssl certificates
- docker buildx build -t "$CI_REGISTRY_IMAGE:${DOCKER_TAG}_integration-test" -f "${CI_PROJECT_DIR}/.gitlab/ci/gosdn-integration.Dockerfile" --build-arg "GOSDN_IMAGE=$CI_REGISTRY_IMAGE:${DOCKER_TAG}" .
# Update gnmi-target with ssl certificates
- docker buildx build -t $GNMI_TARGET_INTEGRATION_IMAGE -f "${CI_PROJECT_DIR}/.gitlab/ci/gnmi-cert-integration.Dockerfile" --build-arg "GNMI_TARGET_IMAGE=${GNMI_TARGET_IMAGE}" .
# Push images
- docker push "$CI_REGISTRY_IMAGE:${DOCKER_TAG}_integration-test"
- docker push $GNMI_TARGET_INTEGRATION_IMAGE
<<: *build-testing
variables: variables:
GOLANG_VERSION: "1.21" GOLANG_VERSION: "1.21"
code-quality: code-quality:
image: golangci/golangci-lint:v1.55.2-alpine image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golangci/golangci-lint:v1.55.2-alpine
stage: analyze stage: analyze
script: script:
# writes golangci-lint output to gl-code-quality-report.json # writes golangci-lint output to gl-code-quality-report.json
......
.test: &test .test: &test
image: $GOSDN_TESTING_IMAGE
stage: test stage: test
rules:
- when: on_success
variables:
GOSDN_LOG: "nolog"
GOSDN_CHANGE_TIMEOUT: "5000ms"
coverage: '/total:\s+\(statements\)\s+(\d+.\d+\%)/'
artifacts:
when: always
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: ./controller/coverage.xml
needs:
- build-controller-testing-image
unit-test: integration-test-controller:
script: image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION-bookworm
- cd controller needs:
- make ci-unit-test - ["build-integration-test-images"]
after_script: #image: debian:latest
- cd controller variables:
- go tool cover -func=coverage.out MONGO_INITDB_ROOT_USERNAME: root
- gocover-cobertura < coverage.out > coverage.xml MONGO_INITDB_ROOT_PASSWORD: example
<<: *test FF_NETWORK_PER_BUILD: 1
services:
controller-test: - name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/mongo:5
alias: mongo
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/rabbitmq:3-management
alias: rabbitmq
variables:
HEALTHCHECK_TCP_PORT: "5672"
- name: $PLUGIN_REGISTRY_IMAGE_NAME:$DOCKER_TAG
- name: $GNMI_TARGET_INTEGRATION_IMAGE
alias: gnmi-target_1
command: ["start", "--cert", "/etc/gnmi-target/ssl/certs/gnmi-target-selfsigned.crt", "--key", "/etc/gnmi-target/ssl/private/gnmi-target-selfsigned.key", "--ca_file", "/etc/gnmi-target/ssl/ca.crt"]
- name: $GNMI_TARGET_INTEGRATION_IMAGE
alias: gnmi-target_2
command: ["start", "--cert", "/etc/gnmi-target/ssl/certs/gnmi-target-selfsigned.crt", "--key", "/etc/gnmi-target/ssl/private/gnmi-target-selfsigned.key", "--ca_file", "/etc/gnmi-target/ssl/ca.crt"]
# Use gosdn docker image from this branch
# Uncomment later when fixed. See: https://code.fbi.h-da.de/danet/gosdn/-/issues/335
#- name: "$CI_REGISTRY_IMAGE:${DOCKER_TAG}_integration-test"
# alias: gosdn
# variables:
# GOSDN_ADMIN_PASSWORD: TestPassword
# command: ["--config", "/app/configs/integration-test-gosdn.toml", "--security", "insecure"]
script: script:
- cd controller # Remove later when fixed. See: https://code.fbi.h-da.de/danet/gosdn/-/issues/335
- make ci-controller-test - make build-gosdn
- cd artifacts && GOSDN_ADMIN_PASSWORD=TestPassword ./gosdn --config ../controller/configs/integration-test-gosdn.toml --security insecure &
- INTEGRATION_TEST_CONTROLLER_URL="localhost:55055" go test ./integration-tests/*
<<: *test <<: *test
ARG GNMI_TARGET_IMAGE=registry.code.fbi.h-da.de/danet/gnmi-target/debian:latest
FROM ${GNMI_TARGET_IMAGE}
RUN mkdir -p /etc/gnmi-target/ssl/certs/
RUN mkdir -p /etc/gnmi-target/ssl/private/
COPY ./artifacts/ssl/gnmi-target /etc/gnmi-target/ssl
ARG GOSDN_IMAGE
FROM ${GOSDN_IMAGE}
RUN mkdir /app/ssl
COPY ./artifacts/ssl/gosdn /app/ssl
#COPY .gitlab/ci/test-start.sh test-start.sh
#RUN chmod +x test-start.sh
#ENTRYPOINT ["./test-start.sh"]
...@@ -3,8 +3,8 @@ variables: ...@@ -3,8 +3,8 @@ variables:
CLAB_DIR: "/home/gitlab-runner/clab" CLAB_DIR: "/home/gitlab-runner/clab"
CLAB_NAME: "clab${CI_PIPELINE_IID}" CLAB_NAME: "clab${CI_PIPELINE_IID}"
containerlab-deploy: legacy-containerlab-deploy:
stage: integration-test stage: test-legacy
tags: tags:
- shell-containerlab - shell-containerlab
needs: ["build-controller-image", "build-controller-testing-image"] needs: ["build-controller-image", "build-controller-testing-image"]
...@@ -38,16 +38,15 @@ containerlab-deploy: ...@@ -38,16 +38,15 @@ containerlab-deploy:
dotenv: ${CI_PROJECT_DIR}/build.env dotenv: ${CI_PROJECT_DIR}/build.env
containerlab-destroy: legacy-containerlab-destroy:
stage: integration-test stage: test-legacy
tags: tags:
- shell-containerlab - shell-containerlab
needs: needs:
[ [
"containerlab-deploy", "legacy-containerlab-deploy",
#"integration-test:nucleus", "legacy-integration-test-legacy:nucleus",
"integration-test:api" "legacy-integration-test-legacy:api"
] ]
before_script: before_script:
- cd ${CLAB_DIR} - cd ${CLAB_DIR}
......
.integration-test: &integration-test .legacy-integration-test: &legacy-integration-test
image: $GOSDN_TESTING_IMAGE image: $GOSDN_TESTING_IMAGE
stage: integration-test stage: test-legacy
needs: needs:
["containerlab-deploy"] ["legacy-containerlab-deploy"]
variables: variables:
GOSDN_LOG: "nolog" GOSDN_LOG: "nolog"
GOSDN_TEST_API_ENDPOINT: "10.254.254.105:${GOSDN_GRPC_PORT}" GOSDN_TEST_API_ENDPOINT: "10.254.254.105:${GOSDN_GRPC_PORT}"
...@@ -10,24 +10,23 @@ ...@@ -10,24 +10,23 @@
GOSDN_TEST_USER: "admin" GOSDN_TEST_USER: "admin"
GOSDN_TEST_PASSWORD: "admin" GOSDN_TEST_PASSWORD: "admin"
# NOTE: Current test setup and runners are changed, therefore this test is not possible to run at the moment legacy-integration-test-legacy:nucleus:
#integration-test:nucleus: <<: *legacy-integration-test
# <<: *integration-test script:
# script: - ${CI_PROJECT_DIR}/.gitlab/ci/scripts/wait-for-it.sh ${CEOS_TEST_ENDPOINT} -s -t 180 -- echo "CEOS is up"
# - ${CI_PROJECT_DIR}/.gitlab/ci/scripts/wait-for-it.sh ${CEOS_TEST_ENDPOINT} -s -t 180 -- echo "CEOS is up" - cd controller/
# - cd controller/ - make integration-test-nucleus
# - make integration-test-nucleus
integration-test:api: legacy-integration-test-legacy:api:
<<: *integration-test <<: *legacy-integration-test
variables: variables:
K8S_OP: "getenv" K8S_OP: "getenv"
script: script:
- cd controller/ - cd controller/
- make integration-test-api - make integration-test-api
integration-test:cli: legacy-integration-test:cli:
<<: *integration-test <<: *legacy-integration-test
script: script:
- cd cli/ - cd cli/
- echo "Your tests here" - echo "Your tests here"
.legacy-test: &legacy-test
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION-bookworm
stage: test-legacy
rules:
- when: on_success
variables:
GOSDN_LOG: "nolog"
GOSDN_CHANGE_TIMEOUT: "5000ms"
coverage: '/total:\s+\(statements\)\s+(\d+.\d+\%)/'
artifacts:
when: always
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: ./controller/coverage.xml
needs: []
legacy-unit-test:
script:
- cd controller
- make ci-unit-test
after_script:
- cd controller
- go tool cover -func=coverage.out
- gocover-cobertura < coverage.out > coverage.xml
<<: *legacy-test
#legacy-controller-test:
# script:
# - cd controller
# - make ci-controller-test
# <<: *legacy-test
...@@ -11,7 +11,7 @@ MAKEFILE_SUBDIR := ./makefiles ...@@ -11,7 +11,7 @@ MAKEFILE_SUBDIR := ./makefiles
GOCMD=go GOCMD=go
GOBUILD=$(GOCMD) build GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean GOCLEAN=$(GOCMD) clean -cache -fuzzcache -testcache -modcache
BUILD_ARTIFACTS_PATH=artifacts BUILD_ARTIFACTS_PATH=artifacts
PLUGIN_NAME= bundled_plugin.zip PLUGIN_NAME= bundled_plugin.zip
...@@ -73,20 +73,34 @@ shell-orchestrator: ...@@ -73,20 +73,34 @@ shell-orchestrator:
start: build-gosdn start: build-gosdn
./$(BUILD_ARTIFACTS_PATH)/gosdn -l debug --config ./controller/configs/gosdn.toml ./$(BUILD_ARTIFACTS_PATH)/gosdn -l debug --config ./controller/configs/gosdn.toml
start-virt-manager-example: build containerize-plugin-registry virt-manager-example-start: build containerize-plugin-registry
./scripts/manage_virt_env.sh --mode start --topology dev_env_data/clab/basic_two_aristas.yaml --sdnconfig dev_env_data/sdn/basic_two_aristas.json ./scripts/manage_virt_env.sh --mode start --topology dev_env_data/clab/basic_two_aristas.yaml --sdnconfig dev_env_data/sdn/basic_two_aristas.json
stop-virt-manager-example: virt-manager-example-stop:
./scripts/manage_virt_env.sh --mode stop --topology dev_env_data/clab/basic_two_aristas.yaml ./scripts/manage_virt_env.sh --mode stop --topology dev_env_data/clab/basic_two_aristas.yaml
start-dev-env: containerize-gosdn containerize-plugin-registry dev-env-start: containerize-gosdn containerize-plugin-registry
./scripts/simple-dev-setup.sh --mode start --topology dev_env_data/clab/basic_two_aristas.yaml ./scripts/simple-dev-setup.sh --mode start --topology dev_env_data/clab/basic_two_gnmi_targets.yaml
stop-dev-env: dev-env-stop:
./scripts/simple-dev-setup.sh --mode stop --topology dev_env_data/clab/basic_two_aristas.yaml ./scripts/simple-dev-setup.sh --mode stop --topology dev_env_data/clab/basic_two_gnmi_targets.yaml
generate-certs: generate-gnmi-target-certs generate-gosdn-certs generate-certs: generate-gnmi-target-certs generate-gosdn-certs
controller-integration-tests: generate-certs containerize-gosdn containerize-plugin-registry
docker-compose -f dev_env_data/docker-compose/integration-test_docker-compose.yml down
docker-compose -f dev_env_data/docker-compose/integration-test_docker-compose.yml up -d
go test ./integration-tests/*
docker-compose -f dev_env_data/docker-compose/integration-test_docker-compose.yml down
controller-integration-tests-debug-up: generate-certs containerize-gosdn containerize-plugin-registry
docker-compose -f dev_env_data/docker-compose/integration-test_docker-compose.yml up -d
controller-integration-tests-debug-down:
docker-compose -f dev_env_data/docker-compose/integration-test_docker-compose.yml down
# Warning: Depending on you go configuration might also clean caches, modules and docker containers from your other projects.
clean: clean:
$(GOCLEAN) $(GOCLEAN)
rm -rf $(BUILD_ARTIFACTS_PATH) rm -rf $(BUILD_ARTIFACTS_PATH) $(TOOLS_DIR)
docker system prune -af
...@@ -34,10 +34,10 @@ There you can also find some tutorials to get to know the SDN controller: ...@@ -34,10 +34,10 @@ There you can also find some tutorials to get to know the SDN controller:
- [Additional services](#additional-services) - [Additional services](#additional-services)
- [Configuration file](#configuration-file) - [Configuration file](#configuration-file)
- [Development-Tutorial](#development-tutorial) - [Development-Tutorial](#development-tutorial)
- [Integration tests](#integration-tests)
- [Contributing](CONTRIBUTING.md) - [Contributing](CONTRIBUTING.md)
- [License](LICENSE) - [License](LICENSE)
- [CI Status](#ci-status) - [CI Status](#ci-status)
- [Development Tutorial](#development-tutorial)
--- ---
...@@ -56,7 +56,7 @@ network using one unified controller. ...@@ -56,7 +56,7 @@ network using one unified controller.
## Example ## Example
A simple showcase how the controller can be adressed after A simple showcase how the controller can be addressed after
`make containerlab-start` is shown below: `make containerlab-start` is shown below:
![](gosdn-cli-showcase.webm) ![](gosdn-cli-showcase.webm)
...@@ -68,7 +68,7 @@ A simple showcase how the controller can be adressed after ...@@ -68,7 +68,7 @@ A simple showcase how the controller can be adressed after
- The `cli` is the CLI to manage the `controller`. - The `cli` is the CLI to manage the `controller`.
- `csbi` is the implementation of Containerised-Southbound-Interfaces (based on - `csbi` is the implementation of Containerised-Southbound-Interfaces (based on
the idea and the proof of concept of Manuel Kieweg). Allowing to request the idea and the proof of concept of Manuel Kieweg). Allowing to request
capabilities of MNEs and generate a containerised Southbound-Interface based capabilities of MNEs and generate a containerized Southbound-Interface based
on them. They are currently unsupported. on them. They are currently unsupported.
- `controller` represents the `goSDN-controller`. - `controller` represents the `goSDN-controller`.
...@@ -96,7 +96,7 @@ Any network element directly configured by `goSDN` ...@@ -96,7 +96,7 @@ Any network element directly configured by `goSDN`
## Launch goSDN Controller local ## Launch goSDN Controller local
In this chapter, you learn how to launch the goSDN controller. In this chapter, you learn how to launch the goSDN controller.
Firstly, make sure that you're located in the root directory of gosdn. Firstly, make sure that you're located in the root directory of goSDN.
`goSDN` provides a `Makefile` for all common use cases. `goSDN` provides a `Makefile` for all common use cases.
```sh ```sh
...@@ -125,7 +125,7 @@ running `./gosdn` from the shell: ...@@ -125,7 +125,7 @@ running `./gosdn` from the shell:
## Getting Started ## Getting Started
If you want to use the the [playground](#playground) you have to make sure you If you want to use the [playground](#playground) you have to make sure you
have [containerlab](https://containerlab.dev/install/) installed on your have [containerlab](https://containerlab.dev/install/) installed on your
system. system.
...@@ -201,9 +201,9 @@ For the storage system: ...@@ -201,9 +201,9 @@ For the storage system:
For the event system (RabbitMQ broker): For the event system (RabbitMQ broker):
- `amqpprefix`: the URI prefix that is needed to connect to the RabbitMQ broker. - `amqpprefix`: the URI prefix that is needed to connect to the RabbitMQ broker.
- `amqphost`: ip adress of the broker - `amqphost`: IP address of the broker
- `amqpport`: port of the broker - `amqpport`: port of the broker
- `amqpuser`: user name of credentials to access the broker, default value is `guest` - `amqpuser`: username of credentials to access the broker, default value is `guest`
- `amqppassword`: user password of credentials to access the broker, default is `guest` - `amqppassword`: user password of credentials to access the broker, default is `guest`
For the plugin registry: For the plugin registry:
...@@ -300,3 +300,13 @@ To develop applications, we provide a framework that can be found [here](https:/ ...@@ -300,3 +300,13 @@ To develop applications, we provide a framework that can be found [here](https:/
The framework provides some basic code to easily set up the subscription to the event system of the controller, so that your application can get notified via the events published by the RabbitMQ server about information you would like to receive. This includes functions to register and subscribe to the used server. The information you receive includes changes on network elements like if a value of a YANG path changes or other changes like additions or deletions of entities. The framework provides some basic code to easily set up the subscription to the event system of the controller, so that your application can get notified via the events published by the RabbitMQ server about information you would like to receive. This includes functions to register and subscribe to the used server. The information you receive includes changes on network elements like if a value of a YANG path changes or other changes like additions or deletions of entities.
Examples where the application framework is used can be found [here](https://code.fbi.h-da.de/danet/gosdn/-/tree/master/applications). Examples where the application framework is used can be found [here](https://code.fbi.h-da.de/danet/gosdn/-/tree/master/applications).
## Integration tests
The integration tests are currently in its own folder named `integration-tests`, as they use a complete black box design.
The idea is to test as many of our code with as little tests as possible to get a "catch all" approach where a test may fail and hint for a problem, without really telling us what the problem is.
As of the nature of this project many people contribute only a small part and often don't have time to write good unit-tests.
Therefore, we simply want to make sure that a change doesn't break anything important.
There exists a `example_tests` folder where examples of using the `integrationTestUtils` are shown. Each test should use the appropriate set-up and tear-down/clean-up functions, so that each test operates independent of each other.
ARG GOLANG_VERSION=1.21 ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY ARG GITLAB_PROXY
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-alpine as builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-alpine as builder
WORKDIR /gosdn/ WORKDIR /gosdn/
......
ARG GOLANG_VERSION=1.21 ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY=code.fbi.h-da.de:443/danet/dependency_proxy/containers ARG GITLAB_PROXY=code.fbi.h-da.de:443/danet/dependency_proxy/containers
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm AS builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm AS builder
......
...@@ -137,7 +137,7 @@ func (v *VenvManager) CreateSDNConfigFile() error { ...@@ -137,7 +137,7 @@ func (v *VenvManager) CreateSDNConfigFile() error {
return nil return nil
} }
// getSDNConfigData gets the sDN configuration data. // getSDNConfigData gets the SDN configuration data.
func (v *VenvManager) getSDNConfigData() (*string, error) { func (v *VenvManager) getSDNConfigData() (*string, error) {
conn, err := v.createConnection() conn, err := v.createConnection()
if err != nil { if err != nil {
......
ARG GOLANG_VERSION=1.21 ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY ARG GITLAB_PROXY
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-alpine as builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-alpine as builder
WORKDIR /app/ WORKDIR /app/
......
...@@ -9,7 +9,7 @@ GOBUILD=$(GOCMD) build ...@@ -9,7 +9,7 @@ GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean GOCLEAN=$(GOCMD) clean
BINARY_NAME=gosdn BINARY_NAME=gosdn
# Tool Vesions # Tool Versions
GOTESTSUM_VERSION=v1.8.1 GOTESTSUM_VERSION=v1.8.1
MOCKERY_VERSION=v2.20.0 MOCKERY_VERSION=v2.20.0
GOCOVER_COBERTURA=v1.2.0 GOCOVER_COBERTURA=v1.2.0
...@@ -43,27 +43,11 @@ start-insecure: clean build ...@@ -43,27 +43,11 @@ start-insecure: clean build
unit-test: install-tools unit-test: install-tools
ENVIRONMENT=testing ./$(TOOLS_DIR)/gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -trimpath -coverprofile=coverage.out ENVIRONMENT=testing ./$(TOOLS_DIR)/gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -trimpath -coverprofile=coverage.out
controller-test: install-tools show-unit-test-coverage: unit-test
ENVIRONMENT=testing ./$(TOOLS_DIR)/gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun go tool cover -html=coverage.out
ci-unit-test: ci-install-tools ci-unit-test: ci-install-tools
ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -trimpath -coverprofile=coverage.out -covermode atomic -timeout 30m ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -trimpath -coverprofile=coverage.out -covermode atomic -timeout 30m
ci-controller-test: ci-install-tools
ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun -trimpath -coverprofile=coverage.out
integration-test-nucleus:
ENVIRONMENT=testing &&\
cd ./test/integration &&\
go test -race -v -run TestGnmi_SetIntegration &&\
go test -race -v -run TestGnmi_GetIntegration &&\
go test -race -v -run TestGnmi_SubscribeIntegration &&\
go test -race -v -run TestGnmi_CapabilitiesIntegration
integration-test-api:
ENVIRONMENT=testing &&\
cd ./api &&\
go test -race -v -run TestApiIntegration
generate-mocks: install-tools generate-mocks: install-tools
./$(TOOLS_DIR)/mockery --all --dir "./interfaces/" ./$(TOOLS_DIR)/mockery --all --dir "./interfaces/"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment