Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NONEVM-706][SOAK][deprecated] - Soak Testing TxExpirationRebroadcast feature #949

56 changes: 53 additions & 3 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"maps"
"os/exec"
"strings"
"testing"
"time"

Expand All @@ -21,20 +22,39 @@ import (

func TestSolanaOCRV2Smoke(t *testing.T) {
for _, test := range []struct {
name string
env map[string]string
name string
env map[string]string
workloadLabels map[string]string // Added workloadLabels
}{
{name: "embedded"},
{name: "embedded", workloadLabels: map[string]string{
"chain.link/team": "team-alpha",
"chain.link/cost-center": "cc-12345",
"chain.link/product": "product-X",
}},
{name: "plugins", env: map[string]string{
"CL_MEDIAN_CMD": "chainlink-feeds",
"CL_SOLANA_CMD": "chainlink-solana",
}, workloadLabels: map[string]string{
"chain.link/team": "team-beta",
"chain.link/cost-center": "cc-67890",
"chain.link/product": "product-Y",
}},
} {
config, err := tc.GetConfig("Smoke", tc.OCR2)
if err != nil {
t.Fatal(err)
}

// Merge workloadLabels into config.WorkloadLabels
if test.workloadLabels != nil {
if config.WorkloadLabels == nil {
config.WorkloadLabels = make(map[string]string)
}
for key, value := range test.workloadLabels {
config.WorkloadLabels[key] = value
}
}

test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -85,6 +105,36 @@ func startOCR2DataFeedsSmokeTest(t *testing.T, testname string, testenv map[stri
state.SetupClients()
require.NoError(t, err)

// Apply WorkloadLabels to Kubernetes resources
if len(config.WorkloadLabels) > 0 {
for resourceName, labelValue := range config.WorkloadLabels {
// Determine the resource type based on the resource name pattern
var resourceType string
switch {
case strings.Contains(resourceName, "node-creds-secret"):
resourceType = "secret"
case strings.Contains(resourceName, "cm"):
resourceType = "configmap"
case strings.Contains(resourceName, "postgres-node"):
resourceType = "deployment" // Adjust as needed
default:
resourceType = "deployment" // Default resource type
}

// Construct the label key
splitName := strings.Split(resourceName, "-")
if len(splitName) == 0 {
require.Fail(t, "Invalid resource name format: "+resourceName)
}
labelKey := "chain.link/" + splitName[len(splitName)-1]

// Apply the label using kubectl
cmd := exec.Command("kubectl", "label", resourceType, resourceName, fmt.Sprintf("%s=%s", labelKey, labelValue), "--overwrite")
output, errOutput := cmd.CombinedOutput()
require.NoError(t, errOutput, fmt.Sprintf("Failed to apply label to resource %s: %s", resourceName, string(output)))
}
}

gauntletConfig := map[string]string{
"SECRET": fmt.Sprintf("\"%s\"", *config.SolanaConfig.Secret),
"NODE_URL": state.Common.ChainDetails.RPCURLExternal,
Expand Down
29 changes: 29 additions & 0 deletions integration-tests/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type TestConfig struct {
OCR2 *ocr2_config.Config `toml:"OCR2"`
SolanaConfig *SolanaConfig `toml:"SolanaConfig"`
ConfigurationName string `toml:"-"`
WorkloadLabels map[string]string `toml:"WorkloadLabels"`

// getter funcs for passing parameters
GetChainID func() string
Expand Down Expand Up @@ -224,9 +225,37 @@ func (c *TestConfig) ReadFromEnvVar() error {
c.SolanaConfig.Secret = &solanaSecret
}

// Add WorkloadLabels from environment variable if set
workloadLabelsEnv := os.Getenv("WORKLOAD_LABELS")
if workloadLabelsEnv != "" {
labels := parseWorkloadLabels(workloadLabelsEnv)
if c.WorkloadLabels == nil {
c.WorkloadLabels = make(map[string]string)
}
for key, value := range labels {
c.WorkloadLabels[key] = value
}
logger.Info().Msg("WorkloadLabels have been set from WORKLOAD_LABELS environment variable")
}

return nil
}

// parseWorkloadLabels parses a string of labels in key=value format separated by commas
func parseWorkloadLabels(labels string) map[string]string {
result := make(map[string]string)
pairs := strings.Split(labels, ",")
for _, pair := range pairs {
kv := strings.SplitN(pair, "=", 2)
if len(kv) == 2 {
key := strings.TrimSpace(kv[0])
value := strings.TrimSpace(kv[1])
result[key] = value
}
}
return result
}

func (c *TestConfig) GetLoggingConfig() *ctf_config.LoggingConfig {
return c.Logging
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/solana/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ var defaultConfigSet = Chain{
TxTimeout: config.MustNewDuration(time.Minute), // timeout for send tx method in client
TxRetryTimeout: config.MustNewDuration(10 * time.Second), // duration for tx rebroadcasting to RPC node
TxConfirmTimeout: config.MustNewDuration(30 * time.Second), // duration before discarding tx as unconfirmed. Set to 0 to disable discarding tx.
TxExpirationRebroadcast: ptr(false), // to enable rebroadcasting of expired transactions
TxExpirationRebroadcast: ptr(true), // to enable rebroadcasting of expired transactions
TxRetentionTimeout: config.MustNewDuration(0 * time.Second), // duration to retain transactions after being marked as finalized or errored. Set to 0 to immediately drop transactions.
SkipPreflight: ptr(true), // to enable or disable preflight checks
Commitment: ptr(string(rpc.CommitmentConfirmed)),
MaxRetries: ptr(int64(0)), // max number of retries (default = 0). when config.MaxRetries < 0), interpreted as MaxRetries = nil and rpc node will do a reasonable number of retries

// fee estimator
FeeEstimatorMode: ptr("fixed"),
FeeEstimatorMode: ptr("blockhistory"),
ComputeUnitPriceMax: ptr(uint64(1_000)),
ComputeUnitPriceMin: ptr(uint64(0)),
ComputeUnitPriceDefault: ptr(uint64(0)),
FeeBumpPeriod: config.MustNewDuration(3 * time.Second), // set to 0 to disable fee bumping
BlockHistoryPollPeriod: config.MustNewDuration(5 * time.Second),
BlockHistorySize: ptr(uint64(1)), // 1: uses latest block; >1: Uses multiple blocks, where n is number of blocks. DISCLAIMER: 1:1 ratio between n and RPC calls.
BlockHistorySize: ptr(uint64(15)), // 1: uses latest block; >1: Uses multiple blocks, where n is number of blocks. DISCLAIMER: 1:1 ratio between n and RPC calls.
ComputeUnitLimitDefault: ptr(uint32(200_000)), // set to 0 to disable adding compute unit limit
EstimateComputeUnitLimit: ptr(false), // set to false to disable compute unit limit estimation
}
Expand Down
Loading