helper

package
v1.18.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurlName = "curl"
	CurlPort = 3000
)
View Source
const (
	HttpEchoName = "http-echo"
	HttpEchoPort = 3000
)
View Source
const (
	TcpEchoName = "tcp-echo"
	TcpEchoPort = 1025
)
View Source
const (
	GATEWAY = "gateway"
	INGRESS = "ingress"
	KNATIVE = "knative"
)
View Source
const (
	TestServerName = "testserver"
	TestServerPort = 1234

	// This response is given by the testserver when the SimpleServer is started
	SimpleHttpResponse = `` /* 851-byte string literal not displayed */

	SimpleHttpResponseArm = `` /* 807-byte string literal not displayed */

)

Variables

View Source
var (
	ErrCannotCurl = errors.New("cannot curl")

	DefaultCurlTimeout        = time.Second * 20 // DefaultCurlTimeout is the default timeout for "Eventually" curl assertions
	DefaultCurlPollingTimeout = time.Second * 2  // DefaultCurlPollingTimeout is the default pollinginterval for "Eventually" curl assertions
)

Functions

func ExtraArgs

func ExtraArgs(args ...string) func(*InstallOptions)

func GenerateVariantValuesFile

func GenerateVariantValuesFile(variant string) (string, error)

func GetExpectedResponseMatcher

func GetExpectedResponseMatcher(expectedOutput interface{}) types.GomegaMatcher

GetExpectedResponseMatcher takes an interface and converts it into the types.GomegaMatcher that will be used to assert that a given Curl response, matches an expected shape

func GetTimeouts

func GetTimeouts(timeout ...time.Duration) (currentTimeout, pollingInterval time.Duration)

Types

type CurlOpts

type CurlOpts struct {
	Protocol          string
	Path              string
	Method            string
	Host              string
	Service           string
	CaFile            string
	Body              string
	Headers           map[string]string
	Port              int
	ReturnHeaders     bool
	ConnectionTimeout int

	// Verbose is used to configure the verbosity of the curl request
	// Deprecated: see buildCurlArgs() for details about why we always default this to true
	Verbose       bool
	LogResponses  bool
	AllowInsecure bool
	// WithoutStats sets the -s flag to prevent download stats from printing
	WithoutStats bool
	// Optional SNI name to resolve domain to when sending request
	Sni        string
	SelfSigned bool

	// Retries on Curl requests are disabled by default because they historically were not configurable
	// Curls to a remote container may be subject to network flakes and therefore using retries
	// can be a useful mechanism to avoid test flakes
	Retries struct {
		Retry        int
		RetryDelay   int
		RetryMaxTime int
	}
}

type InstallOption

type InstallOption func(*InstallOptions)

type InstallOptions

type InstallOptions struct {
	GlooctlCommand []string
	Verbose        bool
}

type SoloTestHelper

type SoloTestHelper struct {
	*TestConfig
	TestUpstreamServer
	// The kubernetes helper
	*kubectl.Cli
}

func NewSoloTestHelper

func NewSoloTestHelper(configFunc TestConfigFunc) (*SoloTestHelper, error)

NewSoloTestHelper is meant to provide a standard way of deploying Gloo/GlooE to a k8s cluster during tests. It assumes that build and test assets are present in the `_output` and `_test` directories (these are configurable). Specifically, it expects the glooctl executable in the BuildAssetDir and a helm chart in TestAssetDir. It also assumes that a kubectl executable is on the PATH.

func (*SoloTestHelper) ChartVersion

func (h *SoloTestHelper) ChartVersion() string

Return the version of the Helm chart

func (*SoloTestHelper) GetContainerLogs

func (h *SoloTestHelper) GetContainerLogs(ctx context.Context, namespace string, name string) string

Can be replaced entirely with Cli

func (*SoloTestHelper) InstallGloo

func (h *SoloTestHelper) InstallGloo(ctx context.Context, deploymentType string, timeout time.Duration, options ...InstallOption) error

Installs Gloo (and, optionally, the test server)

func (*SoloTestHelper) ModifyDeploymentEnv

