istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/components/echo/echotest/echotest.go (about)

     1  // Copyright Istio Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package echotest
    16  
    17  import (
    18  	"istio.io/istio/pkg/test/framework"
    19  	"istio.io/istio/pkg/test/framework/components/echo"
    20  	"istio.io/istio/pkg/test/framework/components/echo/config"
    21  	"istio.io/istio/pkg/test/framework/components/echo/match"
    22  )
    23  
    24  // T enumerates subtests given a set of workloads as echo.Instances.
    25  type T struct {
    26  	// rootCtx is the top level test context to generate subtests from and should only be referenced from RunX methods.
    27  	rootCtx framework.TestContext
    28  
    29  	sources      echo.Instances
    30  	destinations echo.Instances
    31  
    32  	destinationFilters []CombinationFilter
    33  
    34  	sourceDeploymentSetup      []srcSetupFn
    35  	deploymentPairSetup        []svcPairSetupFn
    36  	destinationDeploymentSetup []dstSetupFn
    37  
    38  	cfg *config.Builder
    39  }
    40  
    41  // New creates a *T using the given applications as sources and destinations for each subtest.
    42  func New(ctx framework.TestContext, instances echo.Instances) *T {
    43  	s, d := make(echo.Instances, len(instances)), make(echo.Instances, len(instances))
    44  	copy(s, instances)
    45  	copy(d, instances)
    46  	t := &T{
    47  		rootCtx:      ctx,
    48  		cfg:          config.New(ctx),
    49  		sources:      s,
    50  		destinations: d,
    51  	}
    52  	if ctx.Settings().Skip(echo.VM) {
    53  		t = t.FromMatch(match.NotVM).ToMatch(match.NotVM)
    54  	}
    55  	return t
    56  }