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

[TT-500][TT-682]Add build and lint to integration-tests #11221

Merged
merged 27 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5d59226
Add build and lint to integration-tests
tateexon Nov 7, 2023
adec0fe
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 7, 2023
50b2d40
Fix the build to actually build all the test files
tateexon Nov 7, 2023
6b728d6
Add needs for the new job so it will affect required steps
tateexon Nov 7, 2023
c61b836
Review comments
tateexon Nov 8, 2023
f9a394a
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 8, 2023
697af4b
fix build and lint errors
tateexon Nov 8, 2023
2a48aa9
bump lint and go versions
tateexon Nov 8, 2023
9041ef7
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 8, 2023
b7f4239
lint weirdness in migration test
tateexon Nov 8, 2023
51f12d0
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 8, 2023
59a72ae
Wire the test context in the VRFV2SoakTest Run function to a parent c…
tateexon Nov 8, 2023
309af3b
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 8, 2023
e0ba4b8
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
4d16c29
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 9, 2023
3136d6e
Merge conflict fix and improved .golangci lint file with fixes for those
tateexon Nov 9, 2023
42d3655
One more .golangci cleanup
tateexon Nov 9, 2023
322e014
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
27015ba
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
6c5e88b
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
73837c2
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
faed3cb
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 11, 2023
35e4a15
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 13, 2023
8baaf97
Fix newly added lint errors
tateexon Nov 13, 2023
2369eae
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 13, 2023
6bf6b9d
add build to integration-tests makefile
tateexon Nov 13, 2023
86b119d
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 49 additions & 19 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ jobs:
outputs:
src: ${{ steps.changes.outputs.src }}

build-lint-integration-tests:
name: Build and Lint integration-tests
runs-on: ubuntu20.04-16cores-64GB
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-go@e865e376b8c2d594028c8d645dd6c47169b72974 # v2.2.16
with:
test_download_vendor_packages_command: cd ./integration-tests && go mod download
go_mod_path: ./integration-tests/go.mod
cache_key_id: core-e2e-${{ env.MOD_CACHE_VERSION }}
cache_restore_only: "true"
- name: Build Go
run: |
cd ./integration-tests
go build ./...
SELECTED_NETWORKS=SIMULATED go test -run=^# ./...
- name: Lint Go
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.55.0
# We already cache these directories in setup-go
skip-pkg-cache: true
skip-build-cache: true
# only-new-issues is only applicable to PRs, otherwise it is always set to false
only-new-issues: false # disabled for PRs due to unreliability
args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml
working-directory: ./integration-tests

build-chainlink:
environment: integration
permissions:
Expand Down Expand Up @@ -356,16 +386,16 @@ jobs:
run: |
PORT_BASE=3001
MAX_PORT=8000

# Use PR number as offset. Given GitHub PRs are incremental, this guarantees uniqueness for at least 5000 PRs.
OFFSET=$GITHUB_PR_NUMBER
echo "PR Number: $OFFSET"

# Ensure that we don't exceed the max port
if (( OFFSET > (MAX_PORT - PORT_BASE) )); then
OFFSET=$((OFFSET % (MAX_PORT - PORT_BASE)))
fi

