Skip to content

Commit 5887e37

Browse files
authored
Add docs for Gin usage + record requests/responses [TT-1842] (#1345)
mockserver recording, update docs, move DB config
1 parent 9da2004 commit 5887e37

40 files changed

+441
-255
lines changed

.github/workflows/framework-golden-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
go-modules-${{ runner.os }}
7676
- name: Install dependencies
7777
run: go mod download
78-
- name: Run Docker Component Tests
78+
- name: Run System Tests
7979
if: steps.changes.outputs.src == 'true'
8080
env:
8181
CTF_CONFIGS: ${{ matrix.test.config }}

.github/workflows/framework.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ concurrency:
55
group: ${{ github.workflow }}-${{ github.ref }}-framework
66
cancel-in-progress: true
77
jobs:
8-
test:
8+
framework-component-tests:
99
defaults:
1010
run:
1111
working-directory: framework
@@ -51,4 +51,4 @@ jobs:
5151
- name: Run Docker Component Tests
5252
if: steps.changes.outputs.src == 'true'
5353
run: |
54-
go test -timeout 5m -v -count 1 -run TestDocker ./...
54+
go test -timeout 2m -v -count 1 -run TestComponent ./...

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [Exposing Components](framework/components/state.md)
1818
- [Components Cleanup](framework/components/cleanup.md)
1919
- [Components Caching](framework/components/caching.md)
20+
- [Mocking Services](framework/components/mocking.md)
2021
- [External Environment](framework/components/external.md)
2122
- [Secrets]()
2223
- [Observability Stack](framework/observability/observability_stack.md)

book/src/framework/components/chainlink/node.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ Here we provide full configuration reference, if you want to copy and run it, pl
1010
## Configuration
1111
```toml
1212
[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"
1613

1714
[cl_node.db]
1815
# PostgreSQL image version and tag
1916
image = "postgres:15.6"
2017
# 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
18+
pull_image = false
2219

2320
[cl_node.node]
2421
# custom ports that plugins may need to expose and map to the host machine
@@ -36,7 +33,7 @@ Here we provide full configuration reference, if you want to copy and run it, pl
3633
# Optional name for image we build, default is "ctftmp"
3734
docker_image_name = "ctftmp"
3835
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
39-
pull_image = true
36+
pull_image = false
4037
# Overrides Chainlink node TOML configuration
4138
# can be multiline, see example
4239
user_config_overrides = """

book/src/framework/components/chainlink/nodeset.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,16 @@ Then configure NodeSet
5252
http_port_range_start = 10000
5353
# P2P API port range start, each new node get port incremented (host machine)
5454
p2p_port_range_start = 12000
55-
55+
56+
[nodeset.db]
57+
# PostgreSQL image version and tag
58+
image = "postgres:15.6"
59+
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
60+
pull_image = false
61+
# PostgreSQL volume name
62+
volume_name = ""
5663

5764
[[nodeset.node_specs]]
58-
# Optional URL for fake data provider URL
59-
# usually set up in test with local mock server
60-
data_provider_url = "http://example.com"
61-
62-
[nodeset.node_specs.db]
63-
# PostgreSQL image version and tag
64-
image = "postgres:15.6"
65-
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
66-
pull_image = true
67-
# PostgreSQL volume name
68-
volume_name = ""
6965

7066
[nodeset.node_specs.node]
7167
# custom ports that plugins may need to expose and map to the host machine
@@ -83,7 +79,7 @@ Then configure NodeSet
8379
# Optional name for image we build, default is "ctftmp"
8480
docker_image_name = "ctftmp"
8581
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
86-
pull_image = true
82+
pull_image = false
8783
# Overrides Chainlink node TOML configuration
8884
# can be multiline, see example
8985
user_config_overrides = """
@@ -136,15 +132,13 @@ package capabilities_test
136132
import (
137133
"github.com/smartcontractkit/chainlink-testing-framework/framework"
138134
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
139-
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
140135
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"
141136
"github.com/stretchr/testify/require"
142137
"testing"
143138
)
144139

145140
type Config struct {
146141
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
147-
MockerDataProvider *fake.Input `toml:"data_provider" validate:"required"`
148142
NodeSet *ns.Input `toml:"nodeset" validate:"required"`
149143
}
150144

@@ -154,9 +148,7 @@ func TestMe(t *testing.T) {
154148

155149
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
156150
require.NoError(t, err)
157-
dp, err := fake.NewFakeDataProvider(in.MockerDataProvider)
158-
require.NoError(t, err)
159-
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker)
151+
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc)
160152
require.NoError(t, err)
161153

162154
t.Run("test something", func(t *testing.T) {

book/src/framework/components/external.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,10 @@ For example, to integrate with remote `k8s` environment you can use `CTF_CONFIGS
2020
http_url = "http://127.0.0.1:8545"
2121
ws_url = "ws://127.0.0.1:8545"
2222

23-
[contracts]
24-
25-
[contracts.out]
26-
# set up your contracts
27-
addresses = ["0x5fbdb2315678afecb367f032d93f642f64180aa3"]
28-
use_cache = true
29-
30-
[data_provider]
31-
port = 9111
32-
33-
[data_provider.out]
34-
# setup your data provider URLs
35-
base_url_host = "http://localhost:9111"
36-
3723
[nodeset]
3824

3925
[[nodeset.node_specs]]
26+
...
4027

4128
[nodeset.out]
4229
use_cache = true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Mocking Services
2+
3+
The framework aims to equip you with all the necessary tools to write end-to-end system-level tests, while still allowing the flexibility to mock third-party services that are not critical to your testing scope.
4+
5+
## Configuration
6+
```toml
7+
[fake]
8+
# port to start Gin server
9+
port = 9111
10+
```
11+
12+
## Usage
13+
14+
See [full](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/examples/myproject/fake_test.go) example.

book/src/framework/components/state.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@ You can also define a custom set of ports for any node
4444
[nodeset]
4545
nodes = 5
4646
override_mode = "each"
47+
48+
[nodeset.db]
49+
image = "postgres:15.6"
4750

4851
[[nodeset.node_specs]]
4952

50-
[nodeset.node_specs.db]
51-
image = "postgres:15.6"
52-
pull_image = true
53-
5453
[nodeset.node_specs.node]
5554
# here we defined 2 new ports to listen and mapped them to our host machine
5655
custom_ports = [14000, 14001]
5756
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
58-
pull_image = false
5957
```

book/src/framework/connecting_chainlink_node.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ Create your configuration in `smoke.toml`
1111
type = "anvil"
1212

1313
[cl_node]
14-
data_provider_url = "http://example.com"
1514

1615
[cl_node.db]
1716
image = "postgres:15.6"
18-
pull_image = true
1917

2018
[cl_node.node]
2119
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
22-
pull_image = true
2320
```
2421

2522
Create your test in `smoke_test.go`

book/src/framework/nodeset_capabilities.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,21 @@ Create a configuration file `smoke.toml`
2222
port = "8545"
2323
type = "anvil"
2424

25-
[data_provider]
26-
port = 9111
27-
2825
[nodeset]
2926
nodes = 5
3027
override_mode = "all"
28+
29+
[nodeset.db]
30+
image = "postgres:15.6"
3131

3232
[[nodeset.node_specs]]
3333

34-
[nodeset.node_specs.db]
35-
image = "postgres:15.6"
36-
pull_image = true
37-
3834
[nodeset.node_specs.node]
3935
# path to your capability binaries
4036
capabilities = ["./kvstore"]
4137
# default capabilities directory
4238
# capabilities_container_dir = "/home/capabilities"
4339
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
44-
pull_image = true
45-
4640
```
4741

4842
Run it

0 commit comments

Comments
 (0)