Skip to content

Commit af1eab4

Browse files
authored
Merge branch 'main' into TT-1711
2 parents 6bf9fa8 + 45cc193 commit af1eab4

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Configuration
22

33
### Environment variables
4-
| Name | Description | Possible values | Default | Required? |
5-
|:----------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:|-------------------------:|:-------:|:------------------------:|
6-
| 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 | ||
7-
| CTF_LOG_LEVEL | Harness log level | `info`, `debug`, `trace` | `info` | 🚫 |
8-
| CTF_LOKI_STREAM | Streams all components logs to `Loki`, see params below | `true`, `false` | `false` | 🚫 |
9-
| LOKI_URL | URL to `Loki` push api, should be like`${host}/loki/api/v1/push` | URL | - | If you use `Loki` then ✅ |
10-
| LOKI_TENANT_ID | Streams all components logs to `Loki`, see params below | `true`, `false` | - | If you use `Loki` then ✅ |
11-
| TESTCONTAINERS_RYUK_DISABLED | Testcontainers-Go reaper container, removes all the containers after the test exit | `true`, `false` | `false` | 🚫 |
12-
| RESTY_DEBUG | Log all Resty client HTTP calls | `true`, `false` | `false` | 🚫 |
4+
| Name | Description | Possible values | Default | Required? |
5+
|:----------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:|-------------------------:|:---------------------------------------------------:|:---------:|
6+
| TESTCONTAINERS_RYUK_DISABLED | Testcontainers-Go reaper container, removes all the containers after the test exit | `true`, `false` | `false` | 🚫 |
7+
| 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 | - ||
8+
| CTF_LOG_LEVEL | Harness log level | `info`, `debug`, `trace` | `info` | 🚫 |
9+
| CTF_PROMTAIL_DEBUG | Set `true` if you are integrating with remote `Loki` push API to debug Promtail | `true`, `false` | `false` | 🚫 |
10+
| 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` | 🚫 |
11+
| LOKI_TENANT_ID | Streams all components logs to `Loki`, see params below | `string` | `promtail` | 🚫 |
12+
| LOKI_BASIC_AUTH | Basic auth in format $user:$password | `$user:$password` | - | 🚫 |
13+
| RESTY_DEBUG | Log all Resty client HTTP calls | `true`, `false` | `false` | 🚫 |

book/src/framework/getting_started.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,15 @@ More CLI [docs](./cli.md)
2121

2222
Create an `.envrc` file and put common parameters there (you can use [direnv](https://direnv.net/) to sync them more easily)
2323
```
24-
export CTF_LOG_LEVEL=info
25-
export CTF_LOKI_STREAM=true
26-
export TESTCONTAINERS_RYUK_DISABLED=true
27-
28-
export CTF_CONFIGS=smoke.toml
29-
export PRIVATE_KEY="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
24+
export TESTCONTAINERS_RYUK_DISABLED=true # do not remove containers while we develop locally
25+
export CTF_CONFIGS=smoke.toml # our configuration file
3026
```
3127

3228
Now you are ready to write your [first test](./first_test.md)
3329

3430
## Tools setup (Optional)
3531

36-
This setup is optional, and it explains how to setup a local observability stack for on-chain and off-chain components.
32+
This setup is optional, and it explains how to create a local observability stack for on-chain and off-chain components.
3733

3834
Spin up your local obserability stack (Grafana LGTM)
3935
```

book/src/framework/images/img.png

28.3 KB
Loading

book/src/framework/interactive.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ For other platforms use [Docker Desktop](https://www.docker.com/products/docker-
1111

1212
Download the latest CLI [here](https://github.com/smartcontractkit/chainlink-testing-framework/releases/tag/framework%2Fv0.1.6)
1313

14+
Allow it to run in `System Settings -> Security Settings` (OS X)
15+
16+
![img.png](images/img.png)
17+
1418
```
1519
./framework build node_set
1620
```

framework/.changeset/v0.1.7.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Simplify env vars
2+
- Ship all logs to local Loki by default

framework/config.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const (
2828

2929
const (
3030
EnvVarTestConfigs = "CTF_CONFIGS"
31-
EnvVarLokiStream = "CTF_LOKI_STREAM"
3231
EnvVarAWSSecretsManager = "CTF_AWS_SECRETS_MANAGER"
3332
// EnvVarCI this is a default env variable many CI runners use so code can detect we run in CI
3433
EnvVarCI = "CI"
@@ -141,13 +140,8 @@ func Load[X any](t *testing.T) (*X, error) {
141140
//}
142141
err = DefaultNetwork(once)
143142
require.NoError(t, err)
144-
if err != nil {
145-
return input, err
146-
}
147-
if os.Getenv(EnvVarLokiStream) == "true" {
148-
err = NewPromtail()
149-
require.NoError(t, err)
150-
}
143+
err = NewPromtail()
144+
require.NoError(t, err)
151145
return input, nil
152146
}
153147

framework/promtail.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ scrape_configs:
5858
lokiURL := os.Getenv("LOKI_URL")
5959
lokiTenantID := os.Getenv("LOKI_TENANT_ID")
6060

61-
if lokiURL == "" || lokiTenantID == "" {
62-
return "", errors.New("LOKI_URL or LOKI_TENANT_ID environment variable is missing")
61+
if lokiURL == "" {
62+
lokiURL = "http://host.docker.internal:3030/loki/api/v1/push"
63+
}
64+
if lokiTenantID == "" {
65+
lokiTenantID = "promtail"
6366
}
6467

6568
lokiBasicAuth := os.Getenv("LOKI_BASIC_AUTH")
@@ -99,8 +102,8 @@ scrape_configs:
99102
if err != nil {
100103
return "", fmt.Errorf("could not execute promtail config template: %w", err)
101104
}
105+
L.Debug().Str("Path", filePath).Msg("Promtail configuration written to")
102106

103-
fmt.Printf("Promtail config written to %s\n", filePath)
104107
return configFile.Name(), nil
105108
}
106109

@@ -115,7 +118,7 @@ func NewPromtail() error {
115118

116119
cmd := make([]string, 0)
117120
cmd = append(cmd, "-config.file=/etc/promtail/promtail-config.yml")
118-
if os.Getenv("CTF_LOKI_STREAM_DEBUG") != "" {
121+
if os.Getenv("CTF_PROMTAIL_DEBUG") != "" {
119122
cmd = append(cmd, "-log.level=debug")
120123
}
121124

0 commit comments

Comments
 (0)