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

[BCI-2848] Added TOML support, moved tests to gauntlet, bumped deps #705

Merged
merged 50 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2182c93
TOML migration, refactoring, local runs
smickovskid May 14, 2024
01cc5ac
Rebase
smickovskid May 14, 2024
fed26c2
Removed outdated soak test
smickovskid May 14, 2024
39398a2
Fixing CI
smickovskid May 14, 2024
4f91c1d
Adding yarn install
smickovskid May 15, 2024
d2eb2c1
Adding yarn install
smickovskid May 15, 2024
badfce2
Adding yarn install
smickovskid May 15, 2024
7644097
Adding yarn install
smickovskid May 15, 2024
736210d
Added yarn
smickovskid May 15, 2024
568aea8
Reverted yarn
smickovskid May 15, 2024
f555ba8
Adding gauntlet dep install
smickovskid May 15, 2024
8179186
Go mod bump
smickovskid May 15, 2024
89f16d5
Bumped ctf
smickovskid May 15, 2024
e733712
Checking path
smickovskid May 15, 2024
c21d0e6
Checking path
smickovskid May 15, 2024
2cf4134
Linting and adding gauntlet action
smickovskid May 15, 2024
d238e26
Fixing CI
smickovskid May 15, 2024
06d61f4
Fixing Ci
smickovskid May 15, 2024
292b165
Fixing CI
smickovskid May 15, 2024
8cf5b1f
Fixing CI
smickovskid May 15, 2024
ddfb378
Changed default solana image
smickovskid May 15, 2024
3a38564
Docker env fix
smickovskid May 15, 2024
b036884
Go mod bump
smickovskid May 15, 2024
7796d89
Checking contracts folder
smickovskid May 16, 2024
1ef70ff
Checking dir in CI
smickovskid May 16, 2024
63537f0
Checking dir in CI
smickovskid May 16, 2024
2176e4b
Changing perms of artifacts due to mount issues
smickovskid May 16, 2024
f27ee5e
Changing perms of artifacts due to mount issues
smickovskid May 16, 2024
265f9d5
Changing perms of artifacts due to mount issues
smickovskid May 16, 2024
1425062
Changed the contracts docker path
smickovskid May 16, 2024
93205d5
Creating deploy folder prior to artifact upload
smickovskid May 16, 2024
443e504
Testing mount fix
smickovskid May 16, 2024
b7ba833
Bumped CTF actions
smickovskid May 16, 2024
7b5252d
Testing CI...
smickovskid May 16, 2024
ca665e6
Still testing CI
smickovskid May 16, 2024
88b9629
testing path
smickovskid May 16, 2024
1517a09
Added build contracts
smickovskid May 16, 2024
e5be900
Added contract download artifacts path
smickovskid May 16, 2024
e62e035
Added artifacts download
smickovskid May 16, 2024
3c5d895
Fixed round check logic
smickovskid May 16, 2024
129d588
Removed ls command
smickovskid May 16, 2024
a81266e
Fixed typo in workflow
smickovskid May 16, 2024
8a66300
Adjusted test duration logic
smickovskid May 20, 2024
6835833
Rebase and go mod tidy
smickovskid May 20, 2024
7dd922f
Added readme
smickovskid May 20, 2024
ff1204a
Incorporated feedback
smickovskid May 21, 2024
83239d1
Merge branch 'develop' into BCI-2848
aalu1418 May 21, 2024
f7ae48c
linter fixes
aalu1418 May 21, 2024
ff47af5
gomodtidy
aalu1418 May 21, 2024
539f1d1
linter issue
aalu1418 May 21, 2024
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
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
aalu1418 marked this conversation as resolved.
Show resolved Hide resolved

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

- name: Run Gauntlet
run: yarn --cwd ./gauntlet gauntlet
shell: bash
17 changes: 7 additions & 10 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 @@ -150,19 +146,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 @@ -172,10 +168,11 @@ jobs:
# shellcheck disable=SC2086
echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> $GITHUB_ENV
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@e29366cdecfe6befff9ab8c3cfe4825218505d58 # v2.3.16
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@7f2d504e0b6ebd4aa5ece371d9c5eb9762803ca0 # v2.3.16
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 | gotestfmt
test_download_vendor_packages_command: cd ./integration-tests && go mod download
download_contract_artifacts_path: ${{ env.CONTRACT_ARTIFACTS_PATH }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is download_contract_artifacts_path used?

Interested as we're currently working on contract distribution via Nix/Manifest with G++.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is for previously compiled contract components as part of the tests

e2e_custom_build_artifacts:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, the CTF action takes in an optional argument and the location of an artifact so it downloads it to the workspace

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
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
@@ -1,4 +1,4 @@
nodejs 16.13.2
nodejs 18.13.0
yarn 1.22.19
rust 1.59.0
golang 1.21.1
Expand Down
69 changes: 33 additions & 36 deletions docs/RunningE2eTests.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
# 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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we should start using Nix across the board vs. asdf



## 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.

aalu1418 marked this conversation as resolved.
Show resolved Hide resolved
**Devnet**

- `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

**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;`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we run soak tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't directly have it atm as in kicking it off as a soak, but it is indirectly possible by setting a long TTL and rounds. I need to create a followup task to specifically create a soak trigger.



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
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?)://')
var pattern = new RegExp('^(https?|wss?):/')
return pattern.test(url)
}
export const withProvider: Middleware = (c: SolanaCommand, next: Next) => {
Expand All @@ -17,8 +17,9 @@ 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
assertions.assert(wsUrl && isValidURL(wsUrl), `Invalid WS_URL (${wsUrl}), please add an ws:// or wss:// prefix`)
c.provider = new AnchorProvider(new Connection(nodeURL, { wsEndpoint: wsUrl }), c.wallet, {})
aalu1418 marked this conversation as resolved.
Show resolved Hide resolved
return next()
}

Expand Down
Loading
Loading