Skip to content
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

Improve logging and e2e script #99

Merged
merged 1 commit into from
Feb 24, 2025
Merged

Improve logging and e2e script #99

merged 1 commit into from
Feb 24, 2025

Conversation

Noctunus
Copy link
Member

@Noctunus Noctunus commented Feb 24, 2025

  • Moved pretty much all the chatty log output into the debug level.
  • Introducing a new flag to the e2e-test script '--debug' which allows for easier testcase creation but leaves the log clean for normal runs.
  • Introduced a new flag to the e2e-test script '--clean'. Now the default behavior is to re-use already downloaded dependencies but in case one wants to enforce a re-download just use the flag.

Summary by CodeRabbit

  • New Features
    • Introduced new command-line options for cleaning up dependencies and enabling debug mode.
    • Added a flag for activating debug functionality in the test suite.
  • Improvements
    • Adjusted logging outputs to reduce routine verbosity while offering more detailed logs when debug mode is enabled.

Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

📝 Walkthrough

Walkthrough

This pull request introduces new command-line options and parameters to control functionality in the end-to-end testing workflow. The script is updated with --clean and --debug flags to manage dependency cleanup and enable debug logging. Additionally, several log statements across blockchain, bot, matrix, and partner plugin modules have been changed from Info (or Warn) to Debug level. The test suite now accepts a debug flag to adjust its logging configuration without altering the core test execution flow.

Changes

