Skip to content

Commit

Permalink
Merge branch 'develop' into BCI-2531-extract-core-store-models
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov authored Jan 5, 2024
2 parents 3316e7c + 3e944c9 commit e956d6b
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 45 deletions.
19 changes: 19 additions & 0 deletions integration-tests/actions/ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ func StartNewRound(
return nil
}

// WatchNewRound watches for a new OCR round, similarly to StartNewRound, but it does not explicitly request a new
// round from the contract, as this can cause some odd behavior in some cases
func WatchNewRound(
roundNumber int64,
ocrInstances []contracts.OffchainAggregator,
client blockchain.EVMClient,
logger zerolog.Logger,
) error {
for i := 0; i < len(ocrInstances); i++ {
ocrRound := contracts.NewOffchainAggregatorRoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), client.GetNetworkConfig().Timeout.Duration, logger)
client.AddHeaderEventSubscription(ocrInstances[i].Address(), ocrRound)
err := client.WaitForEvents()
if err != nil {
return fmt.Errorf("failed to wait for event subscriptions of OCR instance %d: %w", i+1, err)
}
}
return nil
}

// SetAdapterResponse sets a single adapter response that correlates with an ocr contract and a chainlink node
func SetAdapterResponse(
response int,
Expand Down
25 changes: 25 additions & 0 deletions integration-tests/docker/test_env/cl_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package test_env
import (
"context"
"fmt"
"io"
"maps"
"math/big"
"net/url"
"os"
"regexp"
"strings"
"testing"
"time"
Expand All @@ -15,6 +17,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/pelletier/go-toml/v2"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
tc "github.com/testcontainers/testcontainers-go"
Expand Down Expand Up @@ -361,6 +364,28 @@ func (n *ClNode) StartContainer() error {
return nil
}

func (n *ClNode) ExecGetVersion() (string, error) {
cmd := []string{"chainlink", "--version"}
_, output, err := n.Container.Exec(context.Background(), cmd)
if err != nil {
return "", errors.Wrapf(err, "could not execute cmd %s", cmd)
}
outputBytes, err := io.ReadAll(output)
if err != nil {
return "", err
}
outputString := strings.TrimSpace(string(outputBytes))

// Find version in cmd output
re := regexp.MustCompile("@(.*)")
matches := re.FindStringSubmatch(outputString)

if len(matches) > 1 {
return matches[1], nil
}
return "", errors.Errorf("could not find chainlink version in command output '%'", output)
}

func (n *ClNode) getContainerRequest(secrets string) (
*tc.ContainerRequest, error) {
configFile, err := os.CreateTemp("", "node_config")
Expand Down
24 changes: 13 additions & 11 deletions integration-tests/scripts/buildTestMatrixList.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@ jq -c '.tests[]' ${JSONFILE} | while read -r test; do
effective_node_count=${node_count:-$NODE_COUNT}
subTests=$(echo ${test} | jq -r '.run[]?.name // empty')
output=""

if [ $COUNTER -ne 1 ]; then
echo -n ","
fi

# Loop through subtests, if any, and print in the desired format
if [ -n "$subTests" ]; then
subTestString=""
subTestCounter=1
for subTest in $subTests; do
if [ $COUNTER -ne 1 ]; then
echo -n ","
if [ $subTestCounter -ne 1 ]; then
subTestString+="|"
fi
matrix_output $COUNTER $MATRIX_JOB_NAME "${testName}/${subTest}" ${effective_node_label} ${effective_node_count}
((COUNTER++))
subTestString+="${testName}\/${subTest}"
((subTestCounter++))
done
else
if [ $COUNTER -ne 1 ]; then
echo -n ","
fi
matrix_output $COUNTER $MATRIX_JOB_NAME "${testName}" ${effective_node_label} ${effective_node_count}
((COUNTER++))
testName="${subTestString}"
fi

matrix_output $COUNTER $MATRIX_JOB_NAME "${testName}" ${effective_node_label} ${effective_node_count}
((COUNTER++))
done > "./tmpout.json"
OUTPUT=$(cat ./tmpout.json)
echo "[${OUTPUT}]"
Expand Down
50 changes: 25 additions & 25 deletions integration-tests/smoke/automation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {
"registry_2_1_with_logtrigger_and_mercury_v02": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
Expand Down Expand Up @@ -167,7 +167,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {
g.Expect(counter.Int64()).Should(gomega.BeNumerically(">=", int64(expect)),
"Expected consumer counter to be greater than %d, but got %d", expect, counter.Int64())
}
}, "5m", "1s").Should(gomega.Succeed()) // ~1m for cluster setup, ~2m for performing each upkeep 5 times, ~2m buffer
}, "10m", "1s").Should(gomega.Succeed()) // ~1m for cluster setup, ~2m for performing each upkeep 5 times, ~2m buffer

