Skip to content

fix(op-acceptor): add build dependencies and increase logs #352

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

serpixel
Copy link

@serpixel serpixel commented May 14, 2025

Description

  • Add git and other build dependencies to the op-acceptor docker image.
  • Increase the timeout for listing tests as it downloads dependencies and increase logs
  • Add extra logging for tests

Tests

Added a test to verify the paths checks logic.

Additional context

When running the tests sometimes we may want to get extra information on these. Right now we need to ssh into the container, but this PR adds a flag to dump the logs into the console.

Requires ethereum-optimism/optimism#16050 for the test log level.

Metadata

  • Fixes #[Link to Issue]

@serpixel serpixel requested a review from a team as a code owner May 14, 2025 18:57
@serpixel serpixel requested a review from bitwiseguy May 14, 2025 18:57
@scharissis
Copy link
Contributor

Do you still think this is needed?

@serpixel serpixel force-pushed the fix/op-acceptor/ensure-package-paths-timeout branch from 1dbbcec to f588c27 Compare May 20, 2025 19:45
@serpixel serpixel changed the title fix(op-acceptor): ensure package paths are valid, increase timeouts fix(op-acceptor): add build dependencies and increase logs May 20, 2025
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2025

Codecov Report

Attention: Patch coverage is 76.25000% with 19 lines in your changes missing coverage. Please review.

Project coverage is 55.66%. Comparing base (47212b6) to head (ea905aa).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
op-acceptor/nat.go 0.00% 10 Missing ⚠️
op-acceptor/runner/runner.go 89.70% 6 Missing and 1 partial ⚠️
op-acceptor/config.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   55.48%   55.66%   +0.17%     
==========================================
  Files          75       75              
  Lines        9591     9646      +55     
==========================================
+ Hits         5322     5369      +47     
- Misses       3913     3920       +7     
- Partials      356      357       +1     
Flag Coverage Δ
op-acceptor 56.78% <76.25%> (+0.54%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
op-acceptor/flags/flags.go 57.14% <ø> (ø)
op-acceptor/config.go 0.00% <0.00%> (ø)
op-acceptor/runner/runner.go 66.70% <89.70%> (+1.60%) ⬆️
op-acceptor/nat.go 37.33% <0.00%> (-0.15%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@serpixel serpixel requested a review from scharissis May 20, 2025 21:18
Comment on lines +43 to +44
# Set ownership of the /app directory to allow the application to write logs and other files at runtime
RUN chown -R app:app /app/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? The logs and files are working without this, I believe?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed if running the docker image locally unless we change the directory we run it on (like in CI).

Comment on lines +394 to +405
// Check if the path is available locally
if isLocalPath(metadata.Package) {
fullPath := filepath.Join(r.workDir, metadata.Package)
if _, statErr := os.Stat(fullPath); os.IsNotExist(statErr) {
r.log.Error("Local package path does not exist, failing test", "validator", metadata.ID, "package", metadata.Package, "fullPath", fullPath)
return &types.TestResult{
Metadata: metadata,
Status: types.TestStatusFail,
Error: fmt.Errorf("local package path does not exist: %s", fullPath),
}, nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't been able to find any evidence that this is needed.
I believe Go can and will resolve local paths, even when referenced as their full package paths.

Are you sure it's needed? How?

Copy link
Author

@serpixel serpixel May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this part if you have a test that uses a local path in 'package' and this path doesn't exist then the entire test suite will fail and it may not be obvious why.
We're using such paths in our test file so this would be relevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow, can you give me an example?

Comment on lines +394 to +405
// Check if the path is available locally
if isLocalPath(metadata.Package) {
fullPath := filepath.Join(r.workDir, metadata.Package)
if _, statErr := os.Stat(fullPath); os.IsNotExist(statErr) {
r.log.Error("Local package path does not exist, failing test", "validator", metadata.ID, "package", metadata.Package, "fullPath", fullPath)
return &types.TestResult{
Metadata: metadata,
Status: types.TestStatusFail,
Error: fmt.Errorf("local package path does not exist: %s", fullPath),
}, nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't been able to find any evidence that this is required. My understanding, and experience, suggest that it's not because Go finds local packages (even when referenced by their full package paths).

Are you sure it's needed?

Copy link
Author

@serpixel serpixel May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment above relating this, the tldr is that without this entry if you have a test that uses a local path in 'package' and this path doesn't exist then the entire test suite will fail.
We're using such paths in our test file so this would be relevant.

Comment on lines 1190 to 1191
// Always set the LOG_LEVEL environment variable
runEnv := append([]string{fmt.Sprintf("LOG_LEVEL=%s", r.testLogLevel)}, os.Environ()...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be TEST_LOG_LEVEL?
Does it get honored?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test for this to ensure the env variable is set. We need ethereum-optimism/optimism#16050 too in order for the tests to be honoring the log level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is it used? I don't see where?

Comment on lines +199 to +201
// Verify that logs are not captured when OutputTestLogs is disabled
assert.Equal(t, types.TestStatusPass, testResult2.Status)
assert.Contains(t, testResult2.Stdout, "This is a test output")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be asserting that it does NOT contain this output?

Suggested change
// Verify that logs are not captured when OutputTestLogs is disabled
assert.Equal(t, types.TestStatusPass, testResult2.Status)
assert.Contains(t, testResult2.Stdout, "This is a test output")
// Verify that logs are not captured when OutputTestLogs is disabled
assert.Equal(t, types.TestStatusPass, testResult2.Status)
assert.NotContains(t, testResult2.Stdout, "This is a test output")

@@ -68,3 +70,133 @@ gates:
assert.Contains(t, failingTest.Stdout, "This is some stdout output that should be captured")
assert.Contains(t, failingTest.Stdout, "This is a second line of output")
}

// TestLogLevelEnvironment verifies that the TEST_LOG_LEVEL environment variable is correctly set and used
func TestLogLevelEnvironment(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also test the different levels behave differently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

op-acceptor: Output logs to the console and enable extra logs for tests when running in CI
3 participants