Documentation ¶
Index ¶
- Constants
- Variables
- func AddClusterSuite(f func(context.Context) TestingSuite)
- func AddConnectedSuite(suffix string, f func(NamespacePair) TestingSuite)
- func AddMultipleServicesSuite(suffix, name string, f func(services MultipleServices) TestingSuite)
- func AddNamespacePairSuite(suffix string, f func(NamespacePair) TestingSuite)
- func AddSingleServiceSuite(suffix, name string, f func(services SingleService) TestingSuite)
- func AddTrafficManagerSuite(suffix string, f func(manager TrafficManager) TestingSuite)
- func AppAndMgrNSName(suffix string) (appNS, mgrNS string)
- func ApplyApp(ctx context.Context, name, namespace, workload string)
- func ApplyAppTemplate(ctx context.Context, namespace string, app *AppData)
- func ApplyEchoService(ctx context.Context, name, namespace string, port int)
- func ApplyService(ctx context.Context, name, namespace, image string, port, targetPort int)
- func AssertDisconnectOutput(ctx context.Context, stdout string)
- func AssertQuitOutput(ctx context.Context, stdout string)
- func BuildOutput(ctx context.Context) string
- func CleanLogDir(ctx context.Context, require *Requirements, ...)
- func Command(ctx context.Context, executable string, args ...string) *dexec.Cmd
- func CreateNamespaces(ctx context.Context, namespaces ...string)
- func DeleteNamespaces(ctx context.Context, namespaces ...string)
- func DeleteSvcAndWorkload(ctx context.Context, workload, name, namespace string)
- func EnvironMap(ctx context.Context) dos.MapEnv
- func GetModuleRoot(ctx context.Context) string
- func GetOSSRoot(ctx context.Context) string
- func GetUser(ctx context.Context) string
- func GetWorkingDir(ctx context.Context) string
- func KubeConfig(ctx context.Context) string
- func Kubectl(ctx context.Context, namespace string, args ...string) error
- func KubectlOut(ctx context.Context, namespace string, args ...string) (out string, err error)
- func LoadEnv(ctx context.Context) context.Context
- func LookupEnv(ctx context.Context, key string) (value string, ok bool)
- func OpenTemplate(ctx context.Context, name string, data any) (io.Reader, error)
- func Output(ctx context.Context, exe string, args ...string) (string, error)
- func PingInterceptedEchoServer(ctx context.Context, svc, svcPort string, headers ...string)
- func PodCreateTimeout(c context.Context) time.Duration
- func ReadTemplate(ctx context.Context, name string, data any) ([]byte, error)
- func RolloutStatusWait(ctx context.Context, namespace, workload string) error
- func Run(ctx context.Context, exe string, args ...string) error
- func RunError(err error, out []byte) error
- func RunTests(c context.Context)
- func RunningPodNames(ctx context.Context, svc, ns string) []string
- func RunningPods(ctx context.Context, svc, ns string) []core.Pod
- func RunningPodsWithAgents(ctx context.Context, appPrefix, ns string) []string
- func SetConfig(ctx context.Context, configDir, configYml string) (context.Context, error)
- func SetModuleRoot(ctx context.Context, dir string) context.Context
- func SetOSSRoot(ctx context.Context, dir string) context.Context
- func StartLocalHttpEchoServer(ctx context.Context, name string) (int, context.CancelFunc)
- func StartLocalHttpEchoServerWithHost(ctx context.Context, name string, host string) (int, context.CancelFunc)
- func Telepresence(ctx context.Context, args ...string) (string, string, error)
- func TelepresenceCmd(ctx context.Context, args ...string) *dexec.Cmd
- func TelepresenceDisconnectOk(ctx context.Context, args ...string)
- func TelepresenceOk(ctx context.Context, args ...string) string
- func TelepresenceQuitOk(ctx context.Context)
- func TestContext(t *testing.T, ossRoot, moduleRoot string) context.Context
- func WithAgentImage(ctx context.Context, image *Image) context.Context
- func WithClientImage(ctx context.Context, image *Image) context.Context
- func WithCluster(ctx context.Context, f func(ctx context.Context))
- func WithConfig(c context.Context, modifierFunc func(config client.Config)) context.Context
- func WithConnected(np NamespacePair, f func(ctx context.Context, ch NamespacePair))
- func WithEnv(ctx context.Context, env dos.MapEnv) context.Context
- func WithImage(ctx context.Context, image *Image) context.Context
- func WithKubeConfig(ctx context.Context, cfg *api.Config) context.Context
- func WithKubeConfigExtension(ctx context.Context, extProducer func(*api.Cluster) map[string]any) context.Context
- func WithModuleRoot(ctx context.Context) context.Context
- func WithMultipleServices(np NamespacePair, name string, serviceCount int, f func(MultipleServices))
- func WithNamespacePair(ctx context.Context, suffix string, f func(NamespacePair))
- func WithNamespaces(ctx context.Context, namespaces *Namespaces) context.Context
- func WithOSSRoot(ctx context.Context) context.Context
- func WithSingleService(h NamespacePair, serviceName string, f func(SingleService))
- func WithT(ctx context.Context, t *testing.T) context.Context
- func WithTrafficManager(np NamespacePair, f func(ctx context.Context, ch TrafficManager))
- func WithUser(ctx context.Context, clusterUser string) context.Context
- func WithWorkingDir(ctx context.Context, dir string) context.Context
- func WrapSensitive(s string) string
- type AppData
- type AppPort
- type Assertions
- type Cluster
- type Generic
- type Harness
- type Image
- type MultipleServices
- type NamespacePair
- type Namespaces
- type Profile
- type Requirements
- type Runner
- type SingleService
- type StatusResponse
- type Suite
- type TestingSuite
- type TrafficManager
Constants ¶
const (
TestUser = "telepresence-test-developer"
)
Variables ¶
var ExtendClusterFunc = func(c Cluster) Cluster {
return c
}
Functions ¶
func AddClusterSuite ¶
func AddClusterSuite(f func(context.Context) TestingSuite)
AddClusterSuite adds a constructor for a test suite that requires a cluster to run to the default runner.
func AddConnectedSuite ¶
func AddConnectedSuite(suffix string, f func(NamespacePair) TestingSuite)
AddConnectedSuite adds a constructor for a test suite to the default runner that requires a cluster where a namespace pair has been initialized, and telepresence is connected.
func AddMultipleServicesSuite ¶
func AddMultipleServicesSuite(suffix, name string, f func(services MultipleServices) TestingSuite)
AddMultipleServicesSuite adds a constructor for a test suite to the default runner that requires a cluster where a namespace pair has been initialized, multiple services has been installed, and telepresence is connected.
func AddNamespacePairSuite ¶
func AddNamespacePairSuite(suffix string, f func(NamespacePair) TestingSuite)
AddNamespacePairSuite adds a constructor for a test suite that requires a cluster where a namespace pair has been initialized to the default runner.
func AddSingleServiceSuite ¶
func AddSingleServiceSuite(suffix, name string, f func(services SingleService) TestingSuite)
AddSingleServiceSuite adds a constructor for a test suite to the default runner that requires a cluster where a namespace pair has been initialized, a service has been installed, and telepresence is connected.
func AddTrafficManagerSuite ¶ added in v2.13.0
func AddTrafficManagerSuite(suffix string, f func(manager TrafficManager) TestingSuite)
AddTrafficManagerSuite adds a constructor for a test suite that requires a cluster where a namespace pair has been initialized and a traffic manager is installed.
func AppAndMgrNSName ¶
func ApplyApp ¶
ApplyApp calls kubectl apply -n <namespace> -f on the given app + .yaml found in testdata/k8s relative to the directory returned by GetWorkingDir.
func ApplyAppTemplate ¶ added in v2.18.0
ApplyAppTemplate calls kubectl apply -n <namespace> -f on the given app + .yaml found in testdata/k8s relative to the directory returned by GetWorkingDir.
func ApplyEchoService ¶
func ApplyService ¶
func AssertDisconnectOutput ¶ added in v2.5.0
AssertDisconnectOutput asserts that the stdout contains the correct output from a telepresence quit command.
func AssertQuitOutput ¶
AssertQuitOutput asserts that the stdout contains the correct output from a telepresence quit command.
func BuildOutput ¶ added in v2.20.0
func CleanLogDir ¶ added in v2.19.0
func CleanLogDir(ctx context.Context, require *Requirements, nsRx, mgrNamespace, svcNameRx string)
func Command ¶
Command creates and returns a dexec.Cmd initialized with the global environment from the cluster harness and any other environment that has been added using the WithEnv() function.
func CreateNamespaces ¶
func DeleteNamespaces ¶
func DeleteSvcAndWorkload ¶
func GetModuleRoot ¶ added in v2.9.3
func GetOSSRoot ¶ added in v2.9.3
func GetWorkingDir ¶
func KubeConfig ¶
func Kubectl ¶
Kubectl runs kubectl with the default context and the given namespace, or in the default namespace if the given namespace is an empty string.
func KubectlOut ¶
KubectlOut runs kubectl with the default context and the application namespace and returns its combined output.
func OpenTemplate ¶ added in v2.13.0
func Output ¶
Output runs the given command and arguments and returns its combined output and an error if the command failed.
func PingInterceptedEchoServer ¶ added in v2.6.8
PingInterceptedEchoServer assumes that a server has been created using StartLocalHttpEchoServer and that an intercept is active for the given svc and svcPort that will redirect to that local server.
func PodCreateTimeout ¶ added in v2.5.8
PodCreateTimeout will return a timeout suitable for operations that create pods. This is longer when running against clusters that scale up nodes on demand for new pods.
func ReadTemplate ¶ added in v2.16.1
func RolloutStatusWait ¶
func RunError ¶
RunError checks if the given err is a *exit.ExitError, and if so, extracts Stderr and the ExitCode from it.
func RunningPodNames ¶ added in v2.20.2
RunningPodNames return the names of running pods with app=<service name>. Running here means that at least one container is still running. I.e. the pod might well be terminating but still considered running.
func RunningPodsWithAgents ¶ added in v2.19.1
RunningPodsWithAgents returns the names of running pods with a matching appPrefix that has a running traffic-agent container.
func SetConfig ¶ added in v2.14.1
SetConfig creates a config from the configYml provided and assigns it to a new context which is returned. Use this if you are testing components of the config.yml, otherwise you can use setDefaultConfig.
func SetModuleRoot ¶ added in v2.9.3
SetModuleRoot sets the module root for the given context to dir.
func SetOSSRoot ¶ added in v2.9.3
SetOSSRoot sets the OSS module root for the given context to dir.
func StartLocalHttpEchoServer ¶
StartLocalHttpEchoServer starts a local http server that echoes a line with the given name and the current URL path. The port is returned together with function that cancels the server.
func StartLocalHttpEchoServerWithHost ¶ added in v2.13.0
func StartLocalHttpEchoServerWithHost(ctx context.Context, name string, host string) (int, context.CancelFunc)
StartLocalHttpEchoServerWithHost is like StartLocalHttpEchoServer but binds to a specific host instead of localhost.
func Telepresence ¶
Telepresence executes the CLI command in a new process.
func TelepresenceCmd ¶
TelepresenceCmd creates a dexec.Cmd using the Command function. Before the command is created, the environment is extended with DEV_TELEPRESENCE_CONFIG_DIR from filelocation.AppUserConfigDir and DEV_TELEPRESENCE_LOG_DIR from filelocation.AppUserLogDir.
func TelepresenceDisconnectOk ¶ added in v2.5.0
TelepresenceDisconnectOk tells telepresence to quit and asserts that the stdout contains the correct output.
func TelepresenceOk ¶
TelepresenceOk executes the CLI command in a new process and requires the result to be OK.
func TelepresenceQuitOk ¶
TelepresenceQuitOk tells telepresence to quit and asserts that the stdout contains the correct output.
func WithAgentImage ¶ added in v2.13.0
func WithClientImage ¶ added in v2.17.0
func WithConfig ¶
func WithConnected ¶ added in v2.13.0
func WithConnected(np NamespacePair, f func(ctx context.Context, ch NamespacePair))
func WithKubeConfig ¶ added in v2.17.0
func WithKubeConfigExtension ¶
func WithModuleRoot ¶
WithModuleRoot set the working directory for the Command function to the module root.
func WithMultipleServices ¶
func WithMultipleServices(np NamespacePair, name string, serviceCount int, f func(MultipleServices))
func WithNamespacePair ¶
func WithNamespacePair(ctx context.Context, suffix string, f func(NamespacePair))
func WithNamespaces ¶ added in v2.13.0
func WithNamespaces(ctx context.Context, namespaces *Namespaces) context.Context
func WithOSSRoot ¶ added in v2.9.3
WithOSSRoot set the working directory for the Command function to the OSS module root.
func WithSingleService ¶
func WithSingleService(h NamespacePair, serviceName string, f func(SingleService))
func WithTrafficManager ¶ added in v2.13.0
func WithTrafficManager(np NamespacePair, f func(ctx context.Context, ch TrafficManager))
func WithWorkingDir ¶
WithWorkingDir determines the working directory for the Command function.
func WrapSensitive ¶ added in v2.14.1
WrapSensitive wraps an argument sent to Command so that it doesn't get logged verbatim. This can be used for commands like "telepresence login --apikey NNNN" where the NNN shouldn't be visible in the logs. If NNN Is wrapped using this function, it will appear as "***" in the logs.
Types ¶
type Assertions ¶ added in v2.16.1
type Assertions struct {
*assert.Assertions
}
type Cluster ¶
type Cluster interface { CapturePodLogs(ctx context.Context, app, container, ns string) string CompatVersion() string Executable() (string, error) GeneralError() error GlobalEnv(context.Context) dos.MapEnv AgentVersion(context.Context) string Initialize(context.Context) context.Context InstallTrafficManager(ctx context.Context, values map[string]string) error InstallTrafficManagerVersion(ctx context.Context, version string, values map[string]string) error IsCI() bool IsIPv6() bool LargeFileTestDisabled() bool Registry() string SetGeneralError(error) Suffix() string TelepresenceVersion() string UninstallTrafficManager(ctx context.Context, managerNamespace string, args ...string) PackageHelmChart(ctx context.Context) (string, error) GetValuesForHelm(ctx context.Context, values map[string]string, release bool) []string GetSetArgsForHelm(ctx context.Context, values map[string]string, release bool) []string GetK8SCluster(ctx context.Context, context, managerNamespace string) (context.Context, *k8s.Cluster, error) TelepresenceHelmInstallOK(ctx context.Context, upgrade bool, args ...string) string TelepresenceHelmInstall(ctx context.Context, upgrade bool, args ...string) (string, error) UserdPProf() uint16 RootdPProf() uint16 }
func GetGlobalHarness ¶
type Harness ¶
type Harness interface { Cluster PushHarness(ctx context.Context, setup func(ctx context.Context) bool, tearDown func(ctx context.Context)) RunSuite(TestingSuite) HarnessContext() context.Context SetupSuite() HarnessT() *testing.T PopHarness() }
func NewContextHarness ¶
type Image ¶ added in v2.13.0
type Image struct { Name string `json:"name,omitempty"` Tag string `json:"tag,omitempty"` Registry string `json:"registry,omitempty"` PullPolicy string `json:"pullPolicy,omitempty"` }
func GetAgentImage ¶ added in v2.13.0
func GetClientImage ¶ added in v2.17.0
func ImageFromEnv ¶ added in v2.17.0
type MultipleServices ¶
type MultipleServices interface { NamespacePair Name() string ServiceCount() int }
type NamespacePair ¶
type NamespacePair interface { Harness ApplyApp(ctx context.Context, name, workload string) ApplyEchoService(ctx context.Context, name string, port int) ApplyTemplate(ctx context.Context, path string, values any) DeleteTemplate(ctx context.Context, path string, values any) AppNamespace() string TelepresenceConnect(ctx context.Context, args ...string) string TelepresenceTryConnect(ctx context.Context, args ...string) (string, error) DeleteSvcAndWorkload(ctx context.Context, workload, name string) Kubectl(ctx context.Context, args ...string) error KubectlOk(ctx context.Context, args ...string) string KubectlOut(ctx context.Context, args ...string) (string, error) ManagerNamespace() string RollbackTM(ctx context.Context) RolloutStatusWait(ctx context.Context, workload string) error }
type Namespaces ¶ added in v2.13.0
type Namespaces struct { Namespace string `json:"namespace,omitempty"` ManagedNamespaces []string `json:"managedNamespaces,omitempty"` }
func GetNamespaces ¶ added in v2.13.0
func GetNamespaces(ctx context.Context) *Namespaces
func (*Namespaces) HelmString ¶ added in v2.13.0
func (n *Namespaces) HelmString() string
func (*Namespaces) UniqueList ¶ added in v2.13.0
func (n *Namespaces) UniqueList() []string
type Requirements ¶ added in v2.16.1
type Requirements struct {
*require.Assertions
}
type Runner ¶
type Runner interface { AddClusterSuite(func(context.Context) TestingSuite) AddNamespacePairSuite(suffix string, f func(NamespacePair) TestingSuite) AddTrafficManagerSuite(suffix string, f func(TrafficManager) TestingSuite) AddConnectedSuite(suffix string, f func(NamespacePair) TestingSuite) AddMultipleServicesSuite(suffix, name string, f func(MultipleServices) TestingSuite) AddSingleServiceSuite(suffix, name string, f func(SingleService) TestingSuite) RunTests(context.Context) }
type SingleService ¶
type SingleService interface { NamespacePair ServiceName() string }
type StatusResponse ¶ added in v2.16.1
type StatusResponse struct { RootDaemon *cmd.RootDaemonStatus `json:"root_daemon,omitempty"` UserDaemon *cmd.UserDaemonStatus `json:"user_daemon,omitempty"` TrafficManager *cmd.TrafficManagerStatus `json:"traffic_manager,omitempty"` ContainerizedDaemon *cmd.ContainerizedDaemonStatus `json:"daemon,omitempty"` Connections []struct { RootDaemon *cmd.RootDaemonStatus `json:"root_daemon,omitempty"` UserDaemon *cmd.UserDaemonStatus `json:"user_daemon,omitempty"` TrafficManager *cmd.TrafficManagerStatus `json:"traffic_manager,omitempty"` ContainerizedDaemon *cmd.ContainerizedDaemonStatus `json:"daemon,omitempty"` } `json:"connections,omitempty"` Error string `json:"err,omitempty"` }
func TelepresenceStatus ¶ added in v2.16.1
func TelepresenceStatus(ctx context.Context, args ...string) (*StatusResponse, error)
func TelepresenceStatusOk ¶ added in v2.16.1
func TelepresenceStatusOk(ctx context.Context, args ...string) *StatusResponse
type Suite ¶
func (*Suite) AmendSuiteContext ¶ added in v2.19.0
func (*Suite) Assert ¶ added in v2.16.1
func (s *Suite) Assert() *Assertions
func (*Suite) Require ¶ added in v2.16.1
func (s *Suite) Require() *Requirements
type TestingSuite ¶ added in v2.13.0
type TestingSuite interface { suite.TestingSuite Harness AmendSuiteContext(context.Context) context.Context Context() context.Context Assert() *Assertions Require() *Requirements SuiteName() string // contains filtered or unexported methods }
type TrafficManager ¶ added in v2.21.0
type TrafficManager interface { NamespacePair DoWithTrafficManager(context.Context, func(context.Context, context.CancelFunc, manager.ManagerClient, *manager.SessionInfo)) error DoWithSession(context.Context, *rpc.ConnectRequest, func(context.Context, rpc.ConnectorServer)) error NewConnectRequest(context.Context) *rpc.ConnectRequest }