Skip to content

Commit 61fcc19

Browse files
authored
Merge branch 'main' into tt-1725-doc-generating-pipeline
2 parents 17d91a0 + 1449c13 commit 61fcc19

Some content is hidden

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

81 files changed

+1691
-4483
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ jobs:
1010
env:
1111
LOKI_TENANT_ID: promtail
1212
LOKI_URL: http://localhost:3030/loki/api/v1/push
13-
# this is not the best practice, and it must be fixed, run your tests WITHOUT IT!
14-
# however, on current latest image we must use this flag
15-
CTF_IGNORE_CRITICAL_LOGS: true
1613
runs-on: ubuntu-latest
1714
permissions:
1815
id-token: write

.github/workflows/framework.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ jobs:
99
defaults:
1010
run:
1111
working-directory: framework
12+
env:
13+
CTF_JD_IMAGE: ${{ secrets.CTF_JD_IMAGE }}
1214
runs-on: ubuntu-latest
1315
permissions:
1416
id-token: write

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,17 @@ Public: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
7272
Private: ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
7373
```
7474

75-
Test keys for `Besu` can be found [here](https://besu.hyperledger.org/23.4.1/private-networks/reference/accounts-for-testing)
75+
For `Besu` keys are
76+
```
77+
Public: 0xfe3b557e8fb62b89f4916b721be55ceb828dbd73
78+
Private: 0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63
79+
80+
Public: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57
81+
Private: 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3
82+
83+
Public: 0xf17f52151EbEF6C7334FAD080c5704D77216b732
84+
Private: 0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f
85+
```
86+
87+
More docs for `Besu` can be found [here](https://besu.hyperledger.org/private-networks/reference/accounts-for-testing)
7688

book/src/framework/components/state.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ One node set is enough for any kind of testing, if you need more nodes consider
4040

4141
## Custom ports
4242

43-
You can also define a custom set of ports for any node
43+
You can also define a custom set of ports for any node.
4444
```toml
4545
[nodeset]
4646
nodes = 5
@@ -53,6 +53,7 @@ You can also define a custom set of ports for any node
5353

5454
[nodeset.node_specs.node]
5555
# here we defined 2 new ports to listen and mapped them to our host machine
56-
custom_ports = [14000, 14001]
56+
# syntax is "host:docker", if you provide only host port then we map 1-to-1
57+
custom_ports = ["14000:15000", "20000"]
5758
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
5859
```

book/src/framework/configuration.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
| CTF_CONFIGS | Path(s) to test config files. <br/>Can be more than one, ex.: smoke.toml,smoke_1.toml,smoke_2.toml.<br/>First filepath will hold all the merged values | Any valid TOML file path | - ||
88
| CTF_LOG_LEVEL | Harness log level | `info`, `debug`, `trace` | `info` | 🚫 |
99
| CTF_PROMTAIL_DEBUG | Set `true` if you are integrating with remote `Loki` push API to debug Promtail | `true`, `false` | `false` | 🚫 |
10+
| CTF_IGNORE_CRITICAL_LOGS | Ignore all logs that has CRIT,FATAL or PANIC levels (Chainlink nodes only!) | `true`, `false` | `false` | 🚫 |
11+
| CTF_CHAINLINK_IMAGE | Flag to override Chainlink Docker image in format $repository:$tag | $repository:$tag | - | 🚫 |
12+
| CTF_JD_IMAGE | Job distributor service image in format $repository:$tag | $repository:$tag | - | 🚫 |
1013
| LOKI_URL | URL to `Loki` push api, should be like`${host}/loki/api/v1/push` | URL | `http://host.docker.internal:3030/loki/api/v1/push` | 🚫 |
1114
| LOKI_TENANT_ID | Streams all components logs to `Loki`, see params below | `string` | `promtail` | 🚫 |
1215
| LOKI_BASIC_AUTH | Basic auth in format $user:$password | `$user:$password` | - | 🚫 |
1316
| RESTY_DEBUG | Log all Resty client HTTP calls | `true`, `false` | `false` | 🚫 |
14-
| CTF_IGNORE_CRITICAL_LOGS | Ignore all logs that has CRIT,FATAL or PANIC levels (Chainlink nodes only!) | `true`, `false` | `false` | 🚫 |
15-
| CTF_CHAINLINK_IMAGE | Flag to override Chainlink Docker image in format $repository:$tag | $repository:$tag | - | 🚫 |

