Skip to content
Snippets Groups Projects
Commit 030bfc5b authored by Fabian Seidl's avatar Fabian Seidl
Browse files

add envvar for rabbitmq in ci tests

parent a3cb8b8a
Branches
Tags
1 merge request!691Resolve "Implement integration tests for applications"
Pipeline #178082 passed
......@@ -10,6 +10,7 @@ integration-test-gosdn:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
INTEGRATION_TEST_TARGET_A: gnmi-target_A:7030
RABBITMQ: rabbitmq
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/mongo:5
alias: mongo
......
......@@ -4,6 +4,7 @@ import (
"context"
"os"
"os/signal"
"strings"
"syscall"
"code.fbi.h-da.de/danet/gosdn/application-framework/event"
......@@ -12,6 +13,8 @@ import (
"google.golang.org/grpc"
)
const localhost = "127.0.0.1"
// Application is an example for a sdn application.
type Application struct {
eventService event.ServiceInterface
......@@ -20,14 +23,16 @@ type Application struct {
eventChannel chan event.Event
}
func NewApplication(ctx context.Context, grpcClientConn *grpc.ClientConn, controllerAddress string, topics []event.Topic) *Application {
func NewApplication(ctx context.Context, grpcClientConn *grpc.ClientConn, controllerAddress string, topics []event.Topic, rabbitMQAddress string) *Application {
queueCredentials, err := registration.Register(ctx, controllerAddress, "integration-test-application", "SecurePresharedToken")
if err != nil {
logrus.Errorf("failed to register application on control plane. %v", err)
os.Exit(1)
}
queueCredentials = "amqp://guest:guest@rabbitmq:5672"
if rabbitMQAddress != "" {
queueCredentials = strings.ReplaceAll(queueCredentials, localhost, rabbitMQAddress)
}
logrus.Infof("QUEUE CREDENTIALS: %v", queueCredentials)
......
......@@ -3,6 +3,7 @@ package integration_test_application
import (
"context"
"fmt"
"os"
"testing"
mnepb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement"
......@@ -47,7 +48,14 @@ func TestMain(m *testing.M) {
integration_test_utils.ApplySDNConfig(conn, ctx, defaultSDNConfig)
topics := []event.Topic{event.ManagedNetworkElement, event.User}
application = NewApplication(ctx, conn, ":55055", topics)
rabbitMQAddress := ""
envVarRabbitmq := os.Getenv("RABBITMQ")
if envVarRabbitmq != "" {
rabbitMQAddress = envVarRabbitmq
}
application = NewApplication(ctx, conn, ":55055", topics, rabbitMQAddress)
eventTypeCallbackTuples := []event.TypeToCallbackTuple{
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment