testenv

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package testenv contains common helpers for tests

Index

Constants

View Source
const Timeout = 5 * time.Minute

Variables

This section is empty.

Functions

func AddRandomSuffix added in v0.10.0

func AddRandomSuffix(name string, s rand.Source) string

AddRandomSuffix adds a random suffix to a given name.

func ApplyTemplate added in v0.7.0

func ApplyTemplate(k kubectl.Command, asset string, data interface{}) error

ApplyTemplate templates a file and applies it to the cluster.

func AssetPath

func AssetPath(p ...string) string

AssetPath returns the path to an asset

func CreateCluster added in v0.10.0

func CreateCluster(
	k kubectl.Command,
	namespace,
	name string,
	labels map[string]string,
	spec map[string]string,
) error

func CreateClusterGroup added in v0.10.0

func CreateClusterGroup(
	k kubectl.Command,
	namespace,
	name string,
	matchLabels map[string]string,
	labels map[string]string,
) error

CreateClusterGroup uses the template to create a clustergroup resource.

func CreateGitRepo added in v0.7.0

func CreateGitRepo(
	k kubectl.Command,
	namespace string,
	name string,
	branch string,
	shard string,
	paths ...string,
) error

CreateGitRepo uses the template to create a gitrepo resource. The namespace is the TargetNamespace for the workloads.

func ExamplePath

func ExamplePath(p ...string) string

ExamplePath returns the path to the fleet examples

func FailAndGather added in v0.11.0

func FailAndGather(message string, callerSkip ...int)

func NewNamespaceName added in v0.7.0

func NewNamespaceName(name string, s rand.Source) string

NewNamespaceName returns a name for a namespace that is unique to the test run. e.g. as a targetNamespace for workloads

func RandomFilename added in v0.5.0

func RandomFilename(filename string, r *rand.Rand) string

RandomName returns a slightly random name, so temporary assets don't conflict

func Root

func Root() string

Root returns the relative path to the repositories root

func SetRoot

func SetRoot(dir string)

SetRoot set the root path for the other relative paths, e.g. AssetPath. Usually set to point to the repositories root.

func Template added in v0.5.0

func Template(output string, tmplPath string, data any) error

Template loads a gotemplate from a file and writes templated output to another file, preferably in a temp dir

Types

type Env

type Env struct {
	Kubectl kubectl.Command
	// Upstream context for cluster containing the fleet controller and local agent
	Upstream string
	// Downstream context for fleet-agent cluster
	Downstream string
	// Managed downstream cluster
	ManagedDownstream string
	// Namespace which contains the cluster resource for most E2E tests
	// (cluster registration namespace)
	Namespace string
	// Namespace which contains downstream clusters, besides the local
	// cluster, for some multi-cluster E2E tests
	ClusterRegistrationNamespace string
}

func New

func New() *Env

type GitRepoData added in v0.7.0

type GitRepoData struct {
	Name            string
	Branch          string
	Paths           []string
	TargetNamespace string
	Shard           string
}

GitRepoData can be used with the gitrepo-template.yaml asset when no custom GitRepo properties are required. All fields except Shard are required.

Directories

Path Synopsis
cmd
Package kubectl is a wrapper around the kubectl CLI
Package kubectl is a wrapper around the kubectl CLI

Jump to

Keyboard shortcuts

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