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

code backup

parent 030bfc5b
No related branches found
No related tags found
1 merge request!691Resolve "Implement integration tests for applications"
This commit is part of merge request !691. Comments created here will be created in the context of that merge request.
...@@ -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,57 @@ func cleanRolesExceptAdmin(resp *apb.GetRolesResponse, roleService apb.RoleServi ...@@ -192,3 +193,57 @@ 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{
// "-X", "DELETE",
// "-u", "guest:guest",
// "http://" + rabbitMQAddress + ":15672/api/queues/%2f/" + queue,
// "--write-out", "%{http_code}",
// }
// cmd := exec.Command("curl", args...)
// cmd.Stdout = os.Stdout
// cmd.Stderr = os.Stderr
// err := cmd.Run()
// if err != nil {
// logrus.Info(err)
// }
// }
// -i -u guest:guest -H "content-type:application/json" -X POST http://127.0.0.1:15672/api/queues/foo/get -d '{"count":5,"requeue":true,"encoding":"auto","truncate":50000}'
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_true\"}",
}
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