Skip to content

Commit

Permalink
Merge branch 'develop' into logger_extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Nov 27, 2023
2 parents 302244d + b87f21e commit 3f249dc
Show file tree
Hide file tree
Showing 31 changed files with 2,614 additions and 1,059 deletions.
136 changes: 136 additions & 0 deletions .github/workflows/on-demand-vrfv2-performance-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: On Demand VRFV2 Performance Test
on:
workflow_dispatch:
inputs:
network:
description: Network to run tests on
type: choice
options:
- "ETHEREUM_MAINNET"
- "SIMULATED"
- "SEPOLIA"
- "OPTIMISM_MAINNET"
- "OPTIMISM_GOERLI"
- "ARBITRUM_MAINNET"
- "ARBITRUM_GOERLI"
- "ARBITRUM_SEPOLIA"
- "BSC_MAINNET"
- "BSC_TESTNET"
- "POLYGON_MAINNET"
- "POLYGON_MUMBAI"
- "AVALANCHE_FUJI"
- "AVALANCHE_MAINNET"
fundingPrivateKey:
description: Private funding key (Skip for Simulated)
required: false
type: string
wsURL:
description: WS URL for the network (Skip for Simulated)
required: false
type: string
httpURL:
description: HTTP URL for the network (Skip for Simulated)
required: false
type: string
chainlinkImage:
description: Container image location for the Chainlink nodes
required: true
default: public.ecr.aws/chainlink/chainlink
chainlinkVersion:
description: Container image version for the Chainlink nodes
required: true
default: "2.6.0"
performanceTestType:
description: Performance Test Type of test to run
type: choice
options:
- "Soak"
- "Load"
- "Stress"
- "Spike"
testDuration:
description: Duration of the test (time string)
required: true
default: 5m
useExistingEnv:
description: Set `true` to use existing environment or `false` to deploy CL node and all contracts
required: false
default: false
configBase64:
description: TOML config in base64 (Needed when overriding config or providing contract addresses for existing env)
required: false
jobs:
vrfv2_performance_test:
name: ${{ inputs.network }} VRFV2 Performance Test
environment: integration
runs-on: ubuntu20.04-8cores-32GB
permissions:
checks: write
pull-requests: write
id-token: write
contents: read
env:
LOKI_URL: ${{ secrets.LOKI_URL }}
LOKI_TOKEN: ${{ secrets.LOKI_TOKEN }}
SELECTED_NETWORKS: ${{ inputs.network }}
TEST_TYPE: ${{ inputs.performanceTestType }}
VRFV2_TEST_DURATION: ${{ inputs.testDuration }}
VRFV2_USE_EXISTING_ENV: ${{ inputs.useExistingEnv }}
CONFIG: ${{ inputs.configBase64 }}
TEST_LOG_LEVEL: debug
REF_NAME: ${{ github.head_ref || github.ref_name }}
CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }}
CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }}
SLACK_API_KEY: ${{ secrets.QA_SLACK_API_KEY }}
SLACK_CHANNEL: ${{ secrets.QA_VRF_SLACK_CHANNEL }}
WASP_LOG_LEVEL: info
steps:
- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d1618b772a97fd87e6505de97b872ee0b1f1729a # v2.0.2
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: ${{ inputs.network }} VRFV2 Performance Test
continue-on-error: true
- name: Setup Push Tag
shell: bash
run: |
echo "### chainlink image used for this test run :link:" >>$GITHUB_STEP_SUMMARY
echo "\`${{ inputs.chainlinkVersion }}\`" >>$GITHUB_STEP_SUMMARY
echo "### chainlink-tests image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY
echo "\`${GITHUB_SHA}\`" >>$GITHUB_STEP_SUMMARY
- name: Get Inputs
run: |
EVM_URLS=$(jq -r '.inputs.wsURL' $GITHUB_EVENT_PATH)
EVM_HTTP_URLS=$(jq -r '.inputs.httpURL' $GITHUB_EVENT_PATH)
EVM_KEYS=$(jq -r '.inputs.fundingPrivateKey' $GITHUB_EVENT_PATH)
echo ::add-mask::$EVM_URLS
echo ::add-mask::$EVM_HTTP_URLS
echo ::add-mask::$EVM_KEYS
echo EVM_URLS=$EVM_URLS >> $GITHUB_ENV
echo EVM_HTTP_URLS=$EVM_HTTP_URLS >> $GITHUB_ENV
echo EVM_KEYS=$EVM_KEYS >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@7d541cbbca52d45b8a718257af86d9cf49774d1f # v2.2.15
with:
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 24h -run TestVRFV2Performance/vrfv2_performance_test ./load/vrfv2
test_download_vendor_packages_command: cd ./integration-tests && go mod download
cl_repo: ${{ inputs.chainlinkImage }}
cl_image_tag: ${{ inputs.chainlinkVersion }}
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
artifacts_name: vrf-test-logs
artifacts_location: ./integration-tests/load/vrfv2/logs/
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: ./integration-tests/go.mod
should_cleanup: false
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
7 changes: 4 additions & 3 deletions .github/workflows/on-demand-vrfv2plus-performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ on:
- "OPTIMISM_GOERLI"
- "ARBITRUM_MAINNET"
- "ARBITRUM_GOERLI"
- "ARBITRUM_SEPOLIA"
- "BSC_MAINNET"
- "BSC_TESTNET"
- "POLYGON_MAINNET"
- "MUMBAI"
- "POLYGON_MUMBAI"
- "AVALANCHE_FUJI"
- "AVALANCHE_MAINNET"
fundingPrivateKey:
Expand Down Expand Up @@ -120,13 +121,13 @@ jobs:
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@e865e376b8c2d594028c8d645dd6c47169b72974 # v2.2.16
with:
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 6h -run TestVRFV2PlusPerformance/vrfv2plus_performance_test ./load/vrfv2plus
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 24h -run TestVRFV2PlusPerformance/vrfv2plus_performance_test ./load/vrfv2plus
test_download_vendor_packages_command: cd ./integration-tests && go mod download
cl_repo: ${{ inputs.chainlinkImage }}
cl_image_tag: ${{ inputs.chainlinkVersion }}
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
artifacts_name: vrf-test-logs
artifacts_location: ./integration-tests/load/logs/
artifacts_location: ./integration-tests/load/vrfv2plus/logs/
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: ./integration-tests/go.mod
should_cleanup: false
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/client/node_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func TestUnit_NodeLifecycle_outOfSyncLoop(t *testing.T) {
n.wg.Add(1)
go func() {
defer close(ch)
n.aliveLoop()
n.outOfSyncLoop(func(num int64, td *utils.Big) bool { return false })
}()
assert.NoError(t, n.Close())
testutils.WaitWithTimeout(t, ch, "expected outOfSyncLoop to exit")
Expand Down
52 changes: 49 additions & 3 deletions core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
crand "crypto/rand"
"database/sql"
"fmt"
"log"
Expand Down Expand Up @@ -778,11 +779,13 @@ func (s *Shell) PrepareTestDatabase(c *cli.Context) error {
if userOnly {
fixturePath = "../store/fixtures/users_only_fixture.sql"
}
if err := insertFixtures(dbUrl, fixturePath); err != nil {
if err = insertFixtures(dbUrl, fixturePath); err != nil {
return s.errorOut(err)
}

return s.errorOut(dropDanglingTestDBs(s.Logger, db))
if err = dropDanglingTestDBs(s.Logger, db); err != nil {
return s.errorOut(err)
}
return s.errorOut(randomizeTestDBSequences(db))
}

func dropDanglingTestDBs(lggr logger.Logger, db *sqlx.DB) (err error) {
Expand Down Expand Up @@ -822,6 +825,49 @@ func dropDanglingTestDBs(lggr logger.Logger, db *sqlx.DB) (err error) {
return
}

type failedToRandomizeTestDBSequencesError struct{}

func (m *failedToRandomizeTestDBSequencesError) Error() string {
return "failed to randomize test db sequences"
}

// randomizeTestDBSequences randomizes sequenced table columns sequence
// This is necessary as to avoid false positives in some test cases.
func randomizeTestDBSequences(db *sqlx.DB) error {
seqRows, err := db.Query(`SELECT sequence_schema, sequence_name FROM information_schema.sequences WHERE sequence_schema = $1`, "public")
if err != nil {
return fmt.Errorf("%s: error fetching sequences: %s", failedToRandomizeTestDBSequencesError{}, err)
}

defer seqRows.Close()
for seqRows.Next() {
var sequenceSchema, sequenceName string
if err = seqRows.Scan(&sequenceSchema, &sequenceName); err != nil {
return fmt.Errorf("%s: failed scanning sequence rows: %s", failedToRandomizeTestDBSequencesError{}, err)
}

if sequenceName == "goose_migrations_id_seq" || sequenceName == "configurations_id_seq" {
continue
}

var randNum *big.Int
randNum, err = crand.Int(crand.Reader, utils.NewBigI(10000).ToInt())
if err != nil {
return fmt.Errorf("%s: failed to generate random number", failedToRandomizeTestDBSequencesError{})
}

if _, err = db.Exec(fmt.Sprintf("ALTER SEQUENCE %s.%s RESTART WITH %d", sequenceSchema, sequenceName, randNum)); err != nil {
return fmt.Errorf("%s: failed to alter and restart %s sequence: %w", failedToRandomizeTestDBSequencesError{}, sequenceName, err)
}
}

if err = seqRows.Err(); err != nil {
return fmt.Errorf("%s: failed to iterate through sequences: %w", failedToRandomizeTestDBSequencesError{}, err)
}

return nil
}

// PrepareTestDatabaseUserOnly calls ResetDatabase then loads only user fixtures required for local
// testing against testnets. Does not include fake chain fixtures.
func (s *Shell) PrepareTestDatabaseUserOnly(c *cli.Context) error {
Expand Down
1 change: 0 additions & 1 deletion core/internal/testutils/pgtest/pgtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func NewSqlxDB(t testing.TB) *sqlx.DB {
db, err := sqlx.Open(string(dialects.TransactionWrappedPostgres), uuid.New().String())
require.NoError(t, err)
t.Cleanup(func() { assert.NoError(t, db.Close()) })

db.MapperFunc(reflectx.CamelToSnakeASCII)

return db
Expand Down
Loading

0 comments on commit 3f249dc

Please sign in to comment.