Skip to content
Snippets Groups Projects
Commit 96775e09 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Merge branch...

Merge branch '112-improve-test-environment-to-use-seperate-ceos-instance-for-each-pipeline' into 'develop'

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

See merge request cocsn/gosdn!148
parents 8bf70e08 6ab9121c
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
Pipeline #74999 passed
......@@ -33,4 +33,4 @@ linters:
issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
\ No newline at end of file
max-same-issues: 0
......@@ -4,7 +4,7 @@ variables:
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/integration
cache:
key: integration
key: ${CI_PIPELINE_ID}
paths:
- ${TF_ROOT}/.terraform
......@@ -13,6 +13,7 @@ cache:
variables:
CI_DEBUG_TRACE: "false"
before_script:
- ./build/ci/generate_port2.sh $CI_PIPELINE_ID >> ${TF_ROOT}/port
- cd ${TF_ROOT}
- export TF_VAR_integration_username=terraform
- export TF_VAR_integration_access_token=${TERRAFORM_API_TOKEN}
......@@ -20,6 +21,7 @@ cache:
- export TF_VAR_tls_key=${DOCKER_TLS_KEY}
- export TF_VAR_tls_cert=${DOCKER_TLS_CERT}
- export TF_VAR_tls_ca_cert=${DOCKER_TLS_CA}
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop')
variables:
......
......@@ -7,6 +7,8 @@ integration-test:
variables:
GOSDN_LOG: "nolog"
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:
- if: $CI_NIGHTLY
when: delayed
......@@ -19,6 +21,8 @@ integration-test:
when: delayed
start_in: 2 minutes
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
.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
import (
"os"
"testing"
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/nucleus/util/proto"
"fmt"
guuid "github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
pb "google.golang.org/protobuf/proto"
"os"
"testing"
)
const unreachable = "203.0.113.10:6030"
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 testUsername = "admin"
var testPassword = "arista"
......@@ -34,11 +35,19 @@ func testSetupIntegration() {
log.SetLevel(log.PanicLevel)
}
a := os.Getenv("GOSDN_TEST_ENDPOINT")
a := os.Getenv("GOSDN_TEST_ENDPOINT_IP")
if a != "" {
testAddress = a
log.Infof("GOSDN_TEST_ENDPOINT set to %v", testAddress)
testIP = a
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")
if api != "" {
testAPIEndpoint = api
......
......@@ -15,6 +15,10 @@ resource "docker_container" "gosdn" {
}
}
data "local_file" "port" {
filename = "port"
}
# create arista container
# namespace is french cheeses
resource "docker_container" "ceos" {
......@@ -24,7 +28,7 @@ resource "docker_container" "ceos" {
ports {
internal = 6030
external = 6030
external = data.local_file.port.content
}
networks_advanced {
......
terraform {
backend "http" {
}
required_providers {
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" {
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