Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move NewAgnhostPod() to e2e/network #89387

Merged
merged 1 commit into from Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 0 additions & 22 deletions test/e2e/framework/util.go
Expand Up @@ -155,9 +155,6 @@ var (
// BusyBoxImage is the image URI of BusyBox.
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)

// AgnHostImage is the image URI of AgnHost
AgnHostImage = imageutils.GetE2EImage(imageutils.Agnhost)

// ProvidersWithSSH are those providers where each node is accessible with SSH
ProvidersWithSSH = []string{"gce", "gke", "aws", "local"}

Expand Down Expand Up @@ -1583,25 +1580,6 @@ func DescribeIng(ns string) {
Logf(desc)
}

// NewAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
// that behave the same, no matter the underlying OS.
func (f *Framework) NewAgnhostPod(name string, args ...string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "agnhost",
Image: AgnHostImage,
Args: args,
},
},
},
}
}

// CreateEmptyFileOnPod creates empty file at given path on the pod.
// TODO(alejandrox1): move to subpkg pod once kubectl methods have been refactored.
func CreateEmptyFileOnPod(namespace string, podName string, filePath string) error {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/network/dns.go
Expand Up @@ -409,7 +409,7 @@ var _ = SIGDescribe("DNS", func() {
ginkgo.By("Creating a pod with dnsPolicy=None and customized dnsConfig...")
testServerIP := "1.1.1.1"
testSearchPath := "resolv.conf.local"
testAgnhostPod := f.NewAgnhostPod(f.Namespace.Name, "pause")
testAgnhostPod := newAgnhostPod(f.Namespace.Name, "pause")
testAgnhostPod.Spec.DNSPolicy = v1.DNSNone
testAgnhostPod.Spec.DNSConfig = &v1.PodDNSConfig{
Nameservers: []string{testServerIP},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/network/firewall.go
Expand Up @@ -146,7 +146,7 @@ var _ = SIGDescribe("Firewall rule", func() {
podName := fmt.Sprintf("netexec%v", i)

framework.Logf("Creating netexec pod %q on node %v in namespace %q", podName, nodeName, ns)
pod := f.NewAgnhostPod(podName,
pod := newAgnhostPod(podName,
"netexec",
fmt.Sprintf("--http-port=%d", firewallTestHTTPPort),
fmt.Sprintf("--udp-port=%d", firewallTestUDPPort))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/network/networking.go
Expand Up @@ -60,7 +60,7 @@ func checkConnectivityToHost(f *framework.Framework, nodeName, podName, host str
Containers: []v1.Container{
{
Name: contName,
Image: framework.AgnHostImage,
Image: agnHostImage,
Command: command,
},
},
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/network/service.go
Expand Up @@ -902,7 +902,7 @@ var _ = SIGDescribe("Services", func() {

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

ginkgo.By("creating a client/server pod")
serverPodName := "hairpin"
podTemplate := f.NewAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
podTemplate := newAgnhostPod(serverPodName, "netexec", "--http-port", strconv.Itoa(servicePort))
podTemplate.Labels = jig.Labels
pod, err := cs.CoreV1().Pods(ns).Create(context.TODO(), podTemplate, metav1.CreateOptions{})
framework.ExpectNoError(err)
Expand Down Expand Up @@ -3334,7 +3334,7 @@ func proxyMode(f *framework.Framework) (string, error) {
Containers: []v1.Container{
{
Name: "detector",
Image: framework.AgnHostImage,
Image: agnHostImage,
Args: []string{"pause"},
},
},
Expand Down
27 changes: 27 additions & 0 deletions test/e2e/network/util.go
Expand Up @@ -21,9 +21,17 @@ import (
"fmt"
"time"

"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
imageutils "k8s.io/kubernetes/test/utils/image"
)

var (
// agnHostImage is the image URI of AgnHost
agnHostImage = imageutils.GetE2EImage(imageutils.Agnhost)
)

// GetHTTPContent returns the content of the given url by HTTP.
Expand All @@ -49,3 +57,22 @@ func DescribeSvc(ns string) {
ns, "describe", "svc", fmt.Sprintf("--namespace=%v", ns))
framework.Logf(desc)
}

// newAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
// that behave the same, no matter the underlying OS.
func newAgnhostPod(name string, args ...string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "agnhost",
Image: agnHostImage,
Args: args,
},
},
},
}
}