book/src/lib.md

Lines changed: 9 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -252,38 +252,13 @@ Builder will read the location of chain configuration from env var named `PRIVAT
252252

253253
`net` is an instance of `blockchain.EVMNetwork`, which contains characteristics of the network and can be used to connect to it using an EVM client. `rpc` variable contains arrays of public and private RPC endpoints, where "private" means URL that's accessible from the same Docker network as the chain is running in.
254254

255-
# Using LogStream
255+
## Logs
256+
By default, we will save logs of all Docker containers running on the host machine, when the test ends (regardless whether it failed or succeeded). They will be available in the `./logs/<test-name><date>` directory. Same goes for dumping the databases of PostgresDBs
257+
used by the Chainlink nodes. These will be saves in the `./db_dumps/<test-name><date>` directory.
256258

257-
LogStream is a package that allows to connect to a Docker container and then flush logs to configured targets. Currently 3 targets are supported:
259+
## Loki and Grafana
258260

259-
- `file` - saves logs to a file in `./logs` folder
260-
- `loki` - sends logs to Loki
261-
- `in-memory` - stores logs in memory
262-
263-
It can be configured to use multiple targets at once. If no target is specified, it becomes a no-op.
264-
265-
LogStream has to be configured by passing an instance of `LoggingConfig` to the constructor.
266-
267-
When you connect a container LogStream will create a new consumer and start a detached goroutine that listens to logs emitted by that container and which reconnects and re-requests logs if listening fails for whatever reason. Retry limit and timeout can both be configured using functional options. In most cases one container should have one consumer, but it's possible to have multiple consumers for one container.
268-
269-
LogStream stores all logs in gob temporary file. To actually send/save them, you need to flush them. When you do it, LogStream will decode the file and send logs to configured targets. If log handling results in an error it won't be retried and processing of logs for given consumer will stop (if you think we should add a retry mechanism please let us know).
270-
271-
_Important:_ Flushing and accepting logs is blocking operation. That's because they both share the same cursor to temporary file and otherwise it's position would be racey and could result in mixed up logs.
272-
273-
## Configuration
274-
275-
Basic `LogStream` TOML configuration is following:
276-
277-
```toml
278-
[LogStream]
279-
log_targets=["file"]
280-
log_producer_timeout="10s"
281-
log_producer_retry_limit=10
282-
```
283-
284-
You can find it here: [logging_default.toml](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/lib/config/tomls/logging_default.toml)
285-
286-
When using `in-memory` or `file` target no other configuration variables are required. When using `loki` target, following ones must be set:
261+
If you need to pass Loki or Grafana configuration to your tests you can do that by providing the following config:
287262

288263
```toml
289264
[Logging.Loki]
@@ -295,87 +270,13 @@ bearer_token_secret="bearer-token"
295270

296271
Also, do remember that different URL should be used when running in CI and everywhere else. In CI it should be a public endpoint, while in local environment it should be a private one.
297272

298-
If your test has a Grafana dashboard in order for the url to be correctly printed you should provide the following config:
273+
If your test has a Grafana dashboard you should provide the following config:
299274

300275
```toml
301276
[Logging.Grafana]
302-
url="http://grafana.somwhere.com/my_dashboard"
303-
```
304-
305-
## Initialisation
306-
307-
First you need to create a new instance:
308-
309-
```golang
310-
// t - instance of *testing.T (can be nil)
311-
// testConfig.Logging - pointer to logging part of TestConfig
312-
ls := logstream.NewLogStream(t, testConfig.Logging)
313-
```
314-
315-
## Listening to logs
316-
317-
If using `testcontainers-go` Docker containers it is recommended to use life cycle hooks for connecting and disconnecting LogStream from the container. You can do that when creating `ContainerRequest` in the following way:
318-
319-
```golang
320-
containerRequest := &tc.ContainerRequest{
321-
LifecycleHooks: []tc.ContainerLifecycleHooks{
322-
{PostStarts: []tc.ContainerHook{
323-
func(ctx context.Context, c tc.Container) error {
324-
if ls != nil {
325-
return n.ls.ConnectContainer(ctx, c, "custom-container-prefix-can-be-empty")
326-
}
327-
return nil
328-
},
329-
},
330-
PostStops: []tc.ContainerHook{
331-
func(ctx context.Context, c tc.Container) error {
332-
if ls != nil {
333-
return n.ls.DisconnectContainer(c)
334-
}
335-
return nil
336-
},
337-
}},
338-
},
339-
}
340-
```
341-
342-
You can print log location for each target using this function: `(m *LogStream) PrintLogTargetsLocations()`. For `file` target it will print relative folder path, for `loki` it will print URL of a Grafana Dashboard scoped to current execution and container ids. For `in-memory` target it's no-op.
343-
344-
It is recommended to shutdown LogStream at the end of your tests. Here's an example:
345-
346-
```golang
347-
t.Cleanup(func() {
348-
l.Warn().Msg("Shutting down Log Stream")
349-
350-
if t.Failed() || os.Getenv("TEST_LOG_COLLECT") == "true" {
351-
// we can't do much if this fails, so we just log the error
352-
_ = logStream.FlushLogsToTargets()
353-
// this will log log locations for each target (for file it will be a folder, for Loki Grafana dashboard -- remember to provide it's url in config!)
354-
logStream.PrintLogTargetsLocations()
355-
// this will save log locations in test summary, so that they can be easily accessed in GH's step summary
356-
logStream.SaveLogLocationInTestSummary()
357-
}
358-
359-
// we can't do much if this fails, so we just log the error
360-
_ = logStream.Shutdown(testcontext.Get(b.t))
361-
})
362-
```
363-
364-
or in a bit shorter way:
365-
366-
```golang
367-
t.Cleanup(func() {
368-
l.Warn().Msg("Shutting down Log Stream")
369-
370-
if t.Failed() || os.Getenv("TEST_LOG_COLLECT") == "true" {
371-
// this will log log locations for each target (for file it will be a folder, for Loki Grafana dashboard -- remember to provide it's url in config!)
372-
logStream.PrintLogTargetsLocations()
373-
// this will save log locations in test summary, so that they can be easily accessed in GH's step summary
374-
}
375-
376-
// we can't do much if this fails
377-
_ = logStream.FlushAndShutdown()
378-
})
277+
base_url="https://your-grafana-url"
278+
dashboard_url="/my-dashboard"
279+
dashboard_uid="my-dashboard-uid" # optional
379280
```
380281

381282
## Grouping test execution

book/src/lib/config/config.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ convert_to_toml_array() {
278278
}
279279
280280
selected_networks=$(convert_to_toml_array "$SELECTED_NETWORKS")
281-
log_targets=$(convert_to_toml_array "$LOGSTREAM_LOG_TARGETS")
282281
283282
if [ -n "$PYROSCOPE_SERVER" ]; then
284283
pyroscope_enabled=true
@@ -292,12 +291,6 @@ else
292291
execution_layer="geth"
293292
fi
294293
295-
if [ -n "$TEST_LOG_COLLECT" ]; then
296-
test_log_collect=true
297-
else
298-
test_log_collect=false
299-
fi
300-
301294
cat << EOF > config.toml
302295
[Network]
303296
selected_networks=$selected_networks
@@ -312,13 +305,6 @@ server_url="$PYROSCOPE_SERVER"
312305
environment="$PYROSCOPE_ENVIRONMENT"
313306
key_secret="$PYROSCOPE_KEY"
314307
315-
[Logging]
316-
test_log_collect=$test_log_collect
317-
run_id="$RUN_ID"
318-
319-
[Logging.LogStream]
320-
log_targets=$log_targets
321-
322308
[Logging.Loki]
323309
tenant_id="$LOKI_TENANT_ID"
324310
url="$LOKI_URL"

framework/.changeset/v0.3.2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- Allow exposing CL node ports in host:docker format
2+
- Expose default test private keys as framework constants
3+
- Rename CHAINLINK_IMAGE to CTF_CHAINLINK_IMAGE to avoid CI collisions
4+
- Add CTF_JD_IMAGE env var
5+
- Add JobDistributor component

framework/.changeset/v0.3.3.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Upgrade Besu to 24.9.1
2+
- Expose default test private keys as framework constants
3+
- Collect all the logs even between restarts

framework/.changeset/v0.3.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Bump go-ethereum as in core, fix darwin amd/arm binary release

0 commit comments

Comments
 (0)