Skip to content

Commit

Permalink
Merge branch 'develop' into TT-1032-replace-gotestfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 authored May 21, 2024
2 parents aa3b65f + 3e5ef75 commit f06b619
Show file tree
Hide file tree
Showing 42 changed files with 1,470 additions and 1,362 deletions.
29 changes: 29 additions & 0 deletions .github/actions/build-gauntlet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Install gauntlet dependencies
description: A GitHub Action to get tool versions and build Gauntlet

runs:
using: 'composite'
steps:
- name: Checkout Repository
uses: actions/[email protected]

- name: Get Tool Versions
uses: smartcontractkit/[email protected]
id: tool-versions

- name: Setup Node ${{ steps.tool-versions.outputs.nodejs_version }}
uses: actions/[email protected]
with:
node-version: ${{ steps.tool-versions.outputs.nodejs_version }}

- name: Install Dependencies
run: yarn --cwd ./gauntlet install --frozen-lockfile
shell: bash

- name: Build Gauntlet
run: yarn --cwd ./gauntlet build
shell: bash

- name: Run Gauntlet
run: yarn --cwd ./gauntlet gauntlet
shell: bash
15 changes: 6 additions & 9 deletions .github/workflows/e2e_custom_cl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ jobs:
env:
TEST_SUITE: smoke
TEST_ARGS: -test.timeout 30m
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
CHAINLINK_ENV_USER: ${{ github.actor }}
TEST_LOG_LEVEL: debug
SELECTED_NETWORKS: SIMULATED
INTERNAL_DOCKER_REPO: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Collect Metrics
Expand All @@ -151,19 +147,19 @@ jobs:
fi
- name: Checkout the repo
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Download Artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: artifacts
path: ${{ env.CONTRACT_ARTIFACTS_PATH }}
- name: Install Solana CLI # required for ensuring the local test validator is configured correctly
run: ./scripts/install-solana-ci.sh
- name: Install gauntlet
uses: ./.github/actions/build-gauntlet
- name: Generate config overrides
run: | # https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/config/README.md
cat << EOF > config.toml
[ChainlinkImage]
image="${{ env.CL_ECR }}"
version="solana.${{ env.CUSTOM_CORE_REF || github.event.inputs.cl_branch_ref || github.sha }}"
[Common]
user="${{ github.actor }}"
internal_docker_repo = "${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com"
EOF
# shellcheck disable=SC2002
Expand All @@ -177,6 +173,7 @@ jobs:
with:
test_command_to_run: cd ./integration-tests && go test -timeout 24h -count=1 -run TestSolanaOCRV2Smoke -json $(args) ./smoke 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci -singlepackage
test_download_vendor_packages_command: cd ./integration-tests && go mod download
download_contract_artifacts_path: ${{ env.CONTRACT_ARTIFACTS_PATH }}
go_mod_path: ./integration-tests/go.mod
cl_repo: ${{ env.CL_ECR }}
cl_image_tag: solana.${{ env.CUSTOM_CORE_REF || github.event.inputs.cl_branch_ref || github.sha }}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- name: golangci-lint
run: nix develop -c make lint-go-integration-tests
- name: Print lint report artifact
if: failure()
shell: bash
run: cat ./integration-tests/golangci-lint-integration-tests-report.xml
- name: Store lint report artifact
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
Expand All @@ -35,9 +39,13 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- name: golangci-lint
run: nix develop -c make lint-go-relay
- name: Print lint report artifact
if: failure()
shell: bash
run: cat ./pkg/golangci-lint-relay-report.xml
- name: Store lint report artifact
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: golangci-lint-relay-report
path: ./pkg/golangci-lint-relay-report.xml
path: ./pkg/golangci-lint-relay-report.xml
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ tests-smoke-report.xml
overrides.toml

# Test & linter reports
.test_summary/
*report.xml
*report.json
*.out
*coverage*
eslint-report.json
.run.id

override*.toml
# go work files
go.work*
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ nodejs 18.20.2
yarn 1.22.19
rust 1.59.0
golang 1.21.7
golangci-lint 1.52.1
golangci-lint 1.55.2
pulumi 3.40.1
actionlint 1.6.22
shellcheck 0.8.0
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ gomodtidy:

.PHONY: lint-go-integration-tests
lint-go-integration-tests:
cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run || true
cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run

.PHONY: lint-go-relay
lint-go-relay:
cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run || true
cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run

.PHONY: upgrade-e2e-solana-image
upgrade-e2e-solana-image:
Expand Down
73 changes: 37 additions & 36 deletions docs/RunningE2eTests.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
# Running e2e tests

The e2e tests run inside of a k8s cluster. They will run against whatever cluster your current kubectl context is set to. This can be an external k8s cluster or a local one (using something like minikube or k3d).

Note: If running against a local k8s cluster, make sure you have plenty of ram allocated for docker, 12 gb if running individual tests and a lot more if you run parallel test like the ones in `make test_smoke` since it can run multiple tests in parallel

Steps to run the e2e tests:

1. Build using the `make build` command if you haven't already built the contracts.
2. Make sure your kubectl context is pointing to the cluster you want to run tests against.
3. Run a test, you have several options
- `make test_smoke` will run the ocr2 e2e tests
- `make test_chaos` will run the chaos tests

## Env variables
```bash
CHAINLINK_ENV_USER=John;
CHAINLINK_IMAGE={AWS_OIDC}.dkr.ecr.{AWS_REGION}.amazonaws.com/chainlink;
CHAINLINK_VERSION=develop; # Can be SHA
SELECTED_NETWORKS=SIMULATED;
INTERNAL_DOCKER_REPO={AWS_OIDC}.dkr.ecr.{AWS_REGION}.amazonaws.com
TTL=72h; # optional
TEST_LOG_LEVEL=debug # optional

# Running on testnet
LINK_TOKEN=Dmw5mDvteezKfop9zd3RQbJmZfBATF3QuSqDU66axyts;
PROGRAM_ID_ACCESS_CONTROLLER=9xi644bRR8birboDGdTiwBq3C7VEeR7VuamRYYXCubUW;
PROGRAM_ID_OCR2=cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ;
PROGRAM_ID_STORE=HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny;
VAULT_ADDRESS=G27m7KxTh4KVLapxB9MXfEA8HLUfYuGYQ1ELEs2zQdiQ;
PRIVATE_KEY=[123, 123, ...];
RPC_URL=https://api.devnet.solana.com;
WS_URL=wss://api.devnet.solana.com/;
```

You can always look at the [Makefile](../Makefile) in this repo to see other commands or tests that have been added since this readme was last updated.
# Running tests

## Installation
`make build && make install`


## Configuration
The main test config logic resides in the `integration-tests/testconfig/` directory. Everything is configured using TOML. The minimum OCR2 required values can be located at `integration-tests/testconfig/default.toml`, these values default to running the tests locally in docker using devnet.

### Combinations
There are a few possibile combinations to run tests that we support.

**Devnet**
Devnet requires previously deployed programs that are owned by the person running the tests. The program ID's are required for testnet, but ignored in localnet.

- `Common.network` needs to be set to `devnet` which will instruct the tests to run against devnet
- `ocr2_program_id`, `access_controller_program_id`, `store_program_id`, `link_token_address`, `vault_address` need to be set so the tests know what programs to use so we avoid deploying each time.
- `rpc_url` and `ws_url` need to be set

**Localnet**
Setting localnet will instruct the tests to run in localnet, the program ID's are not taken from the TOML in this scenario, but rather defined in the `integration-tests/config/config.go`.

**K8s**

Running in Kubernetes will require aws auth.

- `Common.inside_k8` needs to be set to true if you want to run the tests in k8

### Overrides

By default all values are pulled either from `default.toml` or if we create an `overrides.toml` where we want to set new values or override existing values. Both `default.toml` and `overrides.toml` will end up being merged where values that are set in both files will be taken based on the value in `overrides.toml`.

## Run tests

`cd integration-tests/smoke && go test -timeout 24h -count=1 -run TestSolanaOCRV2Smoke -test.timeout 30m;`


30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NODE_URL=https://api.devnet.solana.com
WS_URL=wss://api.devnet.solana.com

PROGRAM_ID_OCR2=cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ
PROGRAM_ID_ACCESS_CONTROLLER=9xi644bRR8birboDGdTiwBq3C7VEeR7VuamRYYXCubUW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export default class DeployToken extends SolanaCommand {
`)

return {
data: {
vault: tokenVault.toString(),
},
responses: [
{
tx: { ...this.wrapResponse('', token.toString()), wait: async () => ({ success: true }) },
Expand Down
9 changes: 6 additions & 3 deletions gauntlet/packages/gauntlet-solana/src/commands/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SolanaCommand from './internal/solana'
import { LedgerWallet, LocalWallet } from './wallet'

const isValidURL = (url: string) => {
var pattern = new RegExp('^(https?)://')
const pattern = new RegExp('^(https?|wss?):/')
return pattern.test(url)
}
export const withProvider: Middleware = (c: SolanaCommand, next: Next) => {
Expand All @@ -17,8 +17,11 @@ export const withProvider: Middleware = (c: SolanaCommand, next: Next) => {
nodeURL && isValidURL(nodeURL),
`Invalid NODE_URL (${nodeURL}), please add an http:// or https:// prefix`,
)

c.provider = new AnchorProvider(new Connection(nodeURL), c.wallet, {})
const wsUrl = process.env.WS_URL
if (wsUrl) {
assertions.assert(isValidURL(wsUrl), `Invalid WS_URL (${wsUrl}), please add an ws:// or wss:// prefix`)
}
c.provider = new AnchorProvider(new Connection(nodeURL, wsUrl ? { wsEndpoint: wsUrl } : {}), c.wallet, {})
return next()
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smartcontractkit/chainlink-solana

go 1.21
go 1.21.6

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
Expand Down
Loading

0 comments on commit f06b619

Please sign in to comment.