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

check ci tests with rabbit clearing

parent b72080b6
No related branches found
No related tags found
1 merge request!691Resolve "Implement integration tests for applications"
Pipeline #178313 failed
This commit is part of merge request !691. Comments created here will be created in the context of that merge request.
...@@ -99,6 +99,8 @@ func TestMain(m *testing.M) { ...@@ -99,6 +99,8 @@ func TestMain(m *testing.M) {
if os.Getenv("RABBITMQ") == "" { if os.Getenv("RABBITMQ") == "" {
_ = <-application.eventChannel _ = <-application.eventChannel
_ = <-application.eventChannel _ = <-application.eventChannel
} else {
integration_test_utils.ClearRabbitMQQueues()
} }
m.Run() m.Run()
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"os/exec"
"time" "time"
configMgmtPb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/configurationmanagement" configMgmtPb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/configurationmanagement"
...@@ -192,3 +193,38 @@ func cleanRolesExceptAdmin(resp *apb.GetRolesResponse, roleService apb.RoleServi ...@@ -192,3 +193,38 @@ func cleanRolesExceptAdmin(resp *apb.GetRolesResponse, roleService apb.RoleServi
return nil return nil
} }
func ClearRabbitMQQueues() {
rabbitMQAddress := "localhost"
envVarRabbitmq := os.Getenv("RABBITMQ")
if envVarRabbitmq != "" {
rabbitMQAddress = envVarRabbitmq
}
// add more queue names if necessary
queues := []string{
"user",
"role",
"managedNetworkElement",
}
for _, queue := range queues {
args := []string{
"-i",
"-u", "guest:guest",
"-H", "\"content-type:application/json\"",
"-X", "POST",
"http://" + rabbitMQAddress + ":15672/api/queues/%2f/" + queue + "/get",
"-d", "{\"count\":10,\"encoding\":\"auto\",\"truncate\":50000,\"ackmode\":\"ack_requeue_false\"}",
}
cmd := exec.Command("curl", args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
logrus.Info(err)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment