Documentation ¶
Index ¶
- Constants
- 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(NamespacePair) TestingSuite)
- func AppAndMgrNSName(suffix string) (appNS, mgrNS string)
- func ApplyApp(ctx context.Context, name, namespace, workload string)
- 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 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 GetGlobalHarness(ctx context.Context) *cluster
- 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) (string, 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.ReadCloser, error)
- func Output(ctx context.Context, exe string, args ...string) (string, error)
- func PingInterceptedEchoServer(ctx context.Context, svc, svcPort string)
- func PodCreateTimeout(c context.Context) time.Duration
- 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 RunningPods(ctx context.Context, svc, ns string) []string
- 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)
- func TelepresenceOk(ctx context.Context, args ...string) string
- func TelepresenceQuitOk(ctx context.Context)
- func TestContext(t *testing.T, ossRoot, moduleRoot string) context.Context
- func UseDocker(ctx context.Context) bool
- func WithAgentImage(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 map[string]string) context.Context
- func WithImage(ctx context.Context, image *Image) 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 WithSystemA(ctx context.Context, sa *SystemA) context.Context
- func WithT(ctx context.Context, t *testing.T) context.Context
- func WithTrafficManager(np NamespacePair, f func(ctx context.Context, ch NamespacePair))
- func WithUseDocker(ctx context.Context, use bool) context.Context
- func WithUser(ctx context.Context, clusterUser string) context.Context
- func WithWorkingDir(ctx context.Context, dir string) context.Context
- type Cluster
- type Harness
- type Image
- type MultipleServices
- type NamespacePair
- type Namespaces
- type Profile
- type Runner
- type SingleService
- type Suite
- type SystemA
- type TestingSuite
Constants ¶
const (
TestUser = "telepresence-test-developer"
)
Variables ¶
This section is empty.
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(NamespacePair) 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 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 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 GetGlobalHarness ¶
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 RolloutStatusWait ¶
func RunError ¶
RunError checks if the given err is a *exit.ExitError, and if so, extracts Stderr and the ExitCode from it.
func RunningPods ¶ added in v2.6.5
RunningPods 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 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)
StartLocalHttpEchoServerWithAddress 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 WithConfig ¶
func WithConnected ¶ added in v2.13.0
func WithConnected(np NamespacePair, f func(ctx context.Context, ch NamespacePair))
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 WithSystemA ¶ added in v2.13.0
func WithTrafficManager ¶ added in v2.13.0
func WithTrafficManager(np NamespacePair, f func(ctx context.Context, ch NamespacePair))
func WithUseDocker ¶ added in v2.13.0
Types ¶
type Cluster ¶
type Cluster interface { CapturePodLogs(ctx context.Context, app, container, ns string) CompatVersion() string Executable() string GeneralError() error GlobalEnv() map[string]string InstallTrafficManager(ctx context.Context, values map[string]string) error InstallTrafficManagerVersion(ctx context.Context, version string, values map[string]string) error IsCI() bool Registry() string SetGeneralError(error) Suffix() string TelepresenceVersion() string UninstallTrafficManager(ctx context.Context, managerNamespace string) PackageHelmChart(ctx context.Context) (string, error) GetValuesForHelm(ctx context.Context, values map[string]string, release bool) []string GetK8SCluster(ctx context.Context, context, managerNamespace string) (context.Context, *k8s.Cluster, error) TelepresenceHelmInstall(ctx context.Context, upgrade bool, args ...string) error }
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"` Tag string `json:"tag,omitempty"` Registry string `json:"registry,omitempty"` }
func GetAgentImage ¶ added in v2.13.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) AppNamespace() string 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 Runner ¶
type Runner interface { AddClusterSuite(func(context.Context) TestingSuite) AddNamespacePairSuite(suffix string, f func(NamespacePair) TestingSuite) AddTrafficManagerSuite(suffix string, f func(NamespacePair) 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 SystemA ¶ added in v2.13.0
type SystemA struct { SystemaHost string `json:"systemaHost"` SystemaPort int `json:"systemaPort"` }
func GetSystemA ¶ added in v2.13.0
type TestingSuite ¶ added in v2.13.0
type TestingSuite interface { suite.TestingSuite Harness Context() context.Context Assert() *assert.Assertions Require() *require.Assertions SuiteName() string }