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

Merge branch '124-access-to-scrampled-ports-not-working' into 'develop'

Draft: Resolve "Access to scrambled ports not working"

See merge request cocsn/gosdn!165
parents f803010d 6dd43834
No related branches found
No related tags found
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,!165Resolve "Access to scrambled ports not working",!138Develop
Pipeline #75348 failed
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
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 = testIP + ":" + testPort var testAddress = "141.100.70.170: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,16 +29,16 @@ func TestMain(m *testing.M) { ...@@ -29,16 +29,16 @@ func TestMain(m *testing.M) {
} }
func testSetupIntegration() { func testSetupIntegration() {
viper.SetConfigFile(".k8s.toml")
if err := viper.ReadInConfig(); err != nil {
log.Error(err)
}
if os.Getenv("GOSDN_LOG") == "nolog" { if os.Getenv("GOSDN_LOG") == "nolog" {
log.SetLevel(log.PanicLevel) log.SetLevel(log.PanicLevel)
} }
api := viper.GetString("GOSDN_TEST_API_ENDPOINT") addr := os.Getenv("GOSDN_TEST_ENDPOINT")
if addr != "" {
testAddress = addr
log.Infof("GOSDN_TEST_ENDPOINT set to %v", testAddress)
}
api := os.Getenv("GOSDN_TEST_API_ENDPOINT")
if api != "" { if api != "" {
testAPIEndpoint = api testAPIEndpoint = api
log.Infof("GOSDN_TEST_API_ENDPOINT set to %v", testAPIEndpoint) log.Infof("GOSDN_TEST_API_ENDPOINT set to %v", testAPIEndpoint)
......
services:
- name: docker:19.03.12-dind
command: ["--registry-mirror", "http://141.100.70.170:6000"]
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
DOCKER_IMAGE_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA DOCKER_IMAGE_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
...@@ -11,6 +7,10 @@ variables: ...@@ -11,6 +7,10 @@ variables:
before_script: before_script:
- echo "override global before script" - echo "override global before script"
image: docker:19.03.12 image: docker:19.03.12
services:
- name: docker:19.03.12-dind
command: ["--registry-mirror", "http://141.100.70.170:6000", "--dns", "1.1.1.1"]
stage: build stage: build
tags: tags:
- dind - dind
......
variables: variables:
TF_ROOT: ${CI_PROJECT_DIR}/test/terraform TF_ROOT: ${CI_PROJECT_DIR}/test/terraform
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/${CI_PIPELINE_ID}
cache: cache:
key: ${CI_PIPELINE_ID} key: ${CI_PIPELINE_ID}
...@@ -13,7 +13,8 @@ cache: ...@@ -13,7 +13,8 @@ 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 - ./build/ci/generate_octet.sh $CI_COMMIT_SHA >> ${TF_ROOT}/firstOctet
- ./build/ci/generate_octet.sh $CI_PIPELINE_ID >> ${TF_ROOT}/secondOctet
- 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}
...@@ -21,7 +22,8 @@ cache: ...@@ -21,7 +22,8 @@ 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}
- export TF_VAR_ceos_address=172.24.$(cat firstOctet).$(cat secondOctet)
- export TF_VAR_gosdn_address=172.24.$(cat secondOctet).$(cat firstOctet)
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,8 +7,6 @@ ...@@ -7,8 +7,6 @@
variables: variables:
GOSDN_LOG: "nolog" GOSDN_LOG: "nolog"
GOSDN_TEST_API_ENDPOINT: gosdn-$CI_COMMIT_SHA.apps.ocp.fbi.h-da.de
GOSDN_TEST_ENDPOINT_IP: 141.100.70.171
GOSDN_CHANGE_TIMEOUT: "100ms" GOSDN_CHANGE_TIMEOUT: "100ms"
rules: rules:
- if: $CI_NIGHTLY - if: $CI_NIGHTLY
...@@ -25,8 +23,9 @@ ...@@ -25,8 +23,9 @@
integration-test:nucleus: integration-test:nucleus:
<<: *integration-test <<: *integration-test
script: script:
- ./build/ci/generate_port.sh $CI_PIPELINE_ID >> port - ./build/ci/generate_octet.bash $CI_COMMIT_SHA >> firstOctet
- export GOSDN_TEST_ENDPOINT_PORT=$(cat port) - ./build/ci/generate_octet.bash $CI_PIPELINE_ID >> secondOctet
- export GOSDN_TEST_ENDPOINT=172.24.$(cat firstOctet).$(cat secondOctet):6030
- cd ./test/integration - cd ./test/integration
- go test -race -v -run TestGnmi_SetIntegration - go test -race -v -run TestGnmi_SetIntegration
- go test -race -v -run TestGnmi_GetIntegration - go test -race -v -run TestGnmi_GetIntegration
...@@ -44,6 +43,9 @@ integration-test:api: ...@@ -44,6 +43,9 @@ integration-test:api:
- job: "build:k8s-bot" - job: "build:k8s-bot"
artifacts: true artifacts: true
script: script:
- ./build/ci/generate_octet.bash $CI_COMMIT_SHA >> firstOctet
- ./build/ci/generate_octet.bash $CI_PIPELINE_ID >> secondOctet
- export GOSDN_TEST_API_ENDPOINT=172.24.$(cat secondOctet).$(cat firstOctet):55055
- cd ./api - cd ./api
- go test -race -v -run TestApiIntegration - go test -race -v -run TestApiIntegration
......
...@@ -8,7 +8,6 @@ hashed_value=$(echo $input | sha256sum | awk '{print $1}' ) ...@@ -8,7 +8,6 @@ hashed_value=$(echo $input | sha256sum | awk '{print $1}' )
decimal_value=$((16#$hashed_value)) decimal_value=$((16#$hashed_value))
decimal_value=${decimal_value/-/} decimal_value=${decimal_value/-/}
port=$(((decimal_value % 10000)+50000)) octet=$(((decimal_value % 255)))
#echo -n $(($port*1)) echo -n $octet
echo -n $port \ No newline at end of file
\ No newline at end of file
...@@ -8,7 +8,6 @@ hashed_value=$(echo $input | sha256sum | awk '{print $1}' ) ...@@ -8,7 +8,6 @@ hashed_value=$(echo $input | sha256sum | awk '{print $1}' )
decimal_value=$((16#$hashed_value)) decimal_value=$((16#$hashed_value))
decimal_value=${decimal_value/-/} decimal_value=${decimal_value/-/}
port=$(((decimal_value % 10000)+50000)) octet=$(((decimal_value % 255)))
#echo -n $(($port*1)) echo -n $octet
echo -n $port \ No newline at end of file
\ No newline at end of file
...@@ -2,7 +2,6 @@ package integration ...@@ -2,7 +2,6 @@ package integration
import ( import (
"context" "context"
"fmt"
"os" "os"
"reflect" "reflect"
"sort" "sort"
...@@ -25,10 +24,7 @@ import ( ...@@ -25,10 +24,7 @@ import (
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 testIP = "141.100.70.171" var testAddress = "141.100.70.170:6030"
var testPort = "6030"
var testAddress = testIP + ":" + testPort
var testAPIEndpoint = "gosdn-latest.apps.ocp.fbi.h-da.de"
var testUsername = "admin" var testUsername = "admin"
var testPassword = "arista" var testPassword = "arista"
var opt *tpb.TransportOption var opt *tpb.TransportOption
...@@ -44,23 +40,10 @@ func testSetupIntegration() { ...@@ -44,23 +40,10 @@ func testSetupIntegration() {
log.SetLevel(log.PanicLevel) log.SetLevel(log.PanicLevel)
} }
a := os.Getenv("GOSDN_TEST_ENDPOINT_IP") addr := os.Getenv("GOSDN_TEST_ENDPOINT")
if a != "" { if addr != "" {
testIP = a testAddress = addr
log.Infof("GOSDN_TEST_ENDPOINT_IP set to %v", testIP) log.Infof("GOSDN_TEST_ENDPOINT set to %v", testAddress)
}
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
log.Infof("GOSDN_TEST_API_ENDPOINT set to %v", testAPIEndpoint)
} }
u := os.Getenv("GOSDN_TEST_USER") u := os.Getenv("GOSDN_TEST_USER")
if u != "" { if u != "" {
......
...@@ -6,17 +6,9 @@ resource "docker_container" "gosdn" { ...@@ -6,17 +6,9 @@ resource "docker_container" "gosdn" {
restart = "always" restart = "always"
networks_advanced { networks_advanced {
name = "bridge" name = "ci"
ipv4_address = var.gosdn_address
} }
ports {
internal = 8080
external = 8080
}
}
data "local_file" "port" {
filename = "port"
} }
# create arista container # create arista container
...@@ -26,13 +18,9 @@ resource "docker_container" "ceos" { ...@@ -26,13 +18,9 @@ resource "docker_container" "ceos" {
image = docker_image.ceos.name image = docker_image.ceos.name
restart = "always" restart = "always"
ports {
internal = 6030
external = data.local_file.port.content
}
networks_advanced { networks_advanced {
name = "bridge" name = "ci"
ipv4_address = var.ceos_address
} }
command = ["/sbin/init", command = ["/sbin/init",
......
...@@ -29,4 +29,12 @@ variable "container_tag" { ...@@ -29,4 +29,12 @@ variable "container_tag" {
variable "network_name" { variable "network_name" {
type = string type = string
default = "" default = ""
}
variable "ceos_address" {
type = string
}
variable "gosdn_address" {
type = string
} }
\ 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