Documentation ¶
Index ¶
- Constants
- func ChainlinkReplicas(count int, values map[string]interface{}) map[string]interface{}
- func ChainlinkVersion(version string, values map[string]interface{}) map[string]interface{}
- func DefaultGeth() (string, map[string]interface{})
- func DumpConfig(cfg *Config, path string) error
- func DumpConfigJson(cfg *Config, path string) error
- func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error)
- func PerformanceGeth() (string, map[string]interface{})
- func RealisticGeth() (string, map[string]interface{})
- type Artifacts
- type ChartConnection
- type ChartConnections
- func (cc ChartConnections) Load(app, instance, name string) (*ChartConnection, error)
- func (cc *ChartConnections) LoadByPort(port int) ([]*ChartConnection, error)
- func (cc *ChartConnections) LoadByPortName(portName string) ([]*ChartConnection, error)
- func (cc *ChartConnections) LocalURLByPort(portName string, protocol Protocol) (*url.URL, error)
- func (cc *ChartConnections) LocalURLs(stringDirective string, portName string) ([]*url.URL, error)
- func (cc *ChartConnections) LocalURLsByPort(portName string, protocol Protocol) ([]*url.URL, error)
- func (cc ChartConnections) Range(f func(key string, chartConnection *ChartConnection) bool)
- func (cc *ChartConnections) RemoteURLByPort(portName string, protocol Protocol) (*url.URL, error)
- func (cc *ChartConnections) RemoteURLs(stringDirective string, portName string) ([]*url.URL, error)
- func (cc *ChartConnections) RemoteURLsByPort(portName string, protocol Protocol) ([]*url.URL, error)
- func (cc ChartConnections) Store(app, instance, name string, chartConnection *ChartConnection) error
- type Charts
- func (c Charts) Connections(chart string) *ChartConnections
- func (c Charts) Decode(value string) error
- func (c Charts) ExecuteInPod(chartName string, podNameSubstring string, podIndex int, containerName string, ...) error
- func (c Charts) Get(chartName string) (*HelmChart, error)
- func (c Charts) OrderedKeys() [][]string
- type Config
- func NewChainlinkCCIPConfig(chainlinkValues map[string]interface{}) *Config
- func NewChainlinkConfig(chainlinkValues map[string]interface{}, optionalNamespacePrefix string, ...) *Config
- func NewChainlinkReorgConfig(chainlinkValues map[string]interface{}) *Config
- func NewTerraChainlinkConfig(chainlinkValues map[string]interface{}) *Config
- type Environment
- func DeployEnvironment(config *Config, chartDirectory string) (*Environment, error)
- func DeployLongTestEnvironment(config *Config, ...) (*Environment, error)
- func DeployOrLoadEnvironment(config *Config, chartDirectory string) (*Environment, error)
- func DeployOrLoadEnvironmentFromConfigFile(chartDirectory, configFilePath string) (*Environment, error)
- func LoadEnvironment(config *Config) (*Environment, error)
- func NewEnvironment(config *Config) (*Environment, error)
- func (k *Environment) AddChart(chart *HelmChart) error
- func (k *Environment) AddLabel(selector string, label string) error
- func (k *Environment) ApplyChaosExperiment(exp chaos.Experimentable) (string, error)
- func (k *Environment) ApplyChaosExperimentFromTemplate(tmplPath string) error
- func (k *Environment) ClearAllChaosExperiments() error
- func (k *Environment) ClearAllChaosStandaloneExperiments(expInfos map[string]*chaos.ExperimentInfo) error
- func (k *Environment) ClearConfig() error
- func (k *Environment) ClearConfigLocalPorts() error
- func (k *Environment) Connect(chartName string) error
- func (k *Environment) ConnectAll() error
- func (k *Environment) DeferTeardown()
- func (k *Environment) Deploy(chartName string) error
- func (k *Environment) DeployAll() error
- func (k *Environment) Disconnect()
- func (k *Environment) GetSecretField(namespace string, secretName string, fieldName string) (string, error)
- func (k *Environment) Init(namespacePrefix string) error
- func (k *Environment) StopChaosExperiment(id string) error
- func (k *Environment) StopChaosStandaloneExperiment(expInfo *chaos.ExperimentInfo) error
- func (k *Environment) SyncConfig() error
- func (k *Environment) SyncConfigJson() error
- func (k *Environment) Teardown() error
- func (k *Environment) Upgrade(chartName string) error
- type HelmChart
- func (hc *HelmChart) Connect() error
- func (hc *HelmChart) CopyToPod(src, destination, containername string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)
- func (hc *HelmChart) Deploy() error
- func (hc *HelmChart) ExecuteInPod(podName string, containerName string, command []string) ([]byte, []byte, error)
- func (hc *HelmChart) GetPodsByNameSubstring(nameSubstring string) ([]v1.Pod, error)
- func (hc *HelmChart) Init(env *Environment) error
- func (hc *HelmChart) Upgrade() error
- type Hook
- type MarshalSafeDuration
- type Protocol
- type SimulatedNetwork
Constants ¶
const ( // HelmInstallTimeout timeout for installing a helm chart HelmInstallTimeout = 200 * time.Second // DefaultK8sConfigPath the default path for kube DefaultK8sConfigPath = ".kube/config" )
const ( // AppEnumerationLabelKey label used to enumerate instances of the same app to ease access AppEnumerationLabelKey = "app" // InstanceEnumerationLabelKey additional label to enumerate app instances InstanceEnumerationLabelKey = "instance" )
Variables ¶
This section is empty.
Functions ¶
func ChainlinkReplicas ¶
ChainlinkReplicas sets the replica count of chainlink nodes to use
func ChainlinkVersion ¶
ChainlinkVersion sets the version of the chainlink image to use
func DefaultGeth ¶ added in v1.0.52
DefaultGeth sets up a basic, low-power simulated geth instance. Really just returns empty map to use default values
func DumpConfig ¶
DumpConfig dumps config to a yaml file
func DumpConfigJson ¶
DumpConfigJson dumps config to a json file
func GetLocalK8sDeps ¶
func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error)
GetLocalK8sDeps get local k8s connection deps
func PerformanceGeth ¶ added in v1.0.52
PerformanceGeth sets up the simulated geth instance with more power, bigger blocks, and faster mining
func RealisticGeth ¶ added in v1.0.52
RealisticGeth sets up the simulated geth instance to emulate the actual ethereum mainnet as close as possible
Types ¶
type Artifacts ¶
type Artifacts struct { DBName string // contains filtered or unexported fields }
Artifacts is an artifacts dumping structure that copies logs and database dumps for all deployed pods
func NewArtifacts ¶
func NewArtifacts(env *Environment) (*Artifacts, error)
NewArtifacts create new artifacts instance for provided environment
type ChartConnection ¶
type ChartConnection struct { PodName string `yaml:"pod_name,omitempty" json:"pod_name" envconfig:"pod_name"` PodIP string `yaml:"pod_ip,omitempty" json:"pod_ip" envconfig:"pod_ip"` RemotePorts map[string]int `yaml:"remote_ports,omitempty" json:"remote_ports" envconfig:"remote_ports"` LocalPorts map[string]int `yaml:"local_ports,omitempty" json:"local_ports" envconfig:"local_ports"` }
ChartConnection info about connected pod ports
type ChartConnections ¶
type ChartConnections map[string]*ChartConnection
ChartConnections represents a group of pods and their connection info deployed within the same chart
func (ChartConnections) Load ¶
func (cc ChartConnections) Load(app, instance, name string) (*ChartConnection, error)
Load emulates the Load sync.Map function to use the common map key and return the value correctly typed
func (*ChartConnections) LoadByPort ¶
func (cc *ChartConnections) LoadByPort(port int) ([]*ChartConnection, error)
LoadByPort scans all the connections and returns a list of connections if they contain a certain port number
func (*ChartConnections) LoadByPortName ¶
func (cc *ChartConnections) LoadByPortName(portName string) ([]*ChartConnection, error)
LoadByPortName scans all the connections and returns a list of connections if they contain a certain port name
func (*ChartConnections) LocalURLByPort ¶
LocalURLByPort returns a parsed URL of a local port-forwarded service based on the port name
func (*ChartConnections) LocalURLs ¶
LocalURLs scans all the connections returns remote URLs based on a port number of a service and a string directive
func (*ChartConnections) LocalURLsByPort ¶
LocalURLsByPort returns parsed URLs of a local port-forwarded service based on the port name
func (ChartConnections) Range ¶
func (cc ChartConnections) Range(f func(key string, chartConnection *ChartConnection) bool)
Range emulates the default range function in the sync.Map, without the need to cast the key & value
func (*ChartConnections) RemoteURLByPort ¶
RemoteURLByPort returns a parsed URL of a remote service based on the port name
func (*ChartConnections) RemoteURLs ¶
RemoteURLs scans all the connections returns remote URLs based on a port number of a service and a string directive
func (*ChartConnections) RemoteURLsByPort ¶
func (cc *ChartConnections) RemoteURLsByPort(portName string, protocol Protocol) ([]*url.URL, error)
RemoteURLsByPort returns parsed URLs of a remote service based on the port name
func (ChartConnections) Store ¶
func (cc ChartConnections) Store(app, instance, name string, chartConnection *ChartConnection) error
Store emulates the default Store function within the sync.Map to use the common map key and value types and return an error if the key is a duplicate
type Charts ¶
Charts represents a map of charts with some helper methods
func (Charts) Connections ¶
func (c Charts) Connections(chart string) *ChartConnections
Connections is a helper method for simply accessing chart connections, also safely allowing method chaining
func (Charts) Decode ¶
Decode is used by envconfig to initialize the custom Charts type with populated values This function will take a JSON object representing charts, and unmarshal it into the existing object to "merge" the two
func (Charts) ExecuteInPod ¶
func (c Charts) ExecuteInPod(chartName string, podNameSubstring string, podIndex int, containerName string, command []string) error
ExecuteInPod is similar to kubectl exec
func (Charts) OrderedKeys ¶
OrderedKeys returns an ordered list of the map keys based on the charts Index value
type Config ¶
type Config struct { Path string `yaml:"-" json:"-" envconfig:"config_path"` QPS float32 `yaml:"qps" json:"qps" envconfig:"qps" default:"50"` Burst int `yaml:"burst" json:"burst" envconfig:"burst" default:"50"` MarshalSafeTimeout MarshalSafeDuration `yaml:"timeout" json:"timeout" ignored:"true" default:"3m"` Timeout time.Duration `yaml:"-" json:"-" envconfig:"timeout" default:"3m"` Persistent bool `yaml:"persistent" json:"persistent" envconfig:"persistent"` NamespacePrefix string `yaml:"namespace_prefix,omitempty" json:"namespace_prefix,omitempty" envconfig:"namespace_prefix"` Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty" envconfig:"namespace"` Charts Charts `yaml:"charts,omitempty" json:"charts,omitempty" envconfig:"charts"` Experiments map[string]*chaos.ExperimentInfo `yaml:"experiments,omitempty" json:"experiments,omitempty" envconfig:"experiments"` }
Config represents the full configuration of an environment, it can either be defined programmatically at runtime, or defined in files to be used in a CLI or any other application
func NewChainlinkCCIPConfig ¶
NewChainlinkCCIPConfig returns a Chainlink environment for the purpose of CCIP testing
func NewChainlinkConfig ¶
func NewChainlinkConfig( chainlinkValues map[string]interface{}, optionalNamespacePrefix string, networks ...SimulatedNetwork, ) *Config
NewChainlinkConfig returns a vanilla Chainlink environment used for generic functional testing. Geth networks can be passed in to launch differently configured simulated geth instances.
func NewChainlinkReorgConfig ¶
NewChainlinkReorgConfig returns a Chainlink environment designed for simulating re-orgs within testing
func NewTerraChainlinkConfig ¶
NewTerraChainlinkConfig returns a Chainlink environment designed for testing with a Terra relay
type Environment ¶
type Environment struct { *Config Artifacts *Artifacts Chaos *chaos.Controller // contains filtered or unexported fields }
Environment build and deployed from several helm Charts
func DeployEnvironment ¶
func DeployEnvironment(config *Config, chartDirectory string) (*Environment, error)
DeployEnvironment returns a deployed environment from a given config that can be pre-defined within the library, or passed in as part of lib usage
func DeployLongTestEnvironment ¶
func DeployLongTestEnvironment( config *Config, chartDirectory, testName, slackAPI, slackChannel, slackUser, frameworkConfigPath, networksConfigPath, testExecutablePath string, ) (*Environment, error)
DeployLongTestEnvironment is used for deploying environment that expect to be running a test for a long time (more than 30 minutes).
func DeployOrLoadEnvironment ¶
func DeployOrLoadEnvironment(config *Config, chartDirectory string) (*Environment, error)
DeployOrLoadEnvironment returns a deployed environment from a given preset that can be ones pre-defined within the library, or passed in as part of lib usage
func DeployOrLoadEnvironmentFromConfigFile ¶
func DeployOrLoadEnvironmentFromConfigFile(chartDirectory, configFilePath string) (*Environment, error)
DeployOrLoadEnvironmentFromConfigFile returns an environment based on a preset file, mostly for use as a presets CLI
func LoadEnvironment ¶
func LoadEnvironment(config *Config) (*Environment, error)
LoadEnvironment loads an already deployed environment from config
func NewEnvironment ¶
func NewEnvironment(config *Config) (*Environment, error)
NewEnvironment creates new environment from charts
func (*Environment) AddChart ¶
func (k *Environment) AddChart(chart *HelmChart) error
AddChart adds chart to deploy
func (*Environment) AddLabel ¶
func (k *Environment) AddLabel(selector string, label string) error
AddLabel adds a new label to a group of pods defined by selector
func (*Environment) ApplyChaosExperiment ¶
func (k *Environment) ApplyChaosExperiment(exp chaos.Experimentable) (string, error)
ApplyChaosExperiment applies experiment to an ephemeral env
func (*Environment) ApplyChaosExperimentFromTemplate ¶
func (k *Environment) ApplyChaosExperimentFromTemplate(tmplPath string) error
ApplyChaosExperimentFromTemplate applies experiment to a standalone env
func (*Environment) ClearAllChaosExperiments ¶
func (k *Environment) ClearAllChaosExperiments() error
ClearAllChaosExperiments clears all chaos experiments
func (*Environment) ClearAllChaosStandaloneExperiments ¶
func (k *Environment) ClearAllChaosStandaloneExperiments(expInfos map[string]*chaos.ExperimentInfo) error
ClearAllChaosStandaloneExperiments remove all chaos experiments from a standalone env
func (*Environment) ClearConfig ¶
func (k *Environment) ClearConfig() error
ClearConfig resets the config so only the preset config remains
func (*Environment) ClearConfigLocalPorts ¶
func (k *Environment) ClearConfigLocalPorts() error
ClearConfigLocalPorts removes the local ports set within config
func (*Environment) Connect ¶
func (k *Environment) Connect(chartName string) error
Connect to a single chart
func (*Environment) ConnectAll ¶
func (k *Environment) ConnectAll() error
ConnectAll connects to all containerPorts for all charts, dump config in JSON if Persistent flag is present
func (*Environment) DeferTeardown ¶
func (k *Environment) DeferTeardown()
DeferTeardown wraps teardown and logs on error, to be used in deferred function calls
func (*Environment) Deploy ¶
func (k *Environment) Deploy(chartName string) error
Deploy a single chart
func (*Environment) DeployAll ¶
func (k *Environment) DeployAll() error
DeployAll deploys all deploy sequence at once
func (*Environment) Disconnect ¶
func (k *Environment) Disconnect()
Disconnect closes any current open port forwarder rules
func (*Environment) GetSecretField ¶
func (k *Environment) GetSecretField(namespace string, secretName string, fieldName string) (string, error)
GetSecretField retrieves field data from k8s secret
func (*Environment) Init ¶
func (k *Environment) Init(namespacePrefix string) error
Init inits namespace for an env and configure helm for k8s and that namespace
func (*Environment) StopChaosExperiment ¶
func (k *Environment) StopChaosExperiment(id string) error
StopChaosExperiment stops experiment in a ephemeral env
func (*Environment) StopChaosStandaloneExperiment ¶
func (k *Environment) StopChaosStandaloneExperiment(expInfo *chaos.ExperimentInfo) error
StopChaosStandaloneExperiment stops experiment in a standalone env
func (*Environment) SyncConfig ¶
func (k *Environment) SyncConfig() error
SyncConfig dumps config in Persistent mode
func (*Environment) SyncConfigJson ¶
func (k *Environment) SyncConfigJson() error
SyncConfigJson dumps a json config in Persistent mode
func (*Environment) Teardown ¶
func (k *Environment) Teardown() error
Teardown tears down the helm releases
func (*Environment) Upgrade ¶
func (k *Environment) Upgrade(chartName string) error
Upgrade a single chart
type HelmChart ¶
type HelmChart struct { ReleaseName string `yaml:"release_name,omitempty" json:"release_name,omitempty" envconfig:"release_name"` Path string `yaml:"path,omitempty" json:"path,omitempty" envconfig:"path"` URL string `yaml:"url,omitempty" json:"url,omitempty" envconfig:"url"` Values map[string]interface{} `yaml:"values,omitempty" json:"values,omitempty" envconfig:"values"` Index int `yaml:"index,omitempty" json:"index,omitempty" envconfig:"index"` AutoConnect bool `yaml:"auto_connect" json:"auto_connect" envconfig:"auto_connect"` ChartConnections ChartConnections `yaml:"chart_connections,omitempty" json:"chart_connections,omitempty" envconfig:"chart_connections"` BeforeHook Hook `yaml:"-" json:"-" envconfig:"-"` AfterHook Hook `yaml:"-" json:"-" envconfig:"-"` // contains filtered or unexported fields }
HelmChart represents a single Helm chart to be installed into a cluster
func NewChainlinkChart ¶
NewChainlinkChart returns a default Chainlink Helm chart based on a set of override values
func (*HelmChart) CopyToPod ¶
func (hc *HelmChart) CopyToPod(src, destination, containername string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)
CopyToPod copies src to a particular container. Destination should be in the form of a proper K8s destination path NAMESPACE/POD_NAME:folder/FILE_NAME
func (*HelmChart) ExecuteInPod ¶
func (hc *HelmChart) ExecuteInPod(podName string, containerName string, command []string) ([]byte, []byte, error)
ExecuteInPod is similar to kubectl exec
func (*HelmChart) GetPodsByNameSubstring ¶
GetPodsByNameSubstring retrieves all running pods whose names contain the provided substring
func (*HelmChart) Init ¶
func (hc *HelmChart) Init(env *Environment) error
Init sets up the connection to helm for the chart to be managed
type Hook ¶
type Hook func(environment *Environment) error
Hook is an environment hook to be ran either before or after a deployment
type MarshalSafeDuration ¶
MarshalSafeDuration enables proper json marshalling and unmarshaling for config values See: https://stackoverflow.com/questions/48050945/how-to-unmarshal-json-into-durations
func (MarshalSafeDuration) AsTimeDuration ¶
func (d MarshalSafeDuration) AsTimeDuration() time.Duration
AsTimeDuration returns as a standard time.Duration
func (MarshalSafeDuration) MarshalJSON ¶
func (d MarshalSafeDuration) MarshalJSON() ([]byte, error)
MarshalJSON marshals durations into proper json
func (*MarshalSafeDuration) UnmarshalJSON ¶
func (d *MarshalSafeDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals durations into proper json
type Protocol ¶
type Protocol int
Protocol represents a URL scheme to use when fetching connection details
type SimulatedNetwork ¶ added in v1.0.52
SimulatedNetwork is a function that enables launching a simulated network with a returned chart name and corresponding values