File(s) Change Summary
scripts/e2e.sh, tests/e2e/e2e_test.go, tests/e2e/tests/suite.go Added new CLI flags and parameters (--clean, --debug, and a debug parameter in NewSuite) to control dependency cleanup and debug mode in tests.
tests/e2e/blockchain/*, tests/e2e/bot/*, tests/e2e/matrix/*, tests/e2e/partner_plugin/* Updated logging statements from Info/Warn to Debug level across various components to reduce log verbosity.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant S as e2e.sh Script
    participant D as Dependency Directory
    participant T as Test Runner

    U->>S: Execute script with (--clean, --debug)
    S->>S: Parse options and set CLEAN & DEBUG flags
    alt CLEAN flag set
        S->>D: Check & remove existing dependency directory
    else
        S->>D: Verify if dependency directory exists
        Note right of S: Skip download/build if directory exists
    end
    S->>T: Assemble parameters (include debug flag if enabled)
    T-->>S: Execute end-to-end tests
Loading
sequenceDiagram
    participant F as Test Flag
    participant TS as NewSuite Function
    participant L as Logger

    F->>TS: Pass debug flag value
    TS->>L: Configure logging level (Debug if true, Info otherwise)
    L-->>TS: Logger initialized accordingly
    TS-->>F: Test suite ready
Loading

Suggested reviewers

  • evlekht

Poem

I'm a bunny in the codeyard, hopping with delight,
New flags and debug options make my world so bright.
With every log now whispered, not a shout in sight,
I nibble on these changes from morning till night.
May our tests run smoothly with a gentle debug light!
🐇💻🌟

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.62.2)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for "maunium.net/go/mautrix/id""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package : could not load export data: no export data for "maunium.net/go/mautrix/id""

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Noctunus Noctunus requested a review from evlekht February 24, 2025 13:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
scripts/e2e.sh (2)

31-38: Fix indentation consistency.

The flag handling section uses tabs while the rest of the file uses spaces. Maintain consistent indentation throughout the script.

-		--clean)
-			CLEAN=1
-			shift
-			;;
-		--debug)
-			DEBUG=1
-			shift
-			;;
+        --clean)
+            CLEAN=1
+            shift
+            ;;
+        --debug)
+            DEBUG=1
+            shift
+            ;;

183-186: Make array handling more robust.

The array initialization and usage could be more robust by ensuring it's always properly initialized, even when empty.

-ADD_PARAM=()
-if [ $DEBUG -eq 1 ] ; then
-	ADD_PARAM+=("-debug")
-fi
+# Initialize array with default empty value
+declare -a ADD_PARAM=()
+
+# Add debug flag if enabled
+if [ $DEBUG -eq 1 ] ; then
+    ADD_PARAM+=("-debug")
+fi
+
+# Ensure array is properly expanded even when empty
+if [ ${#ADD_PARAM[@]} -eq 0 ]; then
+    ADD_PARAM=("")
+fi
tests/e2e/blockchain/network.go (2)

60-60: LGTM! Log level changes align with PR objectives.

The changes appropriately move verbose operational logs to debug level, which helps reduce log clutter during normal runs while maintaining the ability to access detailed information when needed via the new --debug flag.

A few observations:

  • The changes are consistent across all methods (StartNewNetwork, startNewNode, Stop)
  • The log messages maintain their informative content
  • The modifications align with the PR's goal of streamlining logging output

Consider adding debug logs for additional operations that might be useful during troubleshooting:

  • Node configuration details
  • Genesis configuration summary
  • Network cleanup operations

Example addition:

 func (n *Network) startNewNode(...) (*Node, chan error, error) {
     n.logger.Debugf("Starting blockchain node %d (http port %d)...", nodeIndex, httpPort)
+    n.logger.Debugf("Node configuration: staking port %d, bootstrap IDs %s, bootstrap IPs %s",
+        stakingPort, bootstrapIDsArg, bootstrapIPsArg)

Also applies to: 183-183, 189-189, 195-195, 261-261, 313-313, 336-336


206-206: Consider moving UseExistingNetwork logs to debug level for consistency.

While StartNewNetwork and other methods have been updated to use debug level logging, UseExistingNetwork still uses info level. For consistency with the PR's objective of moving verbose output to debug level, consider updating these log statements as well.

-    logger.Info("Connecting to existing network...")
+    logger.Debug("Connecting to existing network...")

-    logger.Info("Preparing EVM admin...")
+    logger.Debug("Preparing EVM admin...")

-    logger.Info("Preparing CMB contracts...")
+    logger.Debug("Preparing CMB contracts...")

-    logger.Info("Blockchain network started")
+    logger.Debug("Blockchain network started")

Also applies to: 218-218, 224-224, 230-230

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef65df4 and 9479153.

📒 Files selected for processing (10)
  • scripts/e2e.sh (4 hunks)
  • tests/e2e/blockchain/network.go (5 hunks)
  • tests/e2e/blockchain/node.go (1 hunks)
  • tests/e2e/bot/bot.go (1 hunks)
  • tests/e2e/bot/factory.go (1 hunks)
  • tests/e2e/e2e_test.go (3 hunks)
  • tests/e2e/matrix/conduit.go (3 hunks)
  • tests/e2e/partner_plugin/factory.go (1 hunks)
  • tests/e2e/partner_plugin/partner_plugin.go (1 hunks)
  • tests/e2e/tests/suite.go (3 hunks)
✅ Files skipped from review due to trivial changes (5)
  • tests/e2e/partner_plugin/factory.go
  • tests/e2e/partner_plugin/partner_plugin.go
  • tests/e2e/blockchain/node.go
  • tests/e2e/bot/factory.go
  • tests/e2e/matrix/conduit.go
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Unit Tests
  • GitHub Check: Build docker image
  • GitHub Check: E2E Tests
  • GitHub Check: Static Analysis
🔇 Additional comments (5)
tests/e2e/bot/bot.go (1)

40-40: LGTM! Appropriate log level adjustment.

Moving the bot stop message to debug level is appropriate as it's non-critical status information.

tests/e2e/e2e_test.go (2)

32-33: LGTM! Well-structured debug flag implementation.

The debug flag is properly defined and integrated with appropriate default value and description.

Also applies to: 44-44, 56-56


96-106: LGTM! Proper debug flag propagation.

The debug flag is correctly passed to the NewSuite function, enabling configurable logging levels.

tests/e2e/tests/suite.go (2)

43-49: LGTM! Well-implemented logging configuration.

The zap logger configuration properly handles the debug flag, defaulting to InfoLevel and switching to DebugLevel when debug is enabled.


156-156: LGTM! Consistent log level adjustment.

Moving service status messages to debug level aligns with the PR's objective of reducing verbose output during normal operation.

Also applies to: 182-182

@Noctunus Noctunus merged commit 8c6b8e4 into dev Feb 24, 2025
7 checks passed
@Noctunus Noctunus deleted the evlekht/alex-e2e-logging branch February 24, 2025 14:05
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.

2 participants