Skip to content

Commit d8d5cee

Browse files
committed
docs on test configuration and validation, switch healthchecks
1 parent f45899b commit d8d5cee

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

book/src/framework/test_configuration_overrides.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
1-
# Overriding Test Configuration
1+
# Test Configuration
2+
3+
Since end-to-end system-level test configurations can become complex, we use a single, generic method to marshal any configuration.
4+
5+
Here’s an example of how you can extend your configuration.
6+
7+
```golang
8+
type Cfg struct {
9+
// Usually you'll have basic components
10+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
11+
MockerDataProvider *fake.Input `toml:"data_provider" validate:"required"`
12+
NodeSet *ns.Input `toml:"nodeset" validate:"required"`
13+
// And some custom test-related data
14+
MyCustomTestData string `toml:"my_custom_test_data" validate:"required"`
15+
}
16+
17+
func TestSmoke(t *testing.T) {
18+
in, err := framework.Load[Cfg](t)
19+
require.NoError(t, err)
20+
in.MyCustomTestData // do something
21+
...
22+
}
23+
```
24+
25+
We use [validator](https://github.com/go-playground/validator) to make sure anyone can properly configure your test.
26+
27+
All basic components configuration is described in our docs, but it’s recommended to comment on your configuration in TOML.
28+
29+
Additionally, use `validate:"required"` or `validate:"required,oneof=anvil geth"` for fields with strict value options on your custom configuration.
30+
```
31+
# My custom config does X
32+
[MyCustomConfig]
33+
# Can be a number
34+
a = 1
35+
# Can be Y or Z
36+
b = "Z"
37+
```
38+
39+
40+
## Overriding Test Configuration
241

342
To override any test configuration, we merge multiple files into a single struct.
443

framework/.changeset/v0.2.3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Add docs for extending test configuration
2+
- Timeout for node healthchecks after more testing

framework/components/clnode/clnode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,18 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
167167
"/bin/sh", "-c",
168168
"chainlink -c /config/config -c /config/overrides -c /config/user-overrides -s /config/secrets -s /config/secrets-overrides -s /config/user-secrets-overrides node start -d -p /config/node_password -a /config/apicredentials",
169169
},
170-
WaitingFor: wait.ForLog("Listening and serving HTTP").WithStartupTimeout(2 * time.Minute),
170+
WaitingFor: wait.ForHTTP("/").WithPort(DefaultHTTPPort).WithStartupTimeout(2 * time.Minute),
171171
}
172172
if in.Node.HTTPPort != 0 && in.Node.P2PPort != 0 {
173173
req.HostConfigModifier = func(h *container.HostConfig) {
174174
h.PortBindings = nat.PortMap{
175-
"6688/tcp": []nat.PortBinding{
175+
nat.Port(httpPort): []nat.PortBinding{
176176
{
177177
HostIP: "0.0.0.0",
178178
HostPort: fmt.Sprintf("%d/tcp", in.Node.HTTPPort),
179179
},
180180
},
181-
"6690/udp": []nat.PortBinding{
181+
nat.Port(p2pPort): []nat.PortBinding{
182182
{
183183
HostIP: "0.0.0.0",
184184
HostPort: fmt.Sprintf("%d/udp", in.Node.P2PPort),

0 commit comments

Comments
 (0)