Documentation
¶
Index ¶
- Constants
- func GetChainlinkClients(env Environment) ([]client.Chainlink, error)
- func GetExplorerMockClient(env Environment) (*client.ExplorerClient, error)
- func NewBlockchainClient(env Environment, network client.BlockchainNetwork) (client.BlockchainClient, error)
- func NewPrivateKeyStoreFromEnv(env Environment, network *config.NetworkConfig) (config.PrivateKeyStore, error)
- type Environment
- type ExternalAdapter
- type K8sEnvResource
- type K8sEnvSpecInit
- type K8sEnvSpecs
- type K8sEnvironment
- 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) TearDown()
- func (env K8sEnvironment) WriteArtifacts(testLogFolder string)
- type K8sManifest
- func (m *K8sManifest) Deploy(values map[string]interface{}) error
- func (m *K8sManifest) ID() string
- func (m *K8sManifest) ServiceDetails() ([]*ServiceDetails, error)
- func (m *K8sManifest) SetEnvironment(k8sClient *kubernetes.Clientset, k8sConfig *rest.Config, config *config.Config, ...) error
- 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) ID() string
- func (mg *K8sManifestGroup) ServiceDetails() ([]*ServiceDetails, error)
- func (mg *K8sManifestGroup) SetEnvironment(k8sClient *kubernetes.Clientset, k8sConfig *rest.Config, config *config.Config, ...) error
- func (mg *K8sManifestGroup) Teardown() error
- func (mg *K8sManifestGroup) Values() map[string]interface{}
- func (mg *K8sManifestGroup) WaitUntilHealthy() error
- type ServiceDetails
Constants ¶
const ( AdapterAPIPort = 6060 ChainlinkWebPort = 6688 ChainlinkP2PPort = 6690 EVMRPCPort = 8545 ExplorerWSPort = 4321 )
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 GetExplorerMockClient ¶
func GetExplorerMockClient(env Environment) (*client.ExplorerClient, error)
GetExplorerMockClient will return all instantiated Explorer mock client for a given environment
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 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)
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 K8sEnvResource ¶
type K8sEnvResource interface {
ID() string
SetEnvironment(
k8sClient *kubernetes.Clientset,
k8sConfig *rest.Config,
config *config.Config,
network *config.NetworkConfig,
namespace *coreV1.Namespace,
) error
Deploy(values map[string]interface{}) error
WaitUntilHealthy() error
ServiceDetails() ([]*ServiceDetails, error)
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 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 map[int]K8sEnvResource
K8sEnvSpecs represents a series of environment resources to be deployed. The map keys need to be continuous with no gaps. For example: 0: Hardhat 1: Adapter 2: Chainlink cluster
type K8sEnvironment ¶
type K8sEnvironment struct {
// contains filtered or unexported fields
}
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) 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() *K8sManifest
NewExplorerManifest is the k8s manifest that when used will deploy explorer mock service
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 (*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) 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( k8sClient *kubernetes.Clientset, k8sConfig *rest.Config, config *config.Config, network *config.NetworkConfig, namespace *coreV1.Namespace, ) error
SetEnvironment is the K8sEnvResource implementation that sets the current cluster and config to be used on deploy
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 {
// 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) 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( k8sClient *kubernetes.Clientset, k8sConfig *rest.Config, config *config.Config, network *config.NetworkConfig, namespace *coreV1.Namespace, ) error
SetEnvironment initiates the k8s cluster and config within all the nested manifests
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.