connhelper

package
v0.0.0-...-adfa13f Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StaticClientName = "static-client"
	StaticServerName = "static-server"
	JobName          = "job-client"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnHelperOpts

type ConnHelperOpts struct {
	ClientType string
}

ConnHelperOpts allows for configuring optional parameters to be passed into the conn helper methods. This provides added flexibility, although not every value will be used by every method. See documentation for more details.

type ConnectHelper

type ConnectHelper struct {
	// ClusterKind is the kind of Consul cluster to use (e.g. "Helm", "CLI").
	ClusterKind consul.ClusterKind

	// Secure configures the Helm chart for the test to use ACL tokens.
	Secure bool

	// HelmValues are the additional helm values to use when installing or
	// upgrading the cluster beyond connectInject.enabled, global.tls.enabled,
	// global.tls.enableAutoEncrypt, global.acls.manageSystemACLs which are
	// set by the Secure and AutoEncrypt fields.
	HelmValues map[string]string

	// ReleaseName is the name of the Consul cluster.
	ReleaseName string

	// Ctx is used to deploy Consul
	Ctx environment.TestContext

	// UseAppNamespace is used top optionally deploy applications into a separate namespace.
	// If unset, the namespace associated with Ctx is used.
	UseAppNamespace bool

	Cfg *config.TestConfig

	// ConsulClient is the client used to test service mesh connectivity.
	ConsulClient *api.Client
	// contains filtered or unexported fields
}

ConnectHelper configures a Consul cluster for connect injection tests. It also provides helper methods to exercise the connect functionality.

func (*ConnectHelper) CreateIntention

func (c *ConnectHelper) CreateIntention(t *testing.T, opts IntentionOpts)

CreateIntention creates an intention for the static-server pod to connect to the static-client pod. opts parameter allows for overriding of some fields. If opts is empty then all namespaces and clients use defaults.

func (*ConnectHelper) CreateNamespace

func (c *ConnectHelper) CreateNamespace(t *testing.T, namespace string)

func (*ConnectHelper) CreateResolverRedirect

func (c *ConnectHelper) CreateResolverRedirect(t *testing.T)

CreateResolverRedirect creates a resolver that redirects to a static-server, a corresponding k8s service, and intentions. This helper is primarily used to ensure that the virtual-ips are persisted to consul properly.

func (*ConnectHelper) DeployClientAndServer

func (c *ConnectHelper) DeployClientAndServer(t *testing.T)

DeployClientAndServer deploys a client and server pod to the Kubernetes cluster which will be used to test service mesh connectivity. If the Secure flag is true, a pre-check is done to ensure that the ACL tokens for the test are deleted. The status of the deployment and injection is checked after the deployment is complete to ensure success.

func (*ConnectHelper) DeployJob

func (c *ConnectHelper) DeployJob(t *testing.T, path string)

DeployJob deploys a job pod to the Kubernetes cluster which will be used to test service mesh connectivity. If the Secure flag is true, a pre-check is done to ensure that the ACL tokens for the test are deleted. The status of the deployment and injection is checked after the deployment is complete to ensure success.

func (*ConnectHelper) DeployServer

func (c *ConnectHelper) DeployServer(t *testing.T)

DeployServer deploys a server pod to the Kubernetes cluster which will be used to test service mesh connectivity. If the Secure flag is true, a pre-check is done to ensure that the ACL tokens for the test are deleted. The status of the deployment and injection is checked after the deployment is complete to ensure success.

func (*ConnectHelper) Install

func (c *ConnectHelper) Install(t *testing.T)

Install uses the consulCluster to install Consul onto the Kubernetes cluster.

func (*ConnectHelper) KubectlOptsForApp

func (c *ConnectHelper) KubectlOptsForApp(t *testing.T) *terratestK8s.KubectlOptions

KubectlOptsForApp returns options using the -apps appended namespace if UseAppNamespace is enabled. Otherwise, it returns the ctx options.

func (*ConnectHelper) Setup

func (c *ConnectHelper) Setup(t *testing.T)

Setup creates a new cluster using the New*Cluster function and assigns it to the consulCluster field.

func (*ConnectHelper) SetupAppNamespace

func (c *ConnectHelper) SetupAppNamespace(t *testing.T)

SetupAppNamespace creates a namespace where applications are deployed. This does nothing if UseAppNamespace is not set. The app namespace is relevant when testing with restricted PSA enforcement enabled.

func (*ConnectHelper) TestConnectionFailureWhenUnhealthy

func (c *ConnectHelper) TestConnectionFailureWhenUnhealthy(t *testing.T)

TestConnectionFailureWhenUnhealthy sets the static-server pod to be unhealthy and ensures the connection fails. It restores the pod to a healthy state after this check.

func (*ConnectHelper) TestConnectionFailureWithoutIntention

func (c *ConnectHelper) TestConnectionFailureWithoutIntention(t *testing.T, connHelperOpts ConnHelperOpts)

TestConnectionFailureWithoutIntention ensures the connection to the static server fails when no intentions are configured. When provided with a ClientType option the client is overridden, otherwise a default will be used.

func (*ConnectHelper) TestConnectionSuccess

func (c *ConnectHelper) TestConnectionSuccess(t *testing.T, connHelperOpts ConnHelperOpts)

TestConnectionSuccess ensures the static-server pod can connect to the static-client pod once the intention is set. When provided with a ClientType option the client is overridden, otherwise a default will be used.

func (*ConnectHelper) Upgrade

func (c *ConnectHelper) Upgrade(t *testing.T)

Upgrade uses the existing Consul cluster and upgrades it using Helm values set by the Secure, AutoEncrypt, and HelmValues fields.

type IntentionOpts

type IntentionOpts struct {
	ConnHelperOpts
	SourceNamespace      string
	DestinationNamespace string
}

Jump to

Keyboard shortcuts

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