# Map the offset to the port range
REMOTE_PORT=$((PORT_BASE + OFFSET))
echo "REMOTE_PORT=$REMOTE_PORT" >> $GITHUB_OUTPUT
Expand All @@ -376,25 +406,25 @@ jobs:
TRACING_SSH_SERVER: ${{ secrets.TRACING_SSH_SERVER }}
REMOTE_PORT: ${{ steps.generate-port.outputs.REMOTE_PORT }}
run: |
eval $(ssh-agent)
echo "test"
echo "$TRACING_SSH_KEY" | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | base64 --decode | ssh-add -
# f: background process
# N: do not execute a remote command
# R: remote port forwarding
ssh -o StrictHostKeyChecking=no -f -N -R $REMOTE_PORT:127.0.0.1:3000 user-gha@$TRACING_SSH_SERVER
echo "To view Grafana locally:"
echo "ssh -N -L 8000:localhost:$REMOTE_PORT user-gha@$TRACING_SSH_SERVER"
echo "Then visit http://localhost:8000 in a browser."
echo "If you are unable to connect, check with the security team that you have access to the tracing server."
eval $(ssh-agent)
echo "test"
echo "$TRACING_SSH_KEY" | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | base64 --decode | ssh-add -
# f: background process
# N: do not execute a remote command
# R: remote port forwarding
ssh -o StrictHostKeyChecking=no -f -N -R $REMOTE_PORT:127.0.0.1:3000 user-gha@$TRACING_SSH_SERVER
echo "To view Grafana locally:"
echo "ssh -N -L 8000:localhost:$REMOTE_PORT user-gha@$TRACING_SSH_SERVER"
echo "Then visit http://localhost:8000 in a browser."
echo "If you are unable to connect, check with the security team that you have access to the tracing server."
- name: Show Grafana Logs
if: steps.check-label.outputs.trace == 'true' && matrix.product.name == 'ocr2' && matrix.product.tag_suffix == '-plugins'
run: |
docker logs grafana
docker logs tempo
docker logs otel-collector
docker logs grafana
docker logs tempo
docker logs otel-collector
- name: Set sleep time to use in future steps
if: steps.check-label.outputs.trace == 'true' && matrix.product.name == 'ocr2' && matrix.product.tag_suffix == '-plugins'
run: |
Expand Down
85 changes: 85 additions & 0 deletions integration-tests/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
run:
timeout: 15m0s
linters:
enable:
- exhaustive
- exportloopref
- revive
- goimports
- gosec
- misspell
- rowserrcheck
- errorlint
linters-settings:
exhaustive:
default-signifies-exhaustive: true
goimports:
local-prefixes: github.com/smartcontractkit/chainlink
golint:
min-confidence: 1.0
gosec:
excludes:
- G101
- G104
# - G204
# - G304
# - G404
govet:
# report about shadowed variables
check-shadowing: true
errorlint:
# Allow formatting of errors without %w
errorf: false
revive:
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
# - name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
# - name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
# - name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
- name: waitgroup-by-value
- name: unconditional-recursion
- name: struct-tag
# - name: string-format
- name: string-of-int
# - name: range-val-address
- name: range-val-in-closure
- name: modifies-value-receiver
- name: modifies-parameter
- name: identical-branches
- name: get-return
# - name: flag-parameter
# - name: early-return
- name: defer
- name: constant-logical-expr
# - name: confusing-naming
# - name: confusing-results
- name: bool-literal-in-expr
- name: atomic
issues:
exclude-rules:
- text: "^G404: Use of weak random number generator"
linters:
- gosec
- linters:
- govet
text: "declaration of \"err\" shadows"
3 changes: 2 additions & 1 deletion integration-tests/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
golang 1.21.1
golang 1.21.3
k3d 5.4.6
tateexon marked this conversation as resolved.
Show resolved Hide resolved
kubectl 1.25.5
nodejs 18.13.0
golangci-lint 1.55.0
3 changes: 3 additions & 0 deletions integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ install_gotestfmt:
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
set -euo pipefail

lint:
golangci-lint --color=always run ./... --fix -v

# Builds the test image
# tag: the tag for the test image being built, example: tag=tate
# base_tag: the tag for the base-test-image to use, example: base_tag=latest
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/actions/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
ocr2keepers20config "github.com/smartcontractkit/ocr2keepers/pkg/v2/config"
ocr2keepers30config "github.com/smartcontractkit/ocr2keepers/pkg/v3/config"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/logging"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/actions/ocr2_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import (
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand Down
11 changes: 6 additions & 5 deletions integration-tests/actions/ocr2_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ import (
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/testhelpers"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"
)

func CreateOCRv2JobsLocal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import (
"go.dedis.ch/kyber/v3/group/edwards25519"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"github.com/smartcontractkit/ocr2vrf/altbn_128"
"github.com/smartcontractkit/ocr2vrf/dkg"
"github.com/smartcontractkit/ocr2vrf/ocr2vrf"
ocr2vrftypes "github.com/smartcontractkit/ocr2vrf/types"

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
)
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ocr2vrf_actions

import (
"context"
"math/big"
"strings"
"testing"
Expand Down Expand Up @@ -272,14 +273,14 @@ func RequestRandomnessFulfillmentAndWaitForFulfilment(
}

func getRequestId(t *testing.T, consumer contracts.VRFBeaconConsumer, receipt *types.Receipt, confirmationDelay *big.Int) *big.Int {
periodBlocks, err := consumer.IBeaconPeriodBlocks(nil)
periodBlocks, err := consumer.IBeaconPeriodBlocks(context.Background())
tateexon marked this conversation as resolved.
Show resolved Hide resolved
require.NoError(t, err, "Error getting Beacon Period block count")

blockNumber := receipt.BlockNumber
periodOffset := new(big.Int).Mod(blockNumber, periodBlocks)
nextBeaconOutputHeight := new(big.Int).Sub(new(big.Int).Add(blockNumber, periodBlocks), periodOffset)

requestID, err := consumer.GetRequestIdsBy(nil, nextBeaconOutputHeight, confirmationDelay)
requestID, err := consumer.GetRequestIdsBy(context.Background(), nextBeaconOutputHeight, confirmationDelay)
require.NoError(t, err, "Error getting requestID from consumer contract")

return requestID
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/actions/ocr_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/rs/zerolog"
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/actions/vrfv2plus/vrfv2plus_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/rs/zerolog"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config"
Expand Down Expand Up @@ -802,7 +803,7 @@ func WaitForRequestCountEqualToFulfilmentCount(consumer contracts.VRFv2PlusLoadT
fmt.Errorf("timeout waiting for rand request and fulfilments to be equal AFTER performance test was executed. Request Count: %d, Fulfilment Count: %d",
metrics.RequestCount.Uint64(), metrics.FulfilmentCount.Uint64())
case <-ticker.C:
go getLoadTestMetrics(consumer, metricsChannel, metricsErrorChannel)
go retreiveLoadTestMetrics(consumer, metricsChannel, metricsErrorChannel)
case metrics = <-metricsChannel:
if metrics.RequestCount.Cmp(metrics.FulfilmentCount) == 0 {
ticker.Stop()
Expand Down Expand Up @@ -852,7 +853,7 @@ func ReturnFundsForFulfilledRequests(client blockchain.EVMClient, coordinator co
return nil
}

func getLoadTestMetrics(
func retreiveLoadTestMetrics(
consumer contracts.VRFv2PlusLoadTestConsumer,
metricsChannel chan *contracts.VRFLoadTestMetrics,
metricsErrorChannel chan error,
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/chaos/automation_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func TestAutomationChaos(t *testing.T) {
}

for name, registryVersion := range registryVersions {
registryVersion := registryVersion
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -176,9 +177,9 @@ func TestAutomationChaos(t *testing.T) {
},
}

for n, tst := range testCases {
name := n
testCase := tst
for name, testCase := range testCases {
name := name
testCase := testCase
t.Run(fmt.Sprintf("Automation_%s", name), func(t *testing.T) {
t.Parallel()
network := networks.MustGetSelectedNetworksFromEnv()[0] // Need a new copy of the network for each test
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/chaos/ocr2vrf_chaos_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chaos

import (
"context"
"fmt"
"math/big"
"strings"
Expand Down Expand Up @@ -185,7 +186,7 @@ func TestOCR2VRFChaos(t *testing.T) {
)

for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ {
randomness, err := consumerContract.GetRandomnessByRequestId(nil, requestID, big.NewInt(int64(i)))
randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i)))
require.NoError(t, err)
l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract")
require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0")
Expand All @@ -212,7 +213,7 @@ func TestOCR2VRFChaos(t *testing.T) {
)

for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ {
randomness, err := consumerContract.GetRandomnessByRequestId(nil, requestID, big.NewInt(int64(i)))
randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i)))
require.NoError(t, err, "Error getting Randomness result from Consumer Contract")
l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract")
require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0")
Expand Down
Loading
Loading