func (h *SoloTestHelper) ModifyDeploymentEnv(ctx context.Context, deploymentClient clientsv1.DeploymentInterface, namespace string, deploymentName string, containerIndex int, envVar corev1.EnvVar)

func (*SoloTestHelper) SetKubeCli

func (h *SoloTestHelper) SetKubeCli(cli *kubectl.Cli)

func (*SoloTestHelper) UninstallGloo

func (h *SoloTestHelper) UninstallGloo() error

does not pass the --all flag to glooctl uninstall

func (*SoloTestHelper) UninstallGlooAll

func (h *SoloTestHelper) UninstallGlooAll() error

passes the --all flag to glooctl uninstall

func (*SoloTestHelper) WaitForRollout

func (h *SoloTestHelper) WaitForRollout(ctx context.Context, deploymentName string, deploymentNamespace string, intervals ...interface{})

WaitForRollout waits for the specified deployment to be rolled out successfully.

type TestConfig

type TestConfig struct {
	// All relative paths will assume this as the base directory. This is usually the project base directory.
	RootDir string
	// The directory holding the test assets. Must be relative to RootDir.
	TestAssetDir string
	// The directory holding the build assets. Must be relative to RootDir.
	BuildAssetDir string
	// Helm chart name
	HelmChartName string
	// Name of the helm index file name
	HelmRepoIndexFileName string
	// The namespace gloo (and the test server) will be installed to. If empty, will use the helm chart version.
	InstallNamespace string
	// Name of the glooctl executable
	GlooctlExecName string
	// If provided, the license key to install the enterprise version of Gloo
	LicenseKey string
	// Determines whether the test server pod gets deployed
	DeployTestServer bool
	// Install a released version of gloo. This is the value of the github tag that may have a leading 'v'
	ReleasedVersion string
	// If true, glooctl will be run with a -v flag
	Verbose bool
	// contains filtered or unexported fields
}

type TestConfigFunc

type TestConfigFunc func(defaults TestConfig) TestConfig

Function to provide/override test configuration. Default values will be passed in.

type TestContainer

type TestContainer interface {
	DeployResources(timeout time.Duration) error
	TerminatePod() error
	DeleteService() error
	TerminatePodAndDeleteService() error
	CanCurl() bool
	// CurlEventuallyShouldRespond checks the response of the request eventually meets expectation
	// The response is type interface{}. See the actual implementation for which types are supported
	CurlEventuallyShouldRespond(opts CurlOpts, response interface{}, ginkgoOffset int, timeout ...time.Duration)
	// CurlEventuallyShouldOutput checks all the output of the curl command eventually meets expectation
	// The response is type interface{}. See the actual implementation for which types are supported
	// Deprecated: Prefer CurlEventuallyShouldRespond
	CurlEventuallyShouldOutput(opts CurlOpts, output interface{}, ginkgoOffset int, timeout ...time.Duration)
	Curl(opts CurlOpts) (string, error)
	Exec(command ...string) (string, error)
	ExecAsync(args ...string) (io.Reader, chan struct{}, error)
}

A TestContainer is a general-purpose abstraction over a container in which we might execute cURL or other, arbitrary commands via kubectl.

func NewCurl added in v1.17.5

func NewCurl(namespace string) (TestContainer, error)

func NewEchoHttp

func NewEchoHttp(namespace string) (TestContainer, error)

Deprecated ported to test/kubernetes/e2e/defaults/testdata/http_echo.yaml

func NewEchoTcp

func NewEchoTcp(namespace string) (TestContainer, error)

Deprecated ported to test/kubernetes/e2e/defaults/testdata/tcp_echo.yaml

type TestUpstreamServer

type TestUpstreamServer interface {
	TestContainer
	DeployServer(timeout time.Duration) error
	DeployServerTls(timeout time.Duration, crt, key []byte) error
}

A TestUpstreamServer is an extension of a TestContainer which is typically run with the defaultTestServerImage. It is used to deploy test http/https services

func NewTestServer

func NewTestServer(namespace string) (TestUpstreamServer, error)

tests relying on the test server should be ported using the default nginx deployment located at test/kubernetes/e2e/defaults/testdata/nginx_pod.yaml

Jump to

Keyboard shortcuts

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