This document describes the overall architecture of the Istio test framework and describes how to extend its capabilities.
At a high-level, the framework is simple:
The Runtime
creates the Context
, which is the main API to the test code. The Runtime
chooses the appropriate
component Registry
based on the flags and then provides it to the Context
. When the test Require
s components,
the Context
looks them up in the Registry
, which provides factories for the components.
To add a new component API:
- Add the Go file for the interface to api/components, along with a
GetXXX
function for extracting that component from the context. - Add an ID for the component to ids.go.
- Add a Descriptor for the component to descriptors.go.
- If a single environment can support multiple versions of a component (e.g. real vs fake), specify the
Variant
to distinguish between the two. - At a minimum, the descriptor should require
ids.Environment
.
- If a single environment can support multiple versions of a component (e.g. real vs fake), specify the
Once you have a component API, you can add an implementation as follows:
- Create the directory
runtime/components/<component_name>
which will hold the implementation. - Under that directory, write a Go class implementing the component API and write a factory method for constructing it.
- Register your component with one of the environment registries defined in registries.go.
Environments are just slightly specialized components, so the process for adding an environment is similar. The interface for Environment is part of the runtime and is located at [runtime/api/environment.go].
To add a new environment, follow these steps:
- Create the directory
runtime/components/environment/<environment>
which will hold the implementation. - Under that directory, write a Go class implementing the Environment API and write a factory method for constructing it.
- In registries.go add a new variable for the environment. For example:
MyEnv = newEnvironment(descriptors.MyEnvironment, myenv.NewEnvironment)
. - In registries.go register any components with the new environment.