istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/components/echo/flags.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 echo
    16  
    17  import (
    18  	"flag"
    19  	"time"
    20  
    21  	"istio.io/istio/pkg/test/util/retry"
    22  )
    23  
    24  var (
    25  	callTimeout      = 30 * time.Second
    26  	callDelay        = 20 * time.Millisecond
    27  	callConverge     = 3
    28  	readinessTimeout = 10 * time.Minute
    29  	callsPerWorkload = 3
    30  )
    31  
    32  // init registers the command-line flags that we can exposed for "go test".
    33  func init() {
    34  	flag.DurationVar(&callTimeout, "istio.test.echo.callTimeout", callTimeout,
    35  		"Specifies the default total timeout used when retrying calls to the Echo service")
    36  	flag.DurationVar(&callDelay, "istio.test.echo.callDelay", callDelay,
    37  		"Specifies the default delay between successive retry attempts when calling the Echo service")
    38  	flag.IntVar(&callConverge, "istio.test.echo.callConverge", callConverge,
    39  		"Specifies the number of successive retry attempts that must be successful when calling the Echo service")
    40  	flag.DurationVar(&readinessTimeout, "istio.test.echo.readinessTimeout", readinessTimeout,
    41  		"Specifies the default timeout for echo readiness check")
    42  	flag.IntVar(&callsPerWorkload, "istio.test.echo.callsPerWorkload", callsPerWorkload,
    43  		"Specifies the number of calls that will be made for each target workload. "+
    44  			"Only applies if the call count is zero (default) and a target was specified for the call")
    45  }
    46  
    47  // DefaultCallRetryOptions returns the default call retry options as specified in command-line flags.
    48  func DefaultCallRetryOptions() []retry.Option {
    49  	return []retry.Option{retry.Timeout(callTimeout), retry.BackoffDelay(callDelay), retry.Converge(callConverge)}
    50  }
    51  
    52  // DefaultReadinessTimeout returns the default echo readiness check timeout.
    53  func DefaultReadinessTimeout() time.Duration {
    54  	return readinessTimeout
    55  }
    56  
    57  // DefaultCallsPerWorkload returns the number of calls that should be made per target workload by default.
    58  func DefaultCallsPerWorkload() int {
    59  	return callsPerWorkload
    60  }