Documentation ¶
Index ¶
- type CombinationFilter
- type Filter
- type T
- func (t *T) ConditionallyTo(filters ...CombinationFilter) *T
- func (t *T) Config(s config.Source) *T
- func (t *T) From(filters ...Filter) *T
- func (t *T) FromMatch(m match.Matcher) *T
- func (t *T) Run(testFn oneToOneTest)
- func (t *T) RunFromClusters(testFn oneClusterOneTest)
- func (t *T) RunToN(n int, testFn oneToNTest)
- func (t *T) RunViaGatewayIngress(gatewayClass string, testFn ingressTest)
- func (t *T) RunViaIngress(testFn ingressTest)
- func (t *T) Setup(setupFn srcSetupFn) *T
- func (t *T) SetupForDestination(setupFn dstSetupFn) *T
- func (t *T) SetupForPair(...) *T
- func (t *T) SetupForServicePair(setupFn svcPairSetupFn) *T
- func (t *T) To(filters ...Filter) *T
- func (t *T) ToMatch(m match.Matcher) *T
- func (t *T) WithDefaultFilters(minimumFrom, minimumTo int) *T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CombinationFilter ¶
var HasL7 CombinationFilter = func(from echo.Instance, to echo.Instances) echo.Instances { if from.Config().HasSidecar() || from.Config().IsProxylessGRPC() { return to } return match.Matcher(func(instance echo.Instance) bool { return instance.Config().HasServiceAddressedWaypointProxy() || instance.Config().HasWorkloadAddressedWaypointProxy() }).GetMatches(to) }
HasL7 only allows traffic where there is some L7 processing occurring on the path
var NoSelfCalls CombinationFilter = func(from echo.Instance, to echo.Instances) echo.Instances { return match.Not(match.ServiceName(from.NamespacedName())).GetMatches(to) }
NoSelfCalls disallows self-calls where from and to have the same service name. Self-calls can by-pass the sidecar, so tests relying on sidecar logic will sent to disable self-calls by default.
var ReachableDestinations CombinationFilter = func(from echo.Instance, to echo.Instances) echo.Instances { return match.And( reachableFromNaked(from), reachableFromVM(from), reachableFromProxylessGRPC(from), reachableNakedDestinations(from), reachableHeadlessDestinations(from), reachableWaypoints(from)). GetMatches(to) }
ReachableDestinations filters out known-unreachable destinations given a source. - from a naked pod, we can't reach cross-network endpoints or VMs - we can't reach cross-cluster headless endpoints - from an injected Pod, only non-naked cross-network endpoints are reachable
type Filter ¶
func FilterMatch ¶
FilterMatch returns a filter that simply applies the given matcher.
func SimplePodServiceAndAllSpecial ¶
SimplePodServiceAndAllSpecial finds the first Pod deployment that has a sidecar and doesn't use a headless service and removes all other "regular" pods that aren't part of the same Service. Pods that are part of the same Service but are in a different cluster or revision will still be included. Example:
- The full set of apps is a, b, c, d, e, headless, naked, and vm.
- The plain-pods are a, b and c.
- This filter would result in a, d, e, headless, naked and vm.
TODO this name is not good
type T ¶
type T struct {
// contains filtered or unexported fields
}
T enumerates subtests given a set of workloads as echo.Instances.
func New ¶
func New(ctx framework.TestContext, instances echo.Instances) *T
New creates a *T using the given applications as sources and destinations for each subtest.
func (*T) ConditionallyTo ¶
func (t *T) ConditionallyTo(filters ...CombinationFilter) *T
ConditionallyTo appends the given filters which are executed per test. Destination filters may need to change behavior based on the client. For example, naked services can't be reached cross-network, so the client matters. Example:
echotest.New(t, apps). ConditionallyTo(echotest.ReachableDestinations). Run()
func (*T) Config ¶
Config adds a configuration source that will be applied during the run of this tester.
func (*T) From ¶
From applies each of the filter functions in order to allow removing workloads from the set of clients. Example:
echotest.New(t, apps). From(echotest.SimplePodServiceAndAllSpecial, echotest.NoExternalServices). Run()
func (*T) Run ¶
func (t *T) Run(testFn oneToOneTest)
Run will generate and run one subtest to send traffic between each combination of source instance to target deployment.
For example, in a test named `a/to_b/from_cluster-0`, `a` is the source deployment, `b` is the destination deployment and `cluster-0` marks which instance of the source deployment.
We use a combination of deployment name and cluster name to identify a particular source instance, as there should typically be one instance per cluster for any deployment. However we do not identify a destination cluster, as we expect most tests will cause load-balancing across all possible clusters.
func (*T) RunFromClusters ¶
func (t *T) RunFromClusters(testFn oneClusterOneTest)
RunFromClusters will generate and run one subtest to send traffic to destination instance. This is for ingress gateway testing when source instance destination instances. This can be used when we're not using echo workloads as the source of traffic, such as from the ingress gateway. For example:
RunFromClusters(func(t framework.TestContext, src cluster.Cluster, dst echo.Instances)) { ingr := ist.IngressFor(src) ingr.CallWithRetryOrFail(...) })
func (*T) RunToN ¶
RunToN will generate nested subtests for every instance in every deployment subsets of the full set of deployments, such that every deployment is a destination at least once. To create as few subtests as possible, the same deployment may appear as a target in multiple subtests.
Example: Given a as the only source, with a, b, c, d as destinationsand n = 3, we get the following subtests:
- a/to_a_b_c/from_cluster_1:
- a/to_a_b_c/from_cluster_2:
- a/to_b_c_d/from_cluster_1:
- a/to_b_c_d/from_cluster_2:
func (*T) RunViaGatewayIngress ¶
func (*T) RunViaIngress ¶
func (t *T) RunViaIngress(testFn ingressTest)
func (*T) Setup ¶
Setup runs the given function in the source deployment context.
For example, given apps a, b, and c in 2 clusters, these tests would all run before the context is cleaned up:
- a/to_b/from_cluster-1
- a/to_b/from_cluster-2
- a/to_c/from_cluster-1
- a/to_c/from_cluster-2
- cleanup...
- b/to_a/from_cluster-1 ...
func (*T) SetupForDestination ¶
SetupForDestination is run each time the destination Service (but not destination cluster) changes.
func (*T) SetupForPair ¶
func (t *T) SetupForPair(setupFn func(ctx framework.TestContext, from echo.Callers, dsts echo.Instances) error) *T
SetupForPair runs the given function for every source instance in every cluster in combination with every destination service.
Example of how long this setup lasts before the given context is cleaned up:
- a/to_b/from_cluster-1
- a/to_b/from_cluster-2
- cleanup...
- a/to_b/from_cluster-2
- ...
func (*T) SetupForServicePair ¶
SetupForServicePair works similarly to SetupForPair, but the setup function accepts echo.Services, which contains instances for multiple services and should be used in combination with RunForN. The length of dsts services will always be N.
func (*T) To ¶
To applies each of the filter functions in order to allow removing workloads from the set of destinations. Example:
echotest.New(t, apps). To(echotest.SimplePodServiceAndAllSpecial). Run()
func (*T) WithDefaultFilters ¶
WithDefaultFilters applies common filters that work for most tests. Example:
- The full set of apps is a, b, c, d (dualStack), e (IPv6), headless, naked, and vm (one simple pod).
- Services d and e are used only when dualStack mode is enabled as part of the tests.
- Subtests are generated only for reachable destinations.