apitest

package
v0.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = ClientConfiguration{
	ClientCredentials: clientcredentials.Config{
		EndpointParams: map[string][]string{"audience": {"https://api.carbonrelay.io/v1/"}},
		AuthStyle:      oauth2.AuthStyleInParams,
	},
}

DefaultConfig is a client configuration to use for integration testing. It's default values are populated using flags.

Functions

func NewClient

func NewClient(ctx context.Context) (api.Client, error)

NewClient returns a new API client from the default configuration.

Types

type ApplicationTestDefinition added in v0.0.15

type ApplicationTestDefinition struct {
	Application applications.Application
	Scenario    applications.Scenario

	// In addition to the application and scenario, we need an experiment.
	ExperimentTestDefinition
}

ApplicationTestDefinition is used to define tests to run against an application API implementation.

func ReadApplicationTestData added in v0.0.15

func ReadApplicationTestData(path string) ([]ApplicationTestDefinition, error)

ReadApplicationTestData reads all of the JSON files in the supplied test data directory.

func (*ApplicationTestDefinition) GenerateTemplate added in v0.0.15

func (td *ApplicationTestDefinition) GenerateTemplate() applications.Template

GenerateTemplate returns details of experiment for this test definition.

type ClientConfiguration

type ClientConfiguration struct {
	// The URL of the StormForge server.
	Address string
	// A static token to use for authorization.
	StaticToken oauth2.Token
	// Configuration to use a client credentials grant for authorization.
	ClientCredentials clientcredentials.Config
}

ClientConfiguration is used to gather configuration for an integration testing API client.

func (*ClientConfiguration) Authorization

func (c *ClientConfiguration) Authorization(ctx context.Context) http.RoundTripper

Authorization returns a round tripper for handling request authorization. May return `nil` to allow for accessing unprotected endpoints.

type ExperimentTestDefinition added in v0.0.15

type ExperimentTestDefinition struct {
	// The name of the experiment to create during the test.
	ExperimentName experiments.ExperimentName
	// The experiment definition for testing.
	Experiment experiments.Experiment
	// A list of assignments for the baseline trial. May be empty to skip baseline trial tests.
	Baseline []experiments.Assignment
	// A matrix of weights used to map a vector of parameter assignments to a vector of metric values.
	Values [][]float64
	// The list of conditions to report as a failure.
	Failures []struct {
		// The parameter or metric name (assumes they never conflict).
		Name string
		// The optional minimum value to trigger the failure.
		Min *float64
		// The optional maximum value to trigger the failure.
		Max *float64
		// The failure reason to report when the condition is triggered.
		Reason string
		// The failure message to report when the condition is triggered.
		Message string
	}
}

ExperimentTestDefinition is used to define tests to run against an experiments API implementation.

func ReadExperimentsTestData added in v0.0.15

func ReadExperimentsTestData(path string) ([]ExperimentTestDefinition, error)

ReadExperimentsTestData reads all of the JSON files in the supplied test data directory.

func (*ExperimentTestDefinition) TrialResults added in v0.0.15

TrialResults computes dummy trial results for the supplied assignments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL