Skip to content

Commit fae9ddc

Browse files
committed
Merge branch 'main' into TT-1830
2 parents 6e37551 + b6fcd0d commit fae9ddc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4397
-2849
lines changed

.github/workflows/docs.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ on:
55
push:
66
branches:
77
- main
8+
tags:
9+
- '*'
810

911
jobs:
1012
build-deploy:
1113
runs-on: ubuntu-latest
1214
steps:
1315
- name: Checkout
1416
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
17+
with:
18+
fetch-depth: 0 # Fetch all history for all tags
1519

1620
- name: Setup mdBook
17-
uses: peaceiris/actions-mdbook@v1
21+
uses: peaceiris/actions-mdbook@v2
1822
with:
1923
mdbook-version: '0.4.40'
2024

@@ -29,7 +33,7 @@ jobs:
2933
mdbook build
3034
3135
- name: Deploy to GitHub Pages
32-
uses: peaceiris/actions-gh-pages@v3
36+
uses: peaceiris/actions-gh-pages@v4
3337
with:
3438
github_token: ${{ secrets.GITHUB_TOKEN }}
3539
publish_dir: book
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Framework Golden Tests Examples
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
defaults:
8+
run:
9+
working-directory: framework/examples/myproject
10+
env:
11+
LOKI_TENANT_ID: promtail
12+
LOKI_URL: http://localhost:3030/loki/api/v1/push
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write
16+
contents: read
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
test:
21+
- name: TestSmoke
22+
config: smoke.toml
23+
count: 1
24+
timeout: 10m
25+
- name: TestLoad
26+
config: load.toml
27+
count: 1
28+
timeout: 10m
29+
- name: TestChaos
30+
config: chaos.toml
31+
count: 1
32+
timeout: 10m
33+
- name: TestUpgradeAll
34+
config: upgrade_all.toml
35+
count: 1
36+
timeout: 10m
37+
- name: TestUpgradeSome
38+
config: upgrade_some.toml
39+
count: 1
40+
timeout: 10m
41+
steps:
42+
- name: Checkout repo
43+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
44+
- name: Configure AWS credentials using OIDC
45+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
46+
with:
47+
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
48+
aws-region: us-east-1
49+
- name: Authenticate to ECR Public
50+
id: login-ecr-public
51+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
52+
with:
53+
registry-type: public
54+
- name: Check for changes in Framework
55+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
56+
id: changes
57+
with:
58+
filters: |
59+
src:
60+
- 'framework/**'
61+
- name: Set up Go
62+
uses: actions/setup-go@v4
63+
with:
64+
go-version: 1.22.8
65+
- name: Cache Go modules
66+
uses: actions/cache@v3
67+
with:
68+
path: |
69+
~/.cache/go-build
70+
~/go/pkg/mod
71+
key: go-modules-${{ hashFiles('framework/examples/myproject/go.sum') }}-${{ runner.os }}-framework-golden-examples
72+
restore-keys: |
73+
go-modules-${{ runner.os }}-framework-golden-examples
74+
go-modules-${{ runner.os }}
75+
- name: Install dependencies
76+
run: go mod download
77+
- name: Run Docker Component Tests
78+
if: steps.changes.outputs.src == 'true'
79+
env:
80+
CTF_CONFIGS: ${{ matrix.test.config }}
81+
run: |
82+
go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }}

.github/workflows/framework.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ jobs:
1010
run:
1111
working-directory: framework
1212
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
1316
steps:
1417
- name: Checkout repo
1518
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
19+
- name: Configure AWS credentials using OIDC
20+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
21+
with:
22+
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
23+
aws-region: us-east-1
24+
- name: Authenticate to ECR Public
25+
id: login-ecr-public
26+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
27+
with:
28+
registry-type: public
1629
- name: Check for changes in Framework
1730
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
1831
id: changes
@@ -25,7 +38,7 @@ jobs:
2538
with:
2639
go-version: 1.22.8
2740
- name: Cache Go modules
28-
uses: actions/cache@v3
41+
uses: actions/cache@v4
2942
with:
3043
path: |
3144
~/.cache/go-build

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
[![Seth tag](https://img.shields.io/github/v/tag/smartcontractkit/chainlink-testing-framework?filter=%2Aseth%2A)](https://github.com/smartcontractkit/chainlink-testing-framework/tags)
1111
[![Havoc tag](https://img.shields.io/github/v/tag/smartcontractkit/chainlink-testing-framework?filter=%2Ahavoc%2A)](https://github.com/smartcontractkit/chainlink-testing-framework/tags)
1212

13-
![Tests](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/test.yaml/badge.svg)
14-
![Lint](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/lint.yaml/badge.svg)
13+
[![Tests](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/test.yaml/badge.svg)](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/test.yaml)
14+
[![Lints](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/lint.yaml/badge.svg)](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/lint.yaml)
1515

1616
[![Go Report Card](https://goreportcard.com/badge/github.com/smartcontractkit/chainlink-testing-framework)](https://goreportcard.com/report/github.com/smartcontractkit/chainlink-testing-framework)
1717
![Go Version](https://img.shields.io/github/go-mod/go-version/smartcontractkit/chainlink-testing-framework?filename=./lib/go.mod)

book/src/SUMMARY.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
- [CLI](./framework/cli.md)
1515
- [Configuration](./framework/configuration.md)
1616
- [Test Configuration](./framework/test_configuration_overrides.md)
17-
- [Caching](framework/components/caching.md)
17+
- [Components Persistence](framework/components/state.md)
18+
- [Components Caching](framework/components/caching.md)
19+
- [External Environment](framework/components/external.md)
1820
- [Secrets]()
21+
- [Docker](framework/docker.md)
1922
- [Observability Stack](framework/observability/observability_stack.md)
2023
- [Metrics](framework/observability/metrics.md)
2124
- [Logs](framework/observability/logs.md)
@@ -36,8 +39,11 @@
3639
- [Chainlink]()
3740
- [RPC]()
3841
- [Loki]()
42+
- [Testing](framework/testing.md)
43+
- [Smoke]()
44+
- [Performance]()
45+
- [Chaos]()
3946
- [Interactive](framework/interactive.md)
40-
- [Continuous Integration](ci/ci.md)
4147
- [Libraries](./libraries.md)
4248
- [Seth](./libs/seth.md)
4349
- [WASP](./libs/wasp.md)

book/src/ci/ci.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

book/src/framework/components/blockchains/anvil.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type Config struct {
5151
func TestDON(t *testing.T) {
5252
in, err := framework.Load[Config](t)
5353
require.NoError(t, err)
54-
pkey := os.Getenv("PRIVATE_KEY")
5554

5655
// deploy anvil blockchain simulator
5756
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Component caching
22

3-
We use component caching to accelerate test development and enforce idempotent test actions.
3+
We use component caching to accelerate test development and enforce idempotent test actions development.
44

55
Each component is isolated by means of inputs and outputs.
66

@@ -9,21 +9,3 @@ If cached config has any outputs with `use_cache = true` it will be used instead
99
```
1010
export CTF_CONFIGS=smoke-cache.toml
1111
```
12-
13-
### Using remote components
14-
15-
Because components are decoupled through outputs, you can use a cached config and switch outputs to any deployed infrastructure, such as staging. This allows you to reuse the same testing logic for behavior validation.
16-
17-
Example:
18-
```
19-
[blockchain_a.out]
20-
use_cache = true
21-
chain_id = '31337'
22-
23-
[[blockchain_a.out.nodes]]
24-
ws_url = 'ws://127.0.0.1:33447'
25-
http_url = 'http://127.0.0.1:33447'
26-
docker_internal_ws_url = 'ws://anvil-3716a:8900'
27-
docker_internal_http_url = 'http://anvil-3716a:8900'
28-
```
29-
Set flag `use_cache = true` on any component output, change output fields as needed and run your test again.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,106 @@
11
# Node
2+
3+
Here we provide *full* configuration parameters for `Node`
4+
5+
<div class="warning">
6+
Here we provide full configuration reference, if you want to copy and run it, please remove all .out fields before!
7+
</div>
8+
9+
10+
## Configuration
11+
```toml
12+
[cl_node]
13+
# Optional URL for fake data provider URL
14+
# usually set up in test with local mock server
15+
data_provider_url = "http://example.com"
16+
17+
[cl_node.db]
18+
# PostgreSQL image version and tag
19+
image = "postgres:15.6"
20+
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
21+
pull_image = true
22+
23+
[cl_node.node]
24+
# A list of paths to capability binaries
25+
capabilities = ["./capability_1", "./capability_2"]
26+
# Default capabilities directory inside container
27+
capabilities_container_dir = "/home/capabilities"
28+
# Image to use, you can either provide "image" or "docker_file" + "docker_ctx" fields
29+
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
30+
# Path to your Chainlink Dockerfile
31+
docker_file = "../../core/chainlink.Dockerfile"
32+
# Path to docker context that should be used to build from
33+
docker_ctx = "../.."
34+
# Optional name for image we build, default is "ctftmp"
35+
docker_image_name = "ctftmp"
36+
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
37+
pull_image = true
38+
# Overrides Chainlink node TOML configuration
39+
# can be multiline, see example
40+
user_config_overrides = """
41+
[Log]
42+
level = 'info'
43+
"""
44+
# Overrides Chainlink node secrets TOML configuration
45+
# you can only add fields, overriding existing fields is prohibited by Chainlink node
46+
user_secrets_overrides = """
47+
[AnotherSecret]
48+
mySecret = 'a'
49+
"""
50+
51+
# Outputs are the results of deploying a component that can be used by another component
52+
[cl_node.out]
53+
# If 'use_cache' equals 'true' we skip component setup when we run the test and return the outputs
54+
use_cache = true
55+
# Describes deployed or external Chainlink node
56+
[cl_node.out.node]
57+
# Host Docker URLs the test uses
58+
# in case of using external component you can replace these URLs with another deployment
59+
p2p_url = "http://127.0.0.1:32812"
60+
url = "http://127.0.0.1:32847"
61+
62+
# Describes deployed or external Chainlink node
63+
[cl_node.out.postgresql]
64+
# PostgreSQL connection string
65+
# in case of using external database can be overriden
66+
url = "postgresql://chainlink:[email protected]:32846/chainlink?sslmode=disable"
67+
```
68+
69+
## Usage
70+
```golang
71+
package yourpackage_test
72+
73+
import (
74+
"fmt"
75+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
76+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
77+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/clnode"
78+
"github.com/stretchr/testify/require"
79+
"testing"
80+
)
81+
82+
type Step2Cfg struct {
83+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
84+
CLNode *clnode.Input `toml:"cl_node" validate:"required"`
85+
}
86+
87+
func TestMe(t *testing.T) {
88+
in, err := framework.Load[Step2Cfg](t)
89+
require.NoError(t, err)
90+
91+
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
92+
require.NoError(t, err)
93+
94+
networkCfg, err := clnode.NewNetworkCfgOneNetworkAllNodes(bc)
95+
require.NoError(t, err)
96+
in.CLNode.Node.TestConfigOverrides = networkCfg
97+
98+
output, err := clnode.NewNodeWithDB(in.CLNode)
99+
require.NoError(t, err)
100+
101+
t.Run("test something", func(t *testing.T) {
102+
fmt.Printf("node url: %s\n", output.Node.HostURL)
103+
require.NotEmpty(t, output.Node.HostURL)
104+
})
105+
}
106+
```

0 commit comments

Comments
 (0)