-
Notifications
You must be signed in to change notification settings - Fork 47
Integration tests for Rbuilder #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Claude finished @ferranbt's task in 1m 11s —— View job Code Review SummaryI've reviewed this PR which adds integration tests for the Rbuilder component. Here are the key findings: Issues Found1. Error Handling (playground/components.go:761)
2. Inconsistent Service Naming (playground/components.go:763)
3. Missing Artifacts/Volumes (playground/components.go:763-770)
4. Test Quality (playground/components_test.go:127)
5. Documentation (playground/utils/rbuilder-config.toml.tmpl:4)
Positive Changes
RecommendationThe Rbuilder component needs the missing artifact/volume mounts to work at runtime. Consider adding proper health checks as well. Task List
|
| component := NewComponent("rbuilder") | ||
|
|
||
| // TODO: Handle error | ||
| ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error from WriteFile is silently ignored. The TODO comment acknowledges this but the error should be handled. Consider returning the error or at minimum logging it.
| ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml) | |
| if err := ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml); err != nil { | |
| // Since Apply doesn't return error, we must log or panic | |
| panic(fmt.Sprintf("failed to write rbuilder config: %v", err)) | |
| } |
Note: A better long-term fix would be to change the ComponentGen.Apply interface to return (*Component, error) to allow proper error propagation.
playground/components.go
Outdated
| // TODO: Handle error | ||
| ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml) | ||
|
|
||
| component.NewService("component"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service is named "component" which is generic and doesn't match the component name "rbuilder". Other components use meaningful service names (e.g., op-rbuilder, mev-boost, op-geth).
| component.NewService("component"). | |
| component.NewService("rbuilder"). |
| } | ||
| tt.test(recipe, nil) | ||
|
|
||
| time.Sleep(10 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This time.Sleep(10 * time.Second) adds unnecessary delay to the test suite without verifying any condition. If the test needs to validate something after startup, use a proper wait condition (like waitForBlock used in other tests). If the sleep is meant to give rbuilder time to start, consider adding a health check to the Rbuilder component instead.
|
|
||
| chain = "/data/genesis.json" | ||
| reth_datadir = "/data/volume-el-data" | ||
| relay_secret_key = "5eae315483f028b5cdd5d1090ff0c7618b18737ea9bf3c35047189db22835c48" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded secrets (relay_secret_key and coinbase_secret_key) in the config template. While acceptable for development/testing, consider adding a comment to clarify these are intentionally insecure test values, similar to comments in other files (e.g., OpRbuilder at line 87 uses 0xac09... with no comment either).
playground/components.go
Outdated
| component.NewService("component"). | ||
| WithImage("ghcr.io/flashbots/rbuilder"). | ||
| WithTag("1.3.5"). | ||
| WithArtifact("/data/rbuilder-config.toml", "rbuilder-config.toml"). | ||
| WithArgs( | ||
| "run", "/data/rbuilder-config.toml", | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Rbuilder component is missing:
- Health check - Most other components define a
WithReady()health check. Without it, dependent services cannot useDependsOnHealthy(). - Required artifacts - The config references
/data/genesis.jsonand/data/volume-el-databut these aren't mounted viaWithArtifact()orWithVolume(). The component will likely fail at runtime.
Consider:
component.NewService("rbuilder").
WithImage("ghcr.io/flashbots/rbuilder").
WithTag("1.3.5").
WithArtifact("/data/rbuilder-config.toml", "rbuilder-config.toml").
WithArtifact("/data/genesis.json", "genesis.json").
WithVolume("el-data", "/data/volume-el-data").
WithArgs(
"run", "/data/rbuilder-config.toml",
)|
Claude finished @ferranbt's task in 2m 14s —— View job Code Review Summary
This update addresses several issues from the previous review (service naming fixed, genesis.json and volume mounts added, config paths corrected). The new Remaining issues:
The most critical issue is the missing health check - without it, the test framework's |
| component := NewComponent("rbuilder") | ||
|
|
||
| // TODO: Handle error | ||
| ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error from WriteFile is still ignored. The TODO comment acknowledges this but the error should be handled properly. Consider returning the error or at minimum logging it, as silent failures can lead to hard-to-debug runtime issues.
| ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml) | |
| if err := ctx.Output.WriteFile("rbuilder-config.toml", rbuilderConfigToml); err != nil { | |
| panic(fmt.Sprintf("failed to write rbuilder config: %v", err)) | |
| } |
Note: A better long-term fix would be to change the ComponentGen.Apply interface to return (*Component, error).
| } | ||
| tt.test(recipe, nil) | ||
|
|
||
| time.Sleep(10 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This time.Sleep(10 * time.Second) adds unnecessary delay without verifying any condition. The test framework already calls WaitForReady which waits for health checks. Without a health check on the Rbuilder component (see below), this sleep doesn't actually validate anything useful.
Either:
- Add a health check to the Rbuilder component and remove this sleep, or
- Add actual assertions after the sleep to validate rbuilder behavior (e.g., verify it's responding to requests)
| WithArgs( | ||
| "run", "/data/rbuilder-config.toml", | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Rbuilder component is missing a health check. Most other components define a WithReady() health check, which allows the test framework's WaitForReady to properly wait for this service. Without it, dependent services cannot use DependsOnHealthy() and the integration test can't reliably verify the service started correctly.
Consider adding a health check similar to other components, for example:
WithReady(ReadyCheck{
Test: HealthcheckTest{"/bin/sh", "-c", "curl -sf http://localhost:PORT/health || exit 1"},
})| if err := d.validateImageExists(imageName); err != nil { | ||
| return nil, nil, fmt.Errorf("failed to validate image %s: %w", imageName, err) | ||
| // TODO: Cannot validate if they have a platform | ||
| if s.Platform == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipping image validation when a platform is specified creates a potential failure mode. If the image doesn't exist, the error will only surface later during docker compose up.
Consider enhancing validateImageExists to accept a platform parameter instead of skipping validation entirely, or document why platform-specific images can't be validated.
| "labels": labels, | ||
| } | ||
|
|
||
| if s.Platform != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service-level platform (line 560) can be overwritten by the config-level platform (line 564). This may be intentional, but it means WithPlatform() has no effect if d.config.Platform is set. Consider:
- Documenting this precedence behavior, or
- Only applying config platform if service platform is empty:
if s.Platform != "" {
service["platform"] = s.Platform
} else if d.config.Platform != "" {
service["platform"] = d.config.Platform
}
No description provided.