Documentation
¶
Index ¶
- Constants
- func GetChainlinkClients(env Environment) ([]client.Chainlink, error)
- func GetExplorerClientFromEnv(env Environment) (*client.ExplorerClient, error)
- func K8sConfig() (*rest.Config, error)
- func NewBlockchainClient(env Environment, network client.BlockchainNetwork) (client.BlockchainClient, error)
- func NewExplorerClient(localUrl string) (*client.ExplorerClient, error)
- func NewPrivateKeyStoreFromEnv(env Environment, network *config.NetworkConfig) (config.PrivateKeyStore, error)
- type Environment
- type ExternalAdapter
- type HelmChart
- func (k *HelmChart) Deploy(_ map[string]interface{}) error
- func (k *HelmChart) GetConfig() *config.Config
- func (k *HelmChart) ID() string
- func (k *HelmChart) ServiceDetails() ([]*ServiceDetails, error)
- func (k *HelmChart) SetEnvironment(environment *K8sEnvironment) error
- func (k *HelmChart) SetValue(key string, val interface{})
- func (k *HelmChart) Teardown() error
- func (k *HelmChart) Values() map[string]interface{}
- func (k *HelmChart) WaitUntilHealthy() error
- type K8sEnvResource
- type K8sEnvSpecInit
- type K8sEnvSpecs
- type K8sEnvironment
- func (env K8sEnvironment) ApplyChaos(exp chaos.Experimentable) (string, error)
- func (env K8sEnvironment) GetAllServiceDetails(remotePort uint16) ([]*ServiceDetails, error)
- func (env K8sEnvironment) GetPrivateKeyFromSecret(namespace string, privateKey string) (string, error)
- func (env K8sEnvironment) GetServiceDetails(remotePort uint16) (*ServiceDetails, error)
- func (env K8sEnvironment) ID() string
- func (env K8sEnvironment) StopAllChaos() error
- func (env K8sEnvironment) StopChaos(name string) error
- func (env K8sEnvironment) TearDown()
- func (env K8sEnvironment) WriteArtifacts(testLogFolder string)
- type K8sManifest
- func (m *K8sManifest) Deploy(values map[string]interface{}) error
- func (m *K8sManifest) ExecuteInPod(podName string, containerName string, command []string) ([]byte, []byte, error)
- func (m *K8sManifest) GetConfig() *config.Config
- func (m *K8sManifest) ID() string
- func (m *K8sManifest) ServiceDetails() ([]*ServiceDetails, error)
- func (m *K8sManifest) SetEnvironment(environment *K8sEnvironment) error
- func (m *K8sManifest) SetValue(key string, val interface{})
- func (m *K8sManifest) Teardown() error
- func (m *K8sManifest) Values() map[string]interface{}
- func (m *K8sManifest) WaitUntilHealthy() error
- type K8sManifestGroup
- func (mg *K8sManifestGroup) Deploy(values map[string]interface{}) error
- func (mg *K8sManifestGroup) GetConfig() *config.Config
- func (mg *K8sManifestGroup) ID() string
- func (mg *K8sManifestGroup) ServiceDetails() ([]*ServiceDetails, error)
- func (mg *K8sManifestGroup) SetEnvironment(env *K8sEnvironment) error
- func (mg *K8sManifestGroup) SetValue(key string, val interface{})
- func (mg *K8sManifestGroup) Teardown() error
- func (mg *K8sManifestGroup) Values() map[string]interface{}
- func (mg *K8sManifestGroup) WaitUntilHealthy() error
- type PodForwardedInfo
- type ServiceDetails
- type SetValuesHelmFunc
- type TemplateValuesArray
Constants ¶
const ( AdapterAPIPort = 6060 ChainlinkWebPort = 6688 ChainlinkP2PPort = 6690 EVMRPCPort = 8545 ExplorerAPIPort = 8080 )
const ( HelmInstallTimeout = 200 * time.Second ReleasePrefix = "release" DefaultK8sConfigPath = ".kube/config" )
const SelectorLabelKey string = "app"
Variables ¶
This section is empty.
Functions ¶
func GetChainlinkClients ¶
func GetChainlinkClients(env Environment) ([]client.Chainlink, error)
GetChainlinkClients will return all instantiated Chainlink clients for a given environment
func GetExplorerClientFromEnv ¶ added in v0.0.3
func GetExplorerClientFromEnv(env Environment) (*client.ExplorerClient, error)
GetExplorerClientFromEnv returns an ExplorerClient initialized with port from service in k8s
func NewBlockchainClient ¶
func NewBlockchainClient(env Environment, network client.BlockchainNetwork) (client.BlockchainClient, error)
NewBlockchainClient will return an instantiated blockchain client and switch the URL depending if there's one deployed into the environment. If there's no deployed blockchain in the environment, the URL from the network config will be used
func NewExplorerClient ¶ added in v0.0.3
func NewExplorerClient(localUrl string) (*client.ExplorerClient, error)
NewExplorerClient creates an ExplorerClient from localUrl
func NewPrivateKeyStoreFromEnv ¶
func NewPrivateKeyStoreFromEnv(env Environment, network *config.NetworkConfig) (config.PrivateKeyStore, error)
NewPrivateKeyStoreFromEnv returns a keystore looking either in a cluster secret or directly from the config
Types ¶
type Environment ¶
type Environment interface {
ID() string
GetAllServiceDetails(remotePort uint16) ([]*ServiceDetails, error)
GetServiceDetails(remotePort uint16) (*ServiceDetails, error)
GetPrivateKeyFromSecret(namespace string, privateKey string) (string, error)
WriteArtifacts(testLogFolder string)
ApplyChaos(exp chaos.Experimentable) (string, error)
StopChaos(name string) error
StopAllChaos() error
TearDown()
}
Environment is the interface that represents a deployed environment, whether locally or on remote machines
func NewK8sEnvironment ¶
func NewK8sEnvironment( init K8sEnvSpecInit, cfg *config.Config, network client.BlockchainNetwork, ) (Environment, error)
NewK8sEnvironment creates and deploys a full ephemeral environment in a k8s cluster. Your current context within your kube config will always be used.
type ExternalAdapter ¶
type ExternalAdapter interface {
TriggerValueChange(i int) (int, error)
LocalURL() string
ClusterURL() string
SetVariable(variable int) error
}
ExternalAdapter represents a dummy external adapter within the K8sEnvironment
func GetExternalAdapter ¶
func GetExternalAdapter(env Environment) (ExternalAdapter, error)
GetExternalAdapter will return a deployed external adapter on an environment
type HelmChart ¶ added in v0.0.2
type HelmChart struct {
SetValuesHelmFunc SetValuesHelmFunc
// contains filtered or unexported fields
}
HelmChart common helm chart data
func NewGethReorgHelmChart ¶ added in v0.0.2
func NewGethReorgHelmChart() *HelmChart
NewGethReorgHelmChart creates new helm chart for multi-node Geth network
func (*HelmChart) ServiceDetails ¶ added in v0.0.2
func (k *HelmChart) ServiceDetails() ([]*ServiceDetails, error)
func (*HelmChart) SetEnvironment ¶ added in v0.0.2
func (k *HelmChart) SetEnvironment(environment *K8sEnvironment) error
func (*HelmChart) WaitUntilHealthy ¶ added in v0.0.2
type K8sEnvResource ¶
type K8sEnvResource interface {
ID() string
GetConfig() *config.Config
SetEnvironment(environment *K8sEnvironment) error
Deploy(values map[string]interface{}) error
WaitUntilHealthy() error
ServiceDetails() ([]*ServiceDetails, error)
SetValue(key string, val interface{})
Values() map[string]interface{}
Teardown() error
}
K8sEnvResource is the interface for deploying a given environment resource. Creating an interface for resource deployment allows it to be extended, deploying k8s resources in different ways. For example: K8sManifest deploys a single manifest, whereas K8sManifestGroup bundles several K8sManifests to be deployed concurrently.
type K8sEnvSpecInit ¶
type K8sEnvSpecInit func(*config.NetworkConfig) (string, K8sEnvSpecs)
K8sEnvSpecInit is the initiator that will return the name of the environment and the specifications to be deployed. The name of the environment returned determines the namespace.
func NewChainlinkCluster ¶
func NewChainlinkCluster(nodeCount int) K8sEnvSpecInit
NewChainlinkCluster is a basic environment that deploys hardhat with a chainlink cluster and an external adapter
func NewChainlinkClusterForAlertsTesting ¶ added in v0.0.3
func NewChainlinkClusterForAlertsTesting(nodeCount int) K8sEnvSpecInit
func NewMixedVersionChainlinkCluster ¶
func NewMixedVersionChainlinkCluster(nodeCount, pastVersionsCount int) K8sEnvSpecInit
NewMixedVersionChainlinkCluster mixes the currently latest chainlink version (as defined by the config file) with a number of past stable versions (defined by pastVersionsCount), ensuring that at least one of each is deployed
type K8sEnvSpecs ¶
type K8sEnvSpecs []K8sEnvResource
K8sEnvSpecs represents a series of environment resources to be deployed. The resources in the array will be deployed in the order that they are present in the array.
type K8sEnvironment ¶
type K8sEnvironment struct {
// contains filtered or unexported fields
}
func (K8sEnvironment) ApplyChaos ¶ added in v0.0.2
func (env K8sEnvironment) ApplyChaos(exp chaos.Experimentable) (string, error)
ApplyChaos applies chaos experiment in the environment namespace
func (K8sEnvironment) GetAllServiceDetails ¶
func (env K8sEnvironment) GetAllServiceDetails(remotePort uint16) ([]*ServiceDetails, error)
GetAllServiceDetails returns all the connectivity details for a deployed service by its remote port within k8s
func (K8sEnvironment) GetPrivateKeyFromSecret ¶
func (env K8sEnvironment) GetPrivateKeyFromSecret(namespace string, privateKey string) (string, error)
func (K8sEnvironment) GetServiceDetails ¶
func (env K8sEnvironment) GetServiceDetails(remotePort uint16) (*ServiceDetails, error)
GetServiceDetails returns all the connectivity details for a deployed service by its remote port within k8s
func (K8sEnvironment) ID ¶
func (env K8sEnvironment) ID() string
ID returns the canonical name of the environment, which in the case of k8s is the namespace
func (K8sEnvironment) StopAllChaos ¶ added in v0.0.2
func (env K8sEnvironment) StopAllChaos() error
StopAllChaos stops all chaos experiments
func (K8sEnvironment) StopChaos ¶ added in v0.0.2
func (env K8sEnvironment) StopChaos(name string) error
StopChaos stops experiment by name
func (K8sEnvironment) TearDown ¶
func (env K8sEnvironment) TearDown()
TearDown cycles through all the specifications and tears down the deployments. This typically entails cleaning up port forwarding requests and deleting the namespace that then destroys all definitions.
func (K8sEnvironment) WriteArtifacts ¶
func (env K8sEnvironment) WriteArtifacts(testLogFolder string)
WriteArtifacts dumps pod logs and DB info within the environment into local log files, used near exclusively on test failure
type K8sManifest ¶
type K8sManifest struct {
// Manifest properties
DeploymentFile string
ServiceFile string
SecretFile string
ConfigMapFile string
Deployment *appsV1.Deployment
Service *coreV1.Service
ConfigMap *coreV1.ConfigMap
Secret *coreV1.Secret
SetValuesFunc k8sSetValuesFunc
// contains filtered or unexported fields
}
K8sManifest represents a manifest of k8s definitions to be deployed. It implements the K8sEnvResource interface to allow the deployment of the definitions into a cluster. It consists of a k8s secret, deployment and service but can be expanded to allow more definitions if needed, or extended with another interface to expand on its functionality.
func NewAdapterManifest ¶
func NewAdapterManifest() *K8sManifest
NewAdapterManifest is the k8s manifest that when used will deploy an external adapter to an environment
func NewChainlinkManifest ¶
func NewChainlinkManifest() *K8sManifest
NewChainlinkManifest is the k8s manifest that when used will deploy a chainlink node to an environment
func NewExplorerManifest ¶
func NewExplorerManifest(nodeCount int) *K8sManifest
NewExplorerManifest is the k8s manifest that when used will deploy explorer to an environment and create access keys for a nodeCount number of times
func NewGanacheManifest ¶
func NewGanacheManifest() *K8sManifest
NewGanacheManifest is the k8s manifest that when used will deploy ganache to an environment
func NewGethManifest ¶
func NewGethManifest() *K8sManifest
NewGethManifest is the k8s manifest that when used will deploy geth to an environment
func NewHardhatManifest ¶
func NewHardhatManifest() *K8sManifest
NewHardhatManifest is the k8s manifest that when used will deploy hardhat to an environment
func NewPostgresManifest ¶ added in v0.0.2
func NewPostgresManifest() *K8sManifest
NewPostgresManifest is the k8s manifest that when used will deploy a postgres db to an environment
func (*K8sManifest) Deploy ¶
func (m *K8sManifest) Deploy(values map[string]interface{}) error
Deploy will create the definitions for each manifest on the k8s cluster
func (*K8sManifest) ExecuteInPod ¶ added in v0.0.3
func (m *K8sManifest) ExecuteInPod(podName string, containerName string, command []string) ([]byte, []byte, error)
ExecuteInPod is similar to kubectl exec
func (*K8sManifest) GetConfig ¶ added in v0.0.2
func (m *K8sManifest) GetConfig() *config.Config
func (*K8sManifest) ID ¶
func (m *K8sManifest) ID() string
ID returns the identifier for the manifest. The ID is important as the manifest will automatically add labels and service selectors to link deployments to their manifests.
func (*K8sManifest) ServiceDetails ¶
func (m *K8sManifest) ServiceDetails() ([]*ServiceDetails, error)
ServiceDetails returns the connectivity details for a deployed service
func (*K8sManifest) SetEnvironment ¶
func (m *K8sManifest) SetEnvironment( environment *K8sEnvironment, ) error
SetEnvironment is the K8sEnvResource implementation that sets the current cluster and config to be used on deploy
func (*K8sManifest) SetValue ¶ added in v0.0.2
func (m *K8sManifest) SetValue(key string, val interface{})
func (*K8sManifest) Teardown ¶
func (m *K8sManifest) Teardown() error
Teardown sends a message to the port forwarding channels to stop the request
func (*K8sManifest) Values ¶
func (m *K8sManifest) Values() map[string]interface{}
Values returns all the values to be exposed in the definition templates
func (*K8sManifest) WaitUntilHealthy ¶
func (m *K8sManifest) WaitUntilHealthy() error
WaitUntilHealthy will wait until all pods that are created from a given manifest are healthy. Once healthy, it will then forward all ports that are exposed within the service and callback to set values.
type K8sManifestGroup ¶
type K8sManifestGroup struct {
SetValuesFunc manifestGroupSetValuesFunc
// contains filtered or unexported fields
}
K8sManifestGroup is an implementation of K8sEnvResource that allows a group of manifests to be deployed concurrently on the cluster. This is important for services that don't have dependencies on each other. For example: a Chainlink node doesn't depend on other Chainlink nodes on deploy and an adapter doesn't depend on Chainlink nodes on deploy, only later on within the test lifecycle which means they can be included within a single group. Whereas, Chainlink does depend on a deployed Geth, Hardhat, Ganache on deploy so they cannot be included in the group as Chainlink definition needs to know the cluster IP of the deployment for it to boot.
func (*K8sManifestGroup) Deploy ¶
func (mg *K8sManifestGroup) Deploy(values map[string]interface{}) error
Deploy concurrently creates all of the definitions on the k8s cluster
func (*K8sManifestGroup) GetConfig ¶ added in v0.0.2
func (mg *K8sManifestGroup) GetConfig() *config.Config
func (*K8sManifestGroup) ID ¶
func (mg *K8sManifestGroup) ID() string
ID returns the identifier of the manifest group
func (*K8sManifestGroup) ServiceDetails ¶
func (mg *K8sManifestGroup) ServiceDetails() ([]*ServiceDetails, error)
ServiceDetails will return all the details of the services within a group
func (*K8sManifestGroup) SetEnvironment ¶
func (mg *K8sManifestGroup) SetEnvironment(env *K8sEnvironment) error
SetEnvironment initiates the k8s cluster and config within all the nested manifests
func (*K8sManifestGroup) SetValue ¶ added in v0.0.2
func (mg *K8sManifestGroup) SetValue(key string, val interface{})
func (*K8sManifestGroup) Teardown ¶
func (mg *K8sManifestGroup) Teardown() error
Teardown will iterate through each manifest and tear it down
func (*K8sManifestGroup) Values ¶
func (mg *K8sManifestGroup) Values() map[string]interface{}
Values will return all of the defined values to be exposed in the template definitions. Due to there possibly being multiple of the same manifest in the group, it will create keys of each manifest id, also keys with each manifest followed by its index. For example: values["adapter"].apiPort values["chainlink"].webPort values["chainlink_0"].webPort values["chainlink_1"].webPort
func (*K8sManifestGroup) WaitUntilHealthy ¶
func (mg *K8sManifestGroup) WaitUntilHealthy() error
WaitUntilHealthy will wait until all of the manifests in the group are considered healthy. To avoid it duplicating checks for multiple of the same manifest in a group, it will first create a unique map of manifest IDs so checks aren't performed multiple times.
type PodForwardedInfo ¶ added in v0.0.2
type PodForwardedInfo struct {
PodIP string
ForwardedPorts []portforward.ForwardedPort
PodName string
}
type ServiceDetails ¶
ServiceDetails contains all of the connectivity properties about a given deployed service
type SetValuesHelmFunc ¶ added in v0.0.2
type TemplateValuesArray ¶ added in v0.0.3
type TemplateValuesArray struct {
Values []interface{}
// contains filtered or unexported fields
}
TemplateValuesArray is used in the next template go func It's goal is to store an array of objects The only function it has, next, returns the first object from they array, and then removing that object from the array