Skip to content

Commit 617a101

Browse files
committed
set all URLs to 15m/5s refresh, fix shadowed error in DefaultNetwork
1 parent 7dcf0a5 commit 617a101

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

framework/.changeset/v0.10.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Expose observability stack functions to reuse in devenv repository
2+
- Set all dashboard URLs to 15m/5s
3+
- Add config functions compatible with devenv

framework/cmd/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func main() {
115115
Aliases: []string{"u"},
116116
Description: "Spins up Blockscout stack",
117117
Action: func(c *cli.Context) error {
118-
return framework.BlockscoutUp(c.String("rpc"))
118+
return framework.BlockScoutUp(c.String("rpc"))
119119
},
120120
},
121121
{
@@ -124,7 +124,7 @@ func main() {
124124
Aliases: []string{"d"},
125125
Description: "Removes Blockscout stack, wipes all Blockscout databases data",
126126
Action: func(c *cli.Context) error {
127-
return framework.BlockscoutDown(c.String("rpc"))
127+
return framework.BlockScoutDown(c.String("rpc"))
128128
},
129129
},
130130
{
@@ -134,10 +134,10 @@ func main() {
134134
Description: "Reboots Blockscout stack",
135135
Action: func(c *cli.Context) error {
136136
rpc := c.String("rpc")
137-
if err := framework.BlockscoutDown(rpc); err != nil {
137+
if err := framework.BlockScoutDown(rpc); err != nil {
138138
return err
139139
}
140-
return framework.BlockscoutUp(rpc)
140+
return framework.BlockScoutUp(rpc)
141141
},
142142
},
143143
},

framework/config.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ func LoadCache[X any](t *testing.T) (*X, error) {
224224
return Load[X](t)
225225
}
226226

227+
// BaseConfigPath returns base config path, ex. env.toml,overrides.toml -> env.toml
227228
func BaseConfigPath() (string, error) {
228229
configs := os.Getenv("CTF_CONFIGS")
229230
if configs == "" {
@@ -233,6 +234,7 @@ func BaseConfigPath() (string, error) {
233234
return strings.Split(configs, ",")[0], nil
234235
}
235236

237+
// BaseConfigName returns base config name, ex. env.toml -> env
236238
func BaseConfigName() (string, error) {
237239
cp, err := BaseConfigPath()
238240
if err != nil {
@@ -241,6 +243,7 @@ func BaseConfigName() (string, error) {
241243
return strings.Replace(cp, ".toml", "", -1), nil
242244
}
243245

246+
// BaseCacheName returns base cache file name, ex.: env.toml -> env-cache.toml
244247
func BaseCacheName() (string, error) {
245248
cp, err := BaseConfigPath()
246249
if err != nil {
@@ -252,15 +255,17 @@ func BaseCacheName() (string, error) {
252255

253256
func DefaultNetwork(once *sync.Once) error {
254257
var net *testcontainers.DockerNetwork
255-
var err error
258+
var innerErr error
256259
once.Do(func() {
257-
net, err = network.New(
260+
net, innerErr = network.New(
258261
context.Background(),
259262
network.WithLabels(map[string]string{"framework": "ctf"}),
260263
)
261-
DefaultNetworkName = net.Name
264+
if innerErr == nil {
265+
DefaultNetworkName = net.Name
266+
}
262267
})
263-
return err
268+
return innerErr
264269
}
265270

266271
func RenderTemplate(tmpl string, data interface{}) (string, error) {

framework/observability.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ var EmbeddedObservabilityFiles embed.FS
1414

1515
const (
1616
LocalCLNodeErrorsURL = "http://localhost:3000/d/a7de535b-3e0f-4066-bed7-d505b6ec9ef1/cl-node-errors?orgId=1&refresh=5s"
17-
LocalWorkflowEngineURL = "http://localhost:3000/d/ce589a98-b4be-4f80-bed1-bc62f3e4414a/workflow-engine?orgId=1&refresh=5s"
18-
LocalLogsURL = "http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22P8E80F9AEF21F6940%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22P8E80F9AEF21F6940%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-15m%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
19-
LocalPrometheusURL = "http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22PBFA97CFB590B2093%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22range%22:true,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22PBFA97CFB590B2093%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
20-
LocalPostgresDebugURL = "http://localhost:3000/d/000000039/postgresql-database?orgId=1&refresh=10s&var-DS_PROMETHEUS=PBFA97CFB590B2093&var-interval=$__auto_interval_interval&var-namespace=&var-release=&var-instance=postgres_exporter_0:9187&var-datname=All&var-mode=All&from=now-5m&to=now"
21-
LocalPyroScopeURL = "http://localhost:4040"
17+
LocalWorkflowEngineURL = "http://localhost:3000/d/ce589a98-b4be-4f80-bed1-bc62f3e4414a/workflow-engine?orgId=1&refresh=5s&from=now-15m&to=now"
18+
LocalLogsURL = "http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22P8E80F9AEF21F6940%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bjob%3D%5C%22ctf%5C%22%7D%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22P8E80F9AEF21F6940%22%7D,%22editorMode%22:%22code%22%7D%5D,%22range%22:%7B%22from%22:%22now-15m%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
19+
LocalPrometheusURL = "http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22PBFA97CFB590B2093%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22range%22:true,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22PBFA97CFB590B2093%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-15m%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
20+
LocalPostgresDebugURL = "http://localhost:3000/d/000000039/postgresql-database?orgId=1&refresh=5s&var-DS_PROMETHEUS=PBFA97CFB590B2093&var-interval=$__auto_interval_interval&var-namespace=&var-release=&var-instance=postgres_exporter_0:9187&var-datname=All&var-mode=All&from=now-15m&to=now"
21+
LocalPyroScopeURL = "http://localhost:4040/?query=process_cpu%3Acpu%3Ananoseconds%3Acpu%3Ananoseconds%7Bservice_name%3D%22chainlink-node%22%7D&from=now-15m"
2222
)
2323

2424
// extractAllFiles goes through the embedded directory and extracts all files to the current directory
@@ -75,7 +75,7 @@ func extractAllFiles(embeddedDir string) error {
7575
return err
7676
}
7777

78-
func BlockscoutUp(url string) error {
78+
func BlockScoutUp(url string) error {
7979
L.Info().Msg("Creating local Blockscout stack")
8080
if err := extractAllFiles("observability"); err != nil {
8181
return err
@@ -93,7 +93,7 @@ func BlockscoutUp(url string) error {
9393
return nil
9494
}
9595

96-
func BlockscoutDown(url string) error {
96+
func BlockScoutDown(url string) error {
9797
L.Info().Msg("Removing local Blockscout stack")
9898
os.Setenv("BLOCKSCOUT_RPC_URL", url)
9999
err := RunCommand("bash", "-c", fmt.Sprintf(`

0 commit comments

Comments
 (0)