Skip to content
Snippets Groups Projects
Commit 6ab9121c authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark Committed by Manuel Kieweg
Browse files

Resolve "Improve test environment to use seperate ceos instance for each pipeline"

parent 8bf70e08
Branches
Tags
9 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!195DO NOT MERGE 2,!194DO NOT MERGE! just for testing,!148Resolve "Improve test environment to use seperate ceos instance for each pipeline",!138Develop
...@@ -33,4 +33,4 @@ linters: ...@@ -33,4 +33,4 @@ linters:
issues: issues:
exclude-use-default: false exclude-use-default: false
max-issues-per-linter: 0 max-issues-per-linter: 0
max-same-issues: 0 max-same-issues: 0
\ No newline at end of file
...@@ -4,7 +4,7 @@ variables: ...@@ -4,7 +4,7 @@ variables:
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/integration TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/integration
cache: cache:
key: integration key: ${CI_PIPELINE_ID}
paths: paths:
- ${TF_ROOT}/.terraform - ${TF_ROOT}/.terraform
...@@ -13,6 +13,7 @@ cache: ...@@ -13,6 +13,7 @@ cache:
variables: variables:
CI_DEBUG_TRACE: "false" CI_DEBUG_TRACE: "false"
before_script: before_script:
- ./build/ci/generate_port2.sh $CI_PIPELINE_ID >> ${TF_ROOT}/port
- cd ${TF_ROOT} - cd ${TF_ROOT}
- export TF_VAR_integration_username=terraform - export TF_VAR_integration_username=terraform
- export TF_VAR_integration_access_token=${TERRAFORM_API_TOKEN} - export TF_VAR_integration_access_token=${TERRAFORM_API_TOKEN}
...@@ -20,6 +21,7 @@ cache: ...@@ -20,6 +21,7 @@ cache:
- export TF_VAR_tls_key=${DOCKER_TLS_KEY} - export TF_VAR_tls_key=${DOCKER_TLS_KEY}
- export TF_VAR_tls_cert=${DOCKER_TLS_CERT} - export TF_VAR_tls_cert=${DOCKER_TLS_CERT}
- export TF_VAR_tls_ca_cert=${DOCKER_TLS_CA} - export TF_VAR_tls_ca_cert=${DOCKER_TLS_CA}
rules: rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop') - if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop')
variables: variables:
......
...@@ -7,6 +7,8 @@ integration-test: ...@@ -7,6 +7,8 @@ integration-test:
variables: variables:
GOSDN_LOG: "nolog" GOSDN_LOG: "nolog"
GOSDN_TEST_API_ENDPOINT: http://gosdn-$CI_COMMIT_SHA.apps.ocp.fbi.h-da.de/api GOSDN_TEST_API_ENDPOINT: http://gosdn-$CI_COMMIT_SHA.apps.ocp.fbi.h-da.de/api
GOSDN_TEST_ENDPOINT_IP: 141.100.70.171
GOSDN_CHANGE_TIMEOUT: "100ms"
rules: rules:
- if: $CI_NIGHTLY - if: $CI_NIGHTLY
when: delayed when: delayed
...@@ -19,6 +21,8 @@ integration-test: ...@@ -19,6 +21,8 @@ integration-test:
when: delayed when: delayed
start_in: 2 minutes start_in: 2 minutes
script: script:
- ./build/ci/generate_port.sh $CI_PIPELINE_ID >> port
- export GOSDN_TEST_ENDPOINT_PORT=$(cat port)
- go test -race ./test/integration -v -coverprofile=coverage.out - go test -race ./test/integration -v -coverprofile=coverage.out
.test: &test .test: &test
......
#!/bin/bash
input=$1
#trailing_backspace=$2
hashed_value=$(echo $input | sha256sum | awk '{print $1}' )
decimal_value=$((16#$hashed_value))
decimal_value=${decimal_value/-/}
port=$(((decimal_value % 10000)+50000))
#echo -n $(($port*1))
echo -n $port
\ No newline at end of file
#!/bin/sh
input=$1
#trailing_backspace=$2
hashed_value=$(echo $input | sha256sum | awk '{print $1}' )
decimal_value=$((16#$hashed_value))
decimal_value=${decimal_value/-/}
port=$(((decimal_value % 10000)+50000))
#echo -n $(($port*1))
echo -n $port
\ No newline at end of file
package integration package integration
import ( import (
"os"
"testing"
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport" tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"code.fbi.h-da.de/cocsn/gosdn/api" "code.fbi.h-da.de/cocsn/gosdn/api"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto" "code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto"
"fmt"
guuid "github.com/google/uuid" guuid "github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi" gpb "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"
pb "google.golang.org/protobuf/proto" pb "google.golang.org/protobuf/proto"
"os"
"testing"
) )
const unreachable = "203.0.113.10:6030" const unreachable = "203.0.113.10:6030"
const testPath = "/system/config/hostname" const testPath = "/system/config/hostname"
var testAddress = "141.100.70.171:6030" var testIP = "141.100.70.171"
var testPort = "6030"
var testAddress = testIP + ":" + testPort
var testAPIEndpoint = "http://gosdn-latest.apps.ocp.fbi.h-da.de/api" var testAPIEndpoint = "http://gosdn-latest.apps.ocp.fbi.h-da.de/api"
var testUsername = "admin" var testUsername = "admin"
var testPassword = "arista" var testPassword = "arista"
...@@ -34,11 +35,19 @@ func testSetupIntegration() { ...@@ -34,11 +35,19 @@ func testSetupIntegration() {
log.SetLevel(log.PanicLevel) log.SetLevel(log.PanicLevel)
} }
a := os.Getenv("GOSDN_TEST_ENDPOINT") a := os.Getenv("GOSDN_TEST_ENDPOINT_IP")
if a != "" { if a != "" {
testAddress = a testIP = a
log.Infof("GOSDN_TEST_ENDPOINT set to %v", testAddress) log.Infof("GOSDN_TEST_ENDPOINT_IP set to %v", testIP)
} }
port := os.Getenv("GOSDN_TEST_ENDPOINT_PORT")
if port != "" {
testPort = port
log.Infof("GOSDN_TEST_ENDPOINT_PORT set to %v", testPort)
}
testAddress = testIP + ":" + testPort
fmt.Printf("Testadress: %s, Testport: %s, Port: %s", testAddress, testPort, port)
api := os.Getenv("GOSDN_TEST_API_ENDPOINT") api := os.Getenv("GOSDN_TEST_API_ENDPOINT")
if api != "" { if api != "" {
testAPIEndpoint = api testAPIEndpoint = api
......
...@@ -15,6 +15,10 @@ resource "docker_container" "gosdn" { ...@@ -15,6 +15,10 @@ resource "docker_container" "gosdn" {
} }
} }
data "local_file" "port" {
filename = "port"
}
# create arista container # create arista container
# namespace is french cheeses # namespace is french cheeses
resource "docker_container" "ceos" { resource "docker_container" "ceos" {
...@@ -24,7 +28,7 @@ resource "docker_container" "ceos" { ...@@ -24,7 +28,7 @@ resource "docker_container" "ceos" {
ports { ports {
internal = 6030 internal = 6030
external = 6030 external = data.local_file.port.content
} }
networks_advanced { networks_advanced {
......
terraform { terraform {
backend "http" { backend "http" {
} }
required_providers { required_providers {
docker = { docker = {
source = "kreuzwerker/docker" source = "kreuzwerker/docker"
......
resource "docker_network" "danet_legacy" {
name = "legacy-${random_id.server.hex}"
ipam_config {
subnet = "172.100.100.0/24"
}
}
resource "docker_network" "danet" {
name = "danet-${random_id.server.hex}"
ipv6 = true
ipam_config {
subnet = "fdfe::/64"
}
}
\ No newline at end of file
resource "random_id" "server" { resource "random_id" "server" {
byte_length = 8 byte_length = 8
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment