Skip to content

Commit

Permalink
Hack
Browse files Browse the repository at this point in the history
Signed-off-by: Dyanngg <dingyang@vmware.com>
  • Loading branch information
Dyanngg committed Mar 17, 2023
1 parent c77073e commit 4b9ab83
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
9 changes: 7 additions & 2 deletions test/e2e/k8s_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,14 @@ func (k *KubernetesUtils) getTCPv4SourcePortRangeFromPod(podNamespace, podNameLa
log.Errorf("Failed to retrieve TCP source port range for Pod %s/%s", podNamespace, podNameLabel)
return 0, 0, err
}
log.Infof("The first splitted port is %s", ports[0])
log.Infof("The second splitted port is %s", ports[1])
startPort, _ := strconv.Atoi(ports[0])
endPort, _ := strconv.Atoi(ports[1])
return startPort, endPort, nil
endPort, err := strconv.Atoi(ports[1])
if err != nil {
log.Errorf("Err in converting endPort: %v", err)
}
return startPort, endPort, err
}

func (k *KubernetesUtils) probe(
Expand Down
17 changes: 13 additions & 4 deletions test/e2e/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"
"time"

log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -117,10 +118,14 @@ func probeHostnameFromPod(data *TestData, pod, container string, baseUrl string)
url := fmt.Sprintf("%s/%s", baseUrl, "hostname")
var err error
var hostname string
var stderr string
if container == busyboxContainerName {
hostname, _, err = data.runWgetCommandOnBusyboxWithRetry(pod, data.testNamespace, url, 5)
hostname, stderr, err = data.runWgetCommandOnBusyboxWithRetry(pod, data.testNamespace, url, 5)
} else {
hostname, _, err = data.RunCommandFromPod(data.testNamespace, pod, container, []string{"wget", "-O", "-", url, "-T", "5"})
hostname, stderr, err = data.RunCommandFromPod(data.testNamespace, pod, container, []string{"wget", "-O", "-", url, "-T", "5"})
}
if stderr != "" {
log.Infof("Stderr: %v", stderr)
}
return hostname, err
}
Expand All @@ -129,14 +134,18 @@ func probeClientIPFromPod(data *TestData, pod, container string, baseUrl string)
url := fmt.Sprintf("%s/%s", baseUrl, "clientip")
var err error
var hostPort string
var stderr string
if container == busyboxContainerName {
hostPort, _, err = data.runWgetCommandOnBusyboxWithRetry(pod, data.testNamespace, url, 5)
hostPort, stderr, err = data.runWgetCommandOnBusyboxWithRetry(pod, data.testNamespace, url, 5)
} else {
hostPort, _, err = data.RunCommandFromPod(data.testNamespace, pod, container, []string{"wget", "-O", "-", url, "-T", "5"})
hostPort, stderr, err = data.RunCommandFromPod(data.testNamespace, pod, container, []string{"wget", "-O", "-", url, "-T", "5"})
}
if err != nil {
return "", err
}
if stderr != "" {
log.Infof("Stderr: %v", stderr)
}
host, _, err := net.SplitHostPort(hostPort)
return host, err
}
Expand Down

0 comments on commit 4b9ab83

Please sign in to comment.