Skip to content

Commit 91766b8

Browse files
authored
Merge pull request kubernetes#89387 from oomichi/NewAgnhostPod
Move NewAgnhostPod() to e2e/network
2 parents dfe8380 + 5c77461 commit 91766b8

File tree

6 files changed

+33
-28
lines changed

6 files changed

+33
-28
lines changed

test/e2e/framework/util.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ var (
155155
// BusyBoxImage is the image URI of BusyBox.
156156
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)
157157

158-
// AgnHostImage is the image URI of AgnHost
159-
AgnHostImage = imageutils.GetE2EImage(imageutils.Agnhost)
160-
161158
// ProvidersWithSSH are those providers where each node is accessible with SSH
162159
ProvidersWithSSH = []string{"gce", "gke", "aws", "local"}
163160

@@ -1516,25 +1513,6 @@ func DescribeIng(ns string) {
15161513
Logf(desc)
15171514
}
15181515

1519-
// NewAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
1520-
// that behave the same, no matter the underlying OS.
1521-
func (f *Framework) NewAgnhostPod(name string, args ...string) *v1.Pod {
1522-
return &v1.Pod{
1523-
ObjectMeta: metav1.ObjectMeta{
1524-
Name: name,
1525-
},
1526-
Spec: v1.PodSpec{
1527-
Containers: []v1.Container{
1528-
{
1529-
Name: "agnhost",
1530-
Image: AgnHostImage,
1531-
Args: args,
1532-
},
1533-
},
1534-
},
1535-
}
1536-
}
1537-
15381516
// CreateEmptyFileOnPod creates empty file at given path on the pod.
15391517
// TODO(alejandrox1): move to subpkg pod once kubectl methods have been refactored.
15401518
func CreateEmptyFileOnPod(namespace string, podName string, filePath string) error {

test/e2e/network/dns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ var _ = SIGDescribe("DNS", func() {
409409
ginkgo.By("Creating a pod with dnsPolicy=None and customized dnsConfig...")
410410
testServerIP := "1.1.1.1"
411411
testSearchPath := "resolv.conf.local"
412-
testAgnhostPod := f.NewAgnhostPod(f.Namespace.Name, "pause")
412+
testAgnhostPod := newAgnhostPod(f.Namespace.Name, "pause")
413413
testAgnhostPod.Spec.DNSPolicy = v1.DNSNone
414414
testAgnhostPod.Spec.DNSConfig = &v1.PodDNSConfig{
415415
Nameservers: []string{testServerIP},

test/e2e/network/firewall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ var _ = SIGDescribe("Firewall rule", func() {
146146
podName := fmt.Sprintf("netexec%v", i)
147147

148148
framework.Logf("Creating netexec pod %q on node %v in namespace %q", podName, nodeName, ns)
149-
pod := f.NewAgnhostPod(podName,
149+
pod := newAgnhostPod(podName,
150150
"netexec",
151151
fmt.Sprintf("--http-port=%d", firewallTestHTTPPort),
152152
fmt.Sprintf("--udp-port=%d", firewallTestUDPPort))

test/e2e/network/networking.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func checkConnectivityToHost(f *framework.Framework, nodeName, podName, host str
6060
Containers: []v1.Container{
6161
{
6262
Name: contName,
63-
Image: framework.AgnHostImage,
63+
Image: agnHostImage,
6464
Command: command,
6565
},
6666
},

test/e2e/network/service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ var _ = SIGDescribe("Services", func() {
902902

903903
ginkgo.By("Creating a webserver pod to be part of the TCP service which echoes back source ip")
904904
serverPodName := "echo-sourceip"
905-
pod := f.NewAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
905+
pod := newAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
906906
pod.Labels = jig.Labels
907907
_, err = cs.CoreV1().Pods(ns).Create(context.TODO(), pod, metav1.CreateOptions{})
908908
framework.ExpectNoError(err)
@@ -960,7 +960,7 @@ var _ = SIGDescribe("Services", func() {
960960

961961
ginkgo.By("creating a client/server pod")
962962
serverPodName := "hairpin"
963-
podTemplate := f.NewAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
963+
podTemplate := newAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
964964
podTemplate.Labels = jig.Labels
965965
pod, err := cs.CoreV1().Pods(ns).Create(context.TODO(), podTemplate, metav1.CreateOptions{})
966966
framework.ExpectNoError(err)
@@ -3334,7 +3334,7 @@ func proxyMode(f *framework.Framework) (string, error) {
33343334
Containers: []v1.Container{
33353335
{
33363336
Name: "detector",
3337-
Image: framework.AgnHostImage,
3337+
Image: agnHostImage,
33383338
Args: []string{"pause"},
33393339
},
33403340
},

test/e2e/network/util.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@ import (
2121
"fmt"
2222
"time"
2323

24+
"k8s.io/api/core/v1"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2426
"k8s.io/apimachinery/pkg/util/wait"
2527
"k8s.io/kubernetes/test/e2e/framework"
2628
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
29+
imageutils "k8s.io/kubernetes/test/utils/image"
30+
)
31+
32+
var (
33+
// agnHostImage is the image URI of AgnHost
34+
agnHostImage = imageutils.GetE2EImage(imageutils.Agnhost)
2735
)
2836

2937
// GetHTTPContent returns the content of the given url by HTTP.
@@ -49,3 +57,22 @@ func DescribeSvc(ns string) {
4957
ns, "describe", "svc", fmt.Sprintf("--namespace=%v", ns))
5058
framework.Logf(desc)
5159
}
60+
61+
// newAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
62+
// that behave the same, no matter the underlying OS.
63+
func newAgnhostPod(name string, args ...string) *v1.Pod {
64+
return &v1.Pod{
65+
ObjectMeta: metav1.ObjectMeta{
66+
Name: name,
67+
},
68+
Spec: v1.PodSpec{
69+
Containers: []v1.Container{
70+
{
71+
Name: "agnhost",
72+
Image: agnHostImage,
73+
Args: args,
74+
},
75+
},
76+
},
77+
}
78+
}

0 commit comments

Comments
 (0)