Skip to content

Commit

Permalink
Read private ethereum config from env (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcl authored Sep 23, 2024
1 parent 2a5f3f4 commit 2ba5125
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
55 changes: 29 additions & 26 deletions lib/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,35 @@ import (
)

const (
E2E_TEST_LOG_COLLECT_ENV = "E2E_TEST_LOG_COLLECT"
E2E_TEST_LOGGING_RUN_ID_ENV = "E2E_TEST_LOGGING_RUN_ID"
E2E_TEST_LOG_STREAM_LOG_TARGETS_ENV = "E2E_TEST_LOG_STREAM_LOG_TARGETS"
E2E_TEST_LOKI_TENANT_ID_ENV = "E2E_TEST_LOKI_TENANT_ID"
E2E_TEST_LOKI_ENDPOINT_ENV = "E2E_TEST_LOKI_ENDPOINT"
E2E_TEST_LOKI_BASIC_AUTH_ENV = "E2E_TEST_LOKI_BASIC_AUTH"
E2E_TEST_LOKI_BEARER_TOKEN_ENV = "E2E_TEST_LOKI_BEARER_TOKEN" // #nosec G101
E2E_TEST_GRAFANA_BASE_URL_ENV = "E2E_TEST_GRAFANA_BASE_URL"
E2E_TEST_GRAFANA_DASHBOARD_URL_ENV = "E2E_TEST_GRAFANA_DASHBOARD_URL"
E2E_TEST_GRAFANA_BEARER_TOKEN_ENV = "E2E_TEST_GRAFANA_BEARER_TOKEN" // #nosec G101
E2E_TEST_PYROSCOPE_ENABLED_ENV = "E2E_TEST_PYROSCOPE_ENABLED"
E2E_TEST_PYROSCOPE_SERVER_URL_ENV = "E2E_TEST_PYROSCOPE_SERVER_URL"
E2E_TEST_PYROSCOPE_KEY_ENV = "E2E_TEST_PYROSCOPE_KEY"
E2E_TEST_PYROSCOPE_ENVIRONMENT_ENV = "E2E_TEST_PYROSCOPE_ENVIRONMENT"
E2E_TEST_CHAINLINK_IMAGE_ENV = "E2E_TEST_CHAINLINK_IMAGE"
E2E_TEST_CHAINLINK_VERSION_ENV = "E2E_TEST_CHAINLINK_VERSION"
E2E_TEST_CHAINLINK_POSTGRES_VERSION_ENV = "E2E_TEST_CHAINLINK_POSTGRES_VERSION"
E2E_TEST_CHAINLINK_UPGRADE_IMAGE_ENV = "E2E_TEST_CHAINLINK_UPGRADE_IMAGE"
E2E_TEST_CHAINLINK_UPGRADE_VERSION_ENV = "E2E_TEST_CHAINLINK_UPGRADE_VERSION"
E2E_TEST_SELECTED_NETWORK_ENV = `E2E_TEST_SELECTED_NETWORK`
E2E_TEST_WALLET_KEY_ENV = `E2E_TEST_(.+)_WALLET_KEY$`
E2E_TEST_WALLET_KEYS_ENV = `E2E_TEST_(.+)_WALLET_KEY_(\d+)$`
E2E_TEST_RPC_HTTP_URL_ENV = `E2E_TEST_(.+)_RPC_HTTP_URL$`
E2E_TEST_RPC_HTTP_URLS_ENV = `E2E_TEST_(.+)_RPC_HTTP_URL_(\d+)$`
E2E_TEST_RPC_WS_URL_ENV = `E2E_TEST_(.+)_RPC_WS_URL$`
E2E_TEST_RPC_WS_URLS_ENV = `E2E_TEST_(.+)_RPC_WS_URL_(\d+)$`
E2E_TEST_LOG_COLLECT_ENV = "E2E_TEST_LOG_COLLECT"
E2E_TEST_LOGGING_RUN_ID_ENV = "E2E_TEST_LOGGING_RUN_ID"
E2E_TEST_LOG_STREAM_LOG_TARGETS_ENV = "E2E_TEST_LOG_STREAM_LOG_TARGETS"
E2E_TEST_LOKI_TENANT_ID_ENV = "E2E_TEST_LOKI_TENANT_ID"
E2E_TEST_LOKI_ENDPOINT_ENV = "E2E_TEST_LOKI_ENDPOINT"
E2E_TEST_LOKI_BASIC_AUTH_ENV = "E2E_TEST_LOKI_BASIC_AUTH"
E2E_TEST_LOKI_BEARER_TOKEN_ENV = "E2E_TEST_LOKI_BEARER_TOKEN" // #nosec G101
E2E_TEST_GRAFANA_BASE_URL_ENV = "E2E_TEST_GRAFANA_BASE_URL"
E2E_TEST_GRAFANA_DASHBOARD_URL_ENV = "E2E_TEST_GRAFANA_DASHBOARD_URL"
E2E_TEST_GRAFANA_BEARER_TOKEN_ENV = "E2E_TEST_GRAFANA_BEARER_TOKEN" // #nosec G101
E2E_TEST_PYROSCOPE_ENABLED_ENV = "E2E_TEST_PYROSCOPE_ENABLED"
E2E_TEST_PYROSCOPE_SERVER_URL_ENV = "E2E_TEST_PYROSCOPE_SERVER_URL"
E2E_TEST_PYROSCOPE_KEY_ENV = "E2E_TEST_PYROSCOPE_KEY"
E2E_TEST_PYROSCOPE_ENVIRONMENT_ENV = "E2E_TEST_PYROSCOPE_ENVIRONMENT"
E2E_TEST_CHAINLINK_IMAGE_ENV = "E2E_TEST_CHAINLINK_IMAGE"
E2E_TEST_CHAINLINK_VERSION_ENV = "E2E_TEST_CHAINLINK_VERSION"
E2E_TEST_CHAINLINK_POSTGRES_VERSION_ENV = "E2E_TEST_CHAINLINK_POSTGRES_VERSION"
E2E_TEST_CHAINLINK_UPGRADE_IMAGE_ENV = "E2E_TEST_CHAINLINK_UPGRADE_IMAGE"
E2E_TEST_CHAINLINK_UPGRADE_VERSION_ENV = "E2E_TEST_CHAINLINK_UPGRADE_VERSION"
E2E_TEST_SELECTED_NETWORK_ENV = `E2E_TEST_SELECTED_NETWORK`
E2E_TEST_WALLET_KEY_ENV = `E2E_TEST_(.+)_WALLET_KEY$`
E2E_TEST_WALLET_KEYS_ENV = `E2E_TEST_(.+)_WALLET_KEY_(\d+)$`
E2E_TEST_RPC_HTTP_URL_ENV = `E2E_TEST_(.+)_RPC_HTTP_URL$`
E2E_TEST_RPC_HTTP_URLS_ENV = `E2E_TEST_(.+)_RPC_HTTP_URL_(\d+)$`
E2E_TEST_RPC_WS_URL_ENV = `E2E_TEST_(.+)_RPC_WS_URL$`
E2E_TEST_RPC_WS_URLS_ENV = `E2E_TEST_(.+)_RPC_WS_URL_(\d+)$`
E2E_TEST_PRIVATE_ETHEREUM_EXECUTION_LAYER_ENV = "E2E_TEST_PRIVATE_ETHEREUM_EXECUTION_LAYER"
E2E_TEST_PRIVATE_ETHEREUM_ETHEREUM_VERSION_ENV = "E2E_TEST_PRIVATE_ETHEREUM_ETHEREUM_VERSION"
E2E_TEST_PRIVATE_ETHEREUM_CUSTOM_DOCKER_IMAGE_ENV = "E2E_TEST_PRIVATE_ETHEREUM_CUSTOM_DOCKER_IMAGE"
)

func MustReadEnvVar_String(name string) string {
Expand Down
31 changes: 31 additions & 0 deletions lib/config/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/smartcontractkit/chainlink-testing-framework/seth"

"github.com/smartcontractkit/chainlink-testing-framework/lib/config/types"
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
)

Expand Down Expand Up @@ -284,6 +285,36 @@ func (c *TestConfig) ReadFromEnvVar() error {
c.ChainlinkUpgradeImage.Version = &chainlinkUpgradeVersion
}

ethereumExecutionLayer := MustReadEnvVar_String(E2E_TEST_PRIVATE_ETHEREUM_EXECUTION_LAYER_ENV)
if ethereumExecutionLayer != "" {
if c.PrivateEthereumNetwork == nil {
c.PrivateEthereumNetwork = &EthereumNetworkConfig{}
}
logger.Debug().Msgf("Using %s env var to override PrivateEthereumNetwork.ExecutionLayer", E2E_TEST_PRIVATE_ETHEREUM_EXECUTION_LAYER_ENV)
el := types.ExecutionLayer(ethereumExecutionLayer)
c.PrivateEthereumNetwork.ExecutionLayer = &el
}

ethereumVersion := MustReadEnvVar_String(E2E_TEST_PRIVATE_ETHEREUM_ETHEREUM_VERSION_ENV)
if ethereumVersion != "" {
if c.PrivateEthereumNetwork == nil {
c.PrivateEthereumNetwork = &EthereumNetworkConfig{}
}
logger.Debug().Msgf("Using %s env var to override PrivateEthereumNetwork.EthereumVersion", E2E_TEST_PRIVATE_ETHEREUM_ETHEREUM_VERSION_ENV)
ev := types.EthereumVersion(ethereumVersion)
c.PrivateEthereumNetwork.EthereumVersion = &ev
}

customDockerImage := MustReadEnvVar_String(E2E_TEST_PRIVATE_ETHEREUM_CUSTOM_DOCKER_IMAGE_ENV)
if customDockerImage != "" {
if c.PrivateEthereumNetwork == nil {
c.PrivateEthereumNetwork = &EthereumNetworkConfig{}
}
logger.Debug().Msgf("Using %s env var to override PrivateEthereumNetwork.CustomDockerImages", E2E_TEST_PRIVATE_ETHEREUM_CUSTOM_DOCKER_IMAGE_ENV)
customImages := map[ContainerType]string{"execution_layer": customDockerImage}
c.PrivateEthereumNetwork.CustomDockerImages = customImages
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion lib/docker/test_env/ethereum_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (b *EthereumNetworkBuilder) autoFill() error {
return err
}

if b.ethereumVersion == "" {
if b.ethereumVersion == "" || b.ethereumVersion == "auto_fill" {
if err := b.trySettingEthereumVersionBasedOnCustomImage(); err != nil {
return err
}
Expand Down

0 comments on commit 2ba5125

Please sign in to comment.