utils

package
v1.4.0-alpha.2....-4dc418c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointHttpPort      = 8080
	EndpointUdpPort       = 8081
	TestContainerHttpPort = 8080
	ClusterHttpPort       = 80
	ClusterUdpPort        = 90
	NetexecImageName      = "gcr.io/google_containers/netexec:1.7"
	HostexecImageName     = "gcr.io/google_containers/hostexec:1.2"
)

Variables

This section is empty.

Functions

func MakeTempDirOrDie

func MakeTempDirOrDie(prefix string, baseDir string) string

Types

type NetworkingTestConfig

type NetworkingTestConfig struct {
	// TestContaienrPod is a test pod running the netexec image. It is capable
	// of executing tcp/udp requests against ip:port.
	TestContainerPod *api.Pod
	// HostTestContainerPod is a pod running with hostNetworking=true, and the
	// hostexec image.
	HostTestContainerPod *api.Pod
	// EndpointPods are the pods belonging to the Service created by this
	// test config. Each invocation of `setup` creates a service with
	// 1 pod per node running the netexecImage.
	EndpointPods []*api.Pod

	// NodePortService is a Service with Type=NodePort spanning over all
	// endpointPods.
	NodePortService *api.Service
	// ExternalAddrs is a list of external IPs of nodes in the cluster.
	ExternalAddrs []string
	// Nodes is a list of nodes in the cluster.
	Nodes []api.Node
	// MaxTries is the number of retries tolerated for tests run against
	// endpoints and services created by this config.
	MaxTries int
	// The ClusterIP of the Service reated by this test config.
	ClusterIP string
	// External ip of first node for use in nodePort testing.
	NodeIP string
	// The http/udp nodePorts of the Service.
	NodeHttpPort int
	NodeUdpPort  int
	// The kubernetes namespace within which all resources for this
	// config are created
	Namespace string
	// contains filtered or unexported fields
}

NetworkingTestConfig is a convenience class around some utility methods for testing kubeproxy/networking/services/endpoints.

func NewCoreNetworkingTestConfig

func NewCoreNetworkingTestConfig(f *framework.Framework) *NetworkingTestConfig

NewNetworkingTestNodeE2EConfig creates and sets up a new test config helper for Node E2E.

func NewNetworkingTestConfig

func NewNetworkingTestConfig(f *framework.Framework) *NetworkingTestConfig

NewNetworkingTestConfig creates and sets up a new test config helper.

func (*NetworkingTestConfig) DeleteNetProxyPod

func (config *NetworkingTestConfig) DeleteNetProxyPod()

func (*NetworkingTestConfig) DeleteNodePortService

func (config *NetworkingTestConfig) DeleteNodePortService()

func (*NetworkingTestConfig) DialFromContainer

func (config *NetworkingTestConfig) DialFromContainer(protocol, containerIP, targetIP string, containerHttpPort, targetPort, maxTries, minTries int, expectedEps sets.String)

DialFromContainers executes a curl via kubectl exec in a test container, which might then translate to a tcp or udp request based on the protocol argument in the url.

  • minTries is the minimum number of curl attempts required before declaring success. Set to 0 if you'd like to return as soon as all endpoints respond at least once.
  • maxTries is the maximum number of curl attempts. If this many attempts pass and we don't see all expected endpoints, the test fails.
  • expectedEps is the set of endpointnames to wait for. Typically this is also the hostname reported by each pod in the service through /hostName.

maxTries == minTries will confirm that we see the expected endpoints and no more for maxTries. Use this if you want to eg: fail a readiness check on a pod and confirm it doesn't show up as an endpoint.

func (*NetworkingTestConfig) DialFromEndpointContainer

func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String)

func (*NetworkingTestConfig) DialFromNode

func (config *NetworkingTestConfig) DialFromNode(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String)

DialFromNode executes a tcp or udp request based on protocol via kubectl exec in a test container running with host networking.

  • minTries is the minimum number of curl attempts required before declaring success. Set to 0 if you'd like to return as soon as all endpoints respond at least once.
  • maxTries is the maximum number of curl attempts. If this many attempts pass and we don't see all expected endpoints, the test fails.

maxTries == minTries will confirm that we see the expected endpoints and no more for maxTries. Use this if you want to eg: fail a readiness check on a pod and confirm it doesn't show up as an endpoint.

func (*NetworkingTestConfig) DialFromTestContainer

func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String)

func (*NetworkingTestConfig) EndpointHostnames

func (config *NetworkingTestConfig) EndpointHostnames() sets.String

EndpointHostnames returns a set of hostnames for existing endpoints.

func (*NetworkingTestConfig) GetSelfURL

func (config *NetworkingTestConfig) GetSelfURL(path string, expected string)

GetSelfURL executes a curl against the given path via kubectl exec into a test container running with host networking, and fails if the output doesn't match the expected string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL