mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-02 03:00:41 +00:00
Exported test utils functions (#866)
Co-authored-by: Igor Gov <iggvrv@gmail.com>
This commit is contained in:
@@ -23,19 +23,19 @@ func TestConfigRegenerate(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configCmdArgs := getDefaultConfigCommandArgs()
|
configCmdArgs := GetDefaultConfigCommandArgs()
|
||||||
|
|
||||||
configCmdArgs = append(configCmdArgs, "-r")
|
configCmdArgs = append(configCmdArgs, "-r")
|
||||||
|
|
||||||
@@ -74,13 +74,13 @@ func TestConfigGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPort := range tests {
|
for _, guiPort := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
@@ -100,16 +100,16 @@ func TestConfigGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +123,9 @@ func TestConfigGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPort)
|
apiServerUrl := GetApiServerUrl(guiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -147,13 +147,13 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPortStruct := range tests {
|
for _, guiPortStruct := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPortStruct.SetGuiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPortStruct.SetGuiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
@@ -173,9 +173,9 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--set", fmt.Sprintf("tap.gui-port=%v", guiPortStruct.SetGuiPort))
|
tapCmdArgs = append(tapCmdArgs, "--set", fmt.Sprintf("tap.gui-port=%v", guiPortStruct.SetGuiPort))
|
||||||
@@ -184,7 +184,7 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,9 +198,9 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPortStruct.SetGuiPort)
|
apiServerUrl := GetApiServerUrl(guiPortStruct.SetGuiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -222,13 +222,13 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPortStruct := range tests {
|
for _, guiPortStruct := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPortStruct.FlagGuiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPortStruct.FlagGuiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
@@ -248,9 +248,9 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%v", guiPortStruct.FlagGuiPort))
|
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%v", guiPortStruct.FlagGuiPort))
|
||||||
@@ -259,7 +259,7 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,9 +273,9 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPortStruct.FlagGuiPort)
|
apiServerUrl := GetApiServerUrl(guiPortStruct.FlagGuiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -15,22 +15,22 @@ func TestRedis(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -40,16 +40,16 @@ func TestRedis(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
redisExternalIp, err := getServiceExternalIp(ctx, defaultNamespaceName, "redis")
|
redisExternalIp, err := GetServiceExternalIp(ctx, defaultNamespaceName, "redis")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to get redis external ip, err: %v", err)
|
t.Errorf("failed to get redis external ip, err: %v", err)
|
||||||
return
|
return
|
||||||
@@ -99,7 +99,7 @@ func TestRedis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redis.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redis.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAmqp(t *testing.T) {
|
func TestAmqp(t *testing.T) {
|
||||||
@@ -107,22 +107,22 @@ func TestAmqp(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -132,16 +132,16 @@ func TestAmqp(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
rabbitmqExternalIp, err := getServiceExternalIp(ctx, defaultNamespaceName, "rabbitmq")
|
rabbitmqExternalIp, err := GetServiceExternalIp(ctx, defaultNamespaceName, "rabbitmq")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to get RabbitMQ external ip, err: %v", err)
|
t.Errorf("failed to get RabbitMQ external ip, err: %v", err)
|
||||||
return
|
return
|
||||||
@@ -224,5 +224,5 @@ func TestAmqp(t *testing.T) {
|
|||||||
ch.Close()
|
ch.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Rabbit.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Rabbit.js\"")
|
||||||
}
|
}
|
||||||
|
@@ -11,22 +11,22 @@ func TestLogs(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -36,14 +36,14 @@ func TestLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logsCmdArgs := getDefaultLogsCommandArgs()
|
logsCmdArgs := GetDefaultLogsCommandArgs()
|
||||||
|
|
||||||
logsCmd := exec.Command(cliPath, logsCmdArgs...)
|
logsCmd := exec.Command(cliPath, logsCmdArgs...)
|
||||||
t.Logf("running command: %v", logsCmd.String())
|
t.Logf("running command: %v", logsCmd.String())
|
||||||
@@ -58,7 +58,7 @@ func TestLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logsPath, logsPathErr := getLogsPath()
|
logsPath, logsPathErr := GetLogsPath()
|
||||||
if logsPathErr != nil {
|
if logsPathErr != nil {
|
||||||
t.Errorf("failed to get logs path, err: %v", logsPathErr)
|
t.Errorf("failed to get logs path, err: %v", logsPathErr)
|
||||||
return
|
return
|
||||||
@@ -112,22 +112,22 @@ func TestLogsPath(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -137,14 +137,14 @@ func TestLogsPath(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logsCmdArgs := getDefaultLogsCommandArgs()
|
logsCmdArgs := GetDefaultLogsCommandArgs()
|
||||||
|
|
||||||
logsPath := "../logs.zip"
|
logsPath := "../logs.zip"
|
||||||
logsCmdArgs = append(logsCmdArgs, "-f", logsPath)
|
logsCmdArgs = append(logsCmdArgs, "-f", logsPath)
|
||||||
|
@@ -22,22 +22,22 @@ func TestTap(t *testing.T) {
|
|||||||
|
|
||||||
for _, entriesCount := range tests {
|
for _, entriesCount := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", entriesCount), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", entriesCount), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -47,16 +47,16 @@ func TestTap(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
for i := 0; i < entriesCount; i++ {
|
for i := 0; i < entriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -71,9 +71,9 @@ func TestTap(t *testing.T) {
|
|||||||
for i := 0; i < len(expectedPods); i++ {
|
for i := 0; i < len(expectedPods); i++ {
|
||||||
expectedPodsStr += fmt.Sprintf("Name:%vNamespace:%v", expectedPods[i].Name, expectedPods[i].Namespace)
|
expectedPodsStr += fmt.Sprintf("Name:%vNamespace:%v", expectedPods[i].Name, expectedPods[i].Namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldCheckSrcAndDest = false
|
const shouldCheckSrcAndDest = false
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d,arrayDict=%v,shouldCheckSrcAndDest=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d,arrayDict=%v,shouldCheckSrcAndDest=%v",
|
||||||
entriesCount, expectedPodsStr, shouldCheckSrcAndDest))
|
entriesCount, expectedPodsStr, shouldCheckSrcAndDest))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -88,15 +88,15 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPort := range tests {
|
for _, guiPort := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%d", guiPort))
|
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%d", guiPort))
|
||||||
@@ -105,7 +105,7 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -115,22 +115,22 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPort)
|
apiServerUrl := GetApiServerUrl(guiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/GuiPort.js\" --env name=%v,namespace=%v,port=%d",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/GuiPort.js\" --env name=%v,namespace=%v,port=%d",
|
||||||
"httpbin", "mizu-tests", guiPort))
|
"httpbin", "mizu-tests", guiPort))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -147,20 +147,20 @@ func TestTapAllNamespaces(t *testing.T) {
|
|||||||
{Name: "httpbin", Namespace: "mizu-tests2"},
|
{Name: "httpbin", Namespace: "mizu-tests2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
tapCmdArgs = append(tapCmdArgs, "-A")
|
tapCmdArgs = append(tapCmdArgs, "-A")
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -170,14 +170,14 @@ func TestTapAllNamespaces(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
||||||
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,13 +192,13 @@ func TestTapMultipleNamespaces(t *testing.T) {
|
|||||||
{Name: "httpbin", Namespace: "mizu-tests2"},
|
{Name: "httpbin", Namespace: "mizu-tests2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
var namespacesCmd []string
|
var namespacesCmd []string
|
||||||
for _, expectedPod := range expectedPods {
|
for _, expectedPod := range expectedPods {
|
||||||
namespacesCmd = append(namespacesCmd, "-n", expectedPod.Namespace)
|
namespacesCmd = append(namespacesCmd, "-n", expectedPod.Namespace)
|
||||||
@@ -209,7 +209,7 @@ func TestTapMultipleNamespaces(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -219,14 +219,14 @@ func TestTapMultipleNamespaces(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
||||||
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,22 +240,22 @@ func TestTapRegex(t *testing.T) {
|
|||||||
{Name: regexPodName, Namespace: "mizu-tests"},
|
{Name: regexPodName, Namespace: "mizu-tests"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgsWithRegex(regexPodName)
|
tapCmdArgs := GetDefaultTapCommandArgsWithRegex(regexPodName)
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -265,14 +265,14 @@ func TestTapRegex(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/Regex.js\" --env name=%v,namespace=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/Regex.js\" --env name=%v,namespace=%v",
|
||||||
expectedPods[0].Name, expectedPods[0].Namespace))
|
expectedPods[0].Name, expectedPods[0].Namespace))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,15 +281,15 @@ func TestTapDryRun(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--dry-run")
|
tapCmdArgs = append(tapCmdArgs, "--dry-run")
|
||||||
@@ -328,22 +328,22 @@ func TestTapRedact(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -353,24 +353,24 @@ func TestTapRedact(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
||||||
requestBody := map[string]string{"User": "Mizu"}
|
requestBody := map[string]string{"User": "Mizu"}
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
if _, requestErr := ExecuteHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redact.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redact.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTapNoRedact(t *testing.T) {
|
func TestTapNoRedact(t *testing.T) {
|
||||||
@@ -378,15 +378,15 @@ func TestTapNoRedact(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--no-redact")
|
tapCmdArgs = append(tapCmdArgs, "--no-redact")
|
||||||
@@ -395,7 +395,7 @@ func TestTapNoRedact(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -405,24 +405,24 @@ func TestTapNoRedact(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
||||||
requestBody := map[string]string{"User": "Mizu"}
|
requestBody := map[string]string{"User": "Mizu"}
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
if _, requestErr := ExecuteHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/NoRedact.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/NoRedact.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTapRegexMasking(t *testing.T) {
|
func TestTapRegexMasking(t *testing.T) {
|
||||||
@@ -430,15 +430,15 @@ func TestTapRegexMasking(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "-r", "Mizu")
|
tapCmdArgs = append(tapCmdArgs, "-r", "Mizu")
|
||||||
@@ -447,7 +447,7 @@ func TestTapRegexMasking(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -457,23 +457,23 @@ func TestTapRegexMasking(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
response, requestErr := http.Post(fmt.Sprintf("%v/post", proxyUrl), "text/plain", bytes.NewBufferString("Mizu"))
|
response, requestErr := http.Post(fmt.Sprintf("%v/post", proxyUrl), "text/plain", bytes.NewBufferString("Mizu"))
|
||||||
if _, requestErr = executeHttpRequest(response, requestErr); requestErr != nil {
|
if _, requestErr = ExecuteHttpRequest(response, requestErr); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/RegexMasking.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/RegexMasking.js\"")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,15 +482,15 @@ func TestTapIgnoredUserAgents(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
ignoredUserAgentValue := "ignore"
|
ignoredUserAgentValue := "ignore"
|
||||||
@@ -500,7 +500,7 @@ func TestTapIgnoredUserAgents(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -510,32 +510,32 @@ func TestTapIgnoredUserAgents(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
|
|
||||||
ignoredUserAgentCustomHeader := "Ignored-User-Agent"
|
ignoredUserAgentCustomHeader := "Ignored-User-Agent"
|
||||||
headers := map[string]string{"User-Agent": ignoredUserAgentValue, ignoredUserAgentCustomHeader: ""}
|
headers := map[string]string{"User-Agent": ignoredUserAgentValue, ignoredUserAgentCustomHeader: ""}
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequestWithHeaders(fmt.Sprintf("%v/get", proxyUrl), headers); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequestWithHeaders(fmt.Sprintf("%v/get", proxyUrl), headers); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/IgnoredUserAgents.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/IgnoredUserAgents.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTapDumpLogs(t *testing.T) {
|
func TestTapDumpLogs(t *testing.T) {
|
||||||
@@ -543,15 +543,15 @@ func TestTapDumpLogs(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--set", "dump-logs=true")
|
tapCmdArgs = append(tapCmdArgs, "--set", "dump-logs=true")
|
||||||
@@ -564,19 +564,19 @@ func TestTapDumpLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(defaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Errorf("failed to cleanup tap command, err: %v", err)
|
t.Errorf("failed to cleanup tap command, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mizuFolderPath, mizuPathErr := getMizuFolderPath()
|
mizuFolderPath, mizuPathErr := GetMizuFolderPath()
|
||||||
if mizuPathErr != nil {
|
if mizuPathErr != nil {
|
||||||
t.Errorf("failed to get mizu folder path, err: %v", mizuPathErr)
|
t.Errorf("failed to get mizu folder path, err: %v", mizuPathErr)
|
||||||
return
|
return
|
||||||
|
@@ -38,7 +38,7 @@ type PodDescriptor struct {
|
|||||||
Namespace string
|
Namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCliPath() (string, error) {
|
func GetCliPath() (string, error) {
|
||||||
dir, filePathErr := os.Getwd()
|
dir, filePathErr := os.Getwd()
|
||||||
if filePathErr != nil {
|
if filePathErr != nil {
|
||||||
return "", filePathErr
|
return "", filePathErr
|
||||||
@@ -48,7 +48,7 @@ func getCliPath() (string, error) {
|
|||||||
return cliPath, nil
|
return cliPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMizuFolderPath() (string, error) {
|
func GetMizuFolderPath() (string, error) {
|
||||||
home, homeDirErr := os.UserHomeDir()
|
home, homeDirErr := os.UserHomeDir()
|
||||||
if homeDirErr != nil {
|
if homeDirErr != nil {
|
||||||
return "", homeDirErr
|
return "", homeDirErr
|
||||||
@@ -57,8 +57,8 @@ func getMizuFolderPath() (string, error) {
|
|||||||
return path.Join(home, ".mizu"), nil
|
return path.Join(home, ".mizu"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfigPath() (string, error) {
|
func GetConfigPath() (string, error) {
|
||||||
mizuFolderPath, mizuPathError := getMizuFolderPath()
|
mizuFolderPath, mizuPathError := GetMizuFolderPath()
|
||||||
if mizuPathError != nil {
|
if mizuPathError != nil {
|
||||||
return "", mizuPathError
|
return "", mizuPathError
|
||||||
}
|
}
|
||||||
@@ -66,15 +66,15 @@ func getConfigPath() (string, error) {
|
|||||||
return path.Join(mizuFolderPath, "config.yaml"), nil
|
return path.Join(mizuFolderPath, "config.yaml"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProxyUrl(namespace string, service string) string {
|
func GetProxyUrl(namespace string, service string) string {
|
||||||
return fmt.Sprintf("http://localhost:8080/api/v1/namespaces/%v/services/%v/proxy", namespace, service)
|
return fmt.Sprintf("http://localhost:8080/api/v1/namespaces/%v/services/%v/proxy", namespace, service)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getApiServerUrl(port uint16) string {
|
func GetApiServerUrl(port uint16) string {
|
||||||
return fmt.Sprintf("http://localhost:%v", port)
|
return fmt.Sprintf("http://localhost:%v", port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServiceExternalIp(ctx context.Context, namespace string, service string) (string, error) {
|
func GetServiceExternalIp(ctx context.Context, namespace string, service string) (string, error) {
|
||||||
home := homedir.HomeDir()
|
home := homedir.HomeDir()
|
||||||
configLoadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: filepath.Join(home, ".kube", "config")}
|
configLoadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: filepath.Join(home, ".kube", "config")}
|
||||||
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||||
@@ -113,39 +113,39 @@ func getDefaultCommandArgs() []string {
|
|||||||
return []string{setFlag, telemetry, setFlag, agentImage, setFlag, imagePullPolicy, setFlag, headless}
|
return []string{setFlag, telemetry, setFlag, agentImage, setFlag, imagePullPolicy, setFlag, headless}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultTapCommandArgs() []string {
|
func GetDefaultTapCommandArgs() []string {
|
||||||
tapCommand := "tap"
|
tapCommand := "tap"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{tapCommand}, defaultCmdArgs...)
|
return append([]string{tapCommand}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultTapCommandArgsWithRegex(regex string) []string {
|
func GetDefaultTapCommandArgsWithRegex(regex string) []string {
|
||||||
tapCommand := "tap"
|
tapCommand := "tap"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{tapCommand, regex}, defaultCmdArgs...)
|
return append([]string{tapCommand, regex}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultLogsCommandArgs() []string {
|
func GetDefaultLogsCommandArgs() []string {
|
||||||
logsCommand := "logs"
|
logsCommand := "logs"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{logsCommand}, defaultCmdArgs...)
|
return append([]string{logsCommand}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultTapNamespace() []string {
|
func GetDefaultTapNamespace() []string {
|
||||||
return []string{"-n", "mizu-tests"}
|
return []string{"-n", "mizu-tests"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultConfigCommandArgs() []string {
|
func GetDefaultConfigCommandArgs() []string {
|
||||||
configCommand := "config"
|
configCommand := "config"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{configCommand}, defaultCmdArgs...)
|
return append([]string{configCommand}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCypressTests(t *testing.T, cypressRunCmd string) {
|
func RunCypressTests(t *testing.T, cypressRunCmd string) {
|
||||||
cypressCmd := exec.Command("bash", "-c", cypressRunCmd)
|
cypressCmd := exec.Command("bash", "-c", cypressRunCmd)
|
||||||
t.Logf("running command: %v", cypressCmd.String())
|
t.Logf("running command: %v", cypressCmd.String())
|
||||||
out, err := cypressCmd.CombinedOutput()
|
out, err := cypressCmd.CombinedOutput()
|
||||||
@@ -184,10 +184,10 @@ func tryExecuteFunc(executeFunc func() error) (err interface{}) {
|
|||||||
return executeFunc()
|
return executeFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitTapPodsReady(apiServerUrl string) error {
|
func WaitTapPodsReady(apiServerUrl string) error {
|
||||||
resolvingUrl := fmt.Sprintf("%v/status/connectedTappersCount", apiServerUrl)
|
resolvingUrl := fmt.Sprintf("%v/status/connectedTappersCount", apiServerUrl)
|
||||||
tapPodsReadyFunc := func() error {
|
tapPodsReadyFunc := func() error {
|
||||||
requestResult, requestErr := executeHttpGetRequest(resolvingUrl)
|
requestResult, requestErr := ExecuteHttpGetRequest(resolvingUrl)
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
return requestErr
|
return requestErr
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ func jsonBytesToInterface(jsonBytes []byte) (interface{}, error) {
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpRequest(response *http.Response, requestErr error) (interface{}, error) {
|
func ExecuteHttpRequest(response *http.Response, requestErr error) (interface{}, error) {
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
return nil, requestErr
|
return nil, requestErr
|
||||||
} else if response.StatusCode != 200 {
|
} else if response.StatusCode != 200 {
|
||||||
@@ -229,7 +229,7 @@ func executeHttpRequest(response *http.Response, requestErr error) (interface{},
|
|||||||
return jsonBytesToInterface(data)
|
return jsonBytesToInterface(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpGetRequestWithHeaders(url string, headers map[string]string) (interface{}, error) {
|
func ExecuteHttpGetRequestWithHeaders(url string, headers map[string]string) (interface{}, error) {
|
||||||
request, err := http.NewRequest(http.MethodGet, url, nil)
|
request, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -241,15 +241,15 @@ func executeHttpGetRequestWithHeaders(url string, headers map[string]string) (in
|
|||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
response, requestErr := client.Do(request)
|
response, requestErr := client.Do(request)
|
||||||
return executeHttpRequest(response, requestErr)
|
return ExecuteHttpRequest(response, requestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpGetRequest(url string) (interface{}, error) {
|
func ExecuteHttpGetRequest(url string) (interface{}, error) {
|
||||||
response, requestErr := http.Get(url)
|
response, requestErr := http.Get(url)
|
||||||
return executeHttpRequest(response, requestErr)
|
return ExecuteHttpRequest(response, requestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpPostRequestWithHeaders(url string, headers map[string]string, body interface{}) (interface{}, error) {
|
func ExecuteHttpPostRequestWithHeaders(url string, headers map[string]string, body interface{}) (interface{}, error) {
|
||||||
requestBody, jsonErr := json.Marshal(body)
|
requestBody, jsonErr := json.Marshal(body)
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
return nil, jsonErr
|
return nil, jsonErr
|
||||||
@@ -267,10 +267,10 @@ func executeHttpPostRequestWithHeaders(url string, headers map[string]string, bo
|
|||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
response, requestErr := client.Do(request)
|
response, requestErr := client.Do(request)
|
||||||
return executeHttpRequest(response, requestErr)
|
return ExecuteHttpRequest(response, requestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanupCommand(cmd *exec.Cmd) error {
|
func CleanupCommand(cmd *exec.Cmd) error {
|
||||||
if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil {
|
if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ func cleanupCommand(cmd *exec.Cmd) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLogsPath() (string, error) {
|
func GetLogsPath() (string, error) {
|
||||||
dir, filePathErr := os.Getwd()
|
dir, filePathErr := os.Getwd()
|
||||||
if filePathErr != nil {
|
if filePathErr != nil {
|
||||||
return "", filePathErr
|
return "", filePathErr
|
||||||
|
Reference in New Issue
Block a user