l.Info().Msgf("Total time taken to get 5 performs for each upkeep: %s", time.Since(startTime))

Expand Down Expand Up @@ -399,9 +399,9 @@ func TestAutomationAddFunds(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
a := setupAutomationTestDocker(
Expand Down Expand Up @@ -556,9 +556,9 @@ func TestAutomationRegisterUpkeep(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
Expand Down Expand Up @@ -640,9 +640,9 @@ func TestAutomationPauseRegistry(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
a := setupAutomationTestDocker(
Expand Down Expand Up @@ -709,9 +709,9 @@ func TestAutomationKeeperNodesDown(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
Expand Down Expand Up @@ -809,9 +809,9 @@ func TestAutomationPerformSimulation(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
a := setupAutomationTestDocker(
Expand Down Expand Up @@ -872,9 +872,9 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
Expand Down Expand Up @@ -986,9 +986,9 @@ func TestUpdateCheckData(t *testing.T) {
"registry_2_1": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
name := n
registryVersion := rv
for name, registryVersion := range registryVersions {
name := name
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
Expand Down
26 changes: 24 additions & 2 deletions integration-tests/smoke/automation_test.go_test_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@
"tests": [
{
"name": "TestAutomationBasic",
"label": "ubuntu-latest-32cores-128GB",
"nodes": 6
"label": "ubuntu-latest",
"nodes": 2,
"run":[
{"name":"registry_2_0"},
{"name":"registry_2_1_conditional"}
]
},
{
"name": "TestAutomationBasic",
"label": "ubuntu-latest",
"nodes": 2,
"run":[
{"name":"registry_2_1_logtrigger"},
{"name":"registry_2_1_with_mercury_v02"}
]
},
{
"name": "TestAutomationBasic",
"label": "ubuntu-latest",
"nodes": 2,
"run":[
{"name":"registry_2_1_with_mercury_v03"},
{"name":"registry_2_1_with_logtrigger_and_mercury_v02"}
]
},
{
"name": "TestSetUpkeepTriggerConfig"
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/smoke/forwarder_ocr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestForwarderOCRBasic(t *testing.T) {

err = actions.CreateOCRJobsWithForwarderLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String())
require.NoError(t, err, "failed to setup forwarder jobs")
err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)
err = env.EVMClient.WaitForEvents()
require.NoError(t, err, "Error waiting for events")
Expand All @@ -79,7 +79,7 @@ func TestForwarderOCRBasic(t *testing.T) {

err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter)
require.NoError(t, err)
err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(2, ocrInstances, env.EVMClient, l)
require.NoError(t, err)
err = env.EVMClient.WaitForEvents()
require.NoError(t, err, "Error waiting for events")
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/smoke/ocr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestOCRBasic(t *testing.T) {
err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID())
require.NoError(t, err)

err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err := ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand All @@ -56,7 +56,7 @@ func TestOCRBasic(t *testing.T) {

err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter)
require.NoError(t, err)
err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(2, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err = ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestOCRJobReplacement(t *testing.T) {
err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID())
require.NoError(t, err)

err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err := ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand All @@ -103,7 +103,7 @@ func TestOCRJobReplacement(t *testing.T) {

err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter)
require.NoError(t, err)
err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(2, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err = ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand All @@ -120,7 +120,7 @@ func TestOCRJobReplacement(t *testing.T) {
err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID())
require.NoError(t, err)

err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err = ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand Down

0 comments on commit e956d6b

Please sign in to comment.