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

chore: refactor e2e tests to have a common suite for all tests #554

Merged

Conversation

mojtaba-esk
Copy link
Contributor

@mojtaba-esk mojtaba-esk commented Aug 28, 2024

Closes #552

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive end-to-end testing suite for the Knuu framework, including enhanced methods for creating Nginx instances and improved resource management.
    • Added public methods for creating Nginx instances and centralized path definitions for HTML resources, improving maintainability.
  • Refactor

    • Simplified the test suite structure by eliminating redundant fields and methods, focusing on leveraging the e2e.Suite functionality.
  • Bug Fixes

    • Updated method names and references to enhance clarity and ensure consistent access across the testing suite.

@mojtaba-esk mojtaba-esk added this to the v0.16.0 milestone Aug 28, 2024
@mojtaba-esk mojtaba-esk requested a review from a team August 28, 2024 13:50
@mojtaba-esk mojtaba-esk self-assigned this Aug 28, 2024
Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Walkthrough

The changes encompass modifications to the test suite structure across multiple files in the e2e package, primarily focusing on refactoring the Suite struct, enhancing method visibility, and centralizing resource management. Key alterations include changing method names from lowercase to uppercase for public access, removing redundant fields and methods, and utilizing constants for paths and port numbers to improve maintainability and clarity.

Changes

Files Change Summary
e2e/basic/probe_test.go, e2e/basic/reverse_proxy_test.go, e2e/basic/suite_setup_test.go Renamed methods to public, updated resource paths and port usage to constants from the e2e package.
e2e/netshaper/suite_setup_test.go Refactored Suite struct to extend from e2e.Suite, removed fields and methods for a streamlined structure.
e2e/suite.go Introduced a new comprehensive Suite struct for managing test lifecycle, including instance creation methods.
e2e/system/*.go Updated method calls to public, replaced hardcoded paths with constants from the e2e package.

Assessment against linked issues

Objective Addressed Explanation
Use the Suite struct to just be in the e2e package (552)
Simplify test setup by removing redundant methods (552)
Centralize resource management for better maintainability (552)

Poem

🐇 In the land of code where bunnies play,
Changes hop along, brightening the day.
Public methods leap, paths now align,
E2E's embrace makes our tests divine!
With every refactor, our joy will swell,
In this tidy haven, all works quite well! 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@celestia-bot celestia-bot requested a review from MSevey August 28, 2024 13:50
@mojtaba-esk mojtaba-esk enabled auto-merge (squash) August 28, 2024 13:51
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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fbf0fb1 and 2984ff3.

Files selected for processing (15)
  • e2e/basic/probe_test.go (2 hunks)
  • e2e/basic/reverse_proxy_test.go (3 hunks)
  • e2e/basic/suite_setup_test.go (3 hunks)
  • e2e/netshaper/suite_setup_test.go (2 hunks)
  • e2e/suite.go (1 hunks)
  • e2e/system/build_from_git_test.go (1 hunks)
  • e2e/system/env_to_json_test.go (3 hunks)
  • e2e/system/external_file_test.go (3 hunks)
  • e2e/system/file_test.go (2 hunks)
  • e2e/system/file_test_image_cached_test.go (4 hunks)
  • e2e/system/files_to_volumes_cm_test.go (9 hunks)
  • e2e/system/folder_test.go (2 hunks)
  • e2e/system/folder_test_image_cached_test.go (3 hunks)
  • e2e/system/start_callback_test.go (2 hunks)
  • e2e/system/suite_setup_test.go (3 hunks)
Additional comments not posted (50)
e2e/netshaper/suite_setup_test.go (1)

14-14: LGTM!

The Suite struct now extends e2e.Suite, which aligns with the objective of centralizing the Suite struct within the e2e package.

The code changes are approved.

e2e/system/folder_test.go (1)

19-20: LGTM!

The function now uses CreateNginxInstanceWithVolume and e2e.NginxHTMLPath, which improves the visibility and maintainability of the code.

The code changes are approved.

e2e/basic/suite_setup_test.go (1)

25-25: LGTM!

The Suite struct now extends e2e.Suite, which aligns with the objective of centralizing the Suite struct within the e2e package.

The code changes are approved.

e2e/system/suite_setup_test.go (1)

25-25: LGTM!

The Suite struct has been simplified by embedding e2e.Suite, which enhances maintainability and readability.

The code changes are approved.

e2e/basic/probe_test.go (3)

21-21: LGTM!

The method createNginxInstanceWithVolume has been renamed to CreateNginxInstanceWithVolume, making it public and enhancing its accessibility.

The code changes are approved.


23-23: LGTM!

The path for the HTML resource file is updated to use e2e.NginxHTMLPath, enhancing modularity and maintainability.

The code changes are approved.


30-30: LGTM!

The port number for the HTTP probe is now sourced from e2e.NginxPort, reinforcing the use of constants defined in the e2e package and improving maintainability and clarity.

The code changes are approved.

e2e/system/external_file_test.go (2)

20-20: LGTM!

The method createNginxInstance has been renamed to CreateNginxInstance, making it public and enhancing its accessibility.

The code changes are approved.


40-40: LGTM!

The path used in the AddFile method of the server's storage is modified to use e2e.NginxHTMLPath, enhancing modularity and maintainability.

The code changes are approved.

e2e/system/folder_test_image_cached_test.go (3)

8-8: LGTM!

The import statement correctly adds the e2e package, which is necessary for the new references.

The code changes are approved.


26-26: LGTM!

The function correctly uses the public method CreateNginxInstanceWithVolume.

The code changes are approved.


35-35: LGTM!

The path reference e2e.NginxHTMLPath improves maintainability and readability.

The code changes are approved.

e2e/system/start_callback_test.go (4)

9-10: LGTM!

The import statement correctly adds the e2e package, which is necessary for the new references.

The code changes are approved.


22-22: LGTM!

The function correctly uses the public method CreateNginxInstance.

The code changes are approved.


30-30: LGTM!

The port number reference e2e.NginxPort improves maintainability and readability.

The code changes are approved.


36-36: LGTM!

The start command reference e2e.NginxCommand improves maintainability and readability.

The code changes are approved.

e2e/system/env_to_json_test.go (4)

9-9: LGTM!

The import statement correctly adds the e2e package, which is necessary for the new references.

The code changes are approved.


41-41: LGTM!

The function correctly uses the public method CreateNginxInstance.

The code changes are approved.


45-45: LGTM!

The path reference e2e.NginxHTMLPath improves maintainability and readability.

The code changes are approved.


57-57: LGTM!

The path reference e2e.NginxHTMLPath improves maintainability and readability.

The code changes are approved.

e2e/system/file_test_image_cached_test.go (3)

32-32: Change method visibility to public

The method createNginxInstanceWithVolume is now CreateNginxInstanceWithVolume. This change makes the method public, allowing it to be accessed outside its original package.

The code changes are approved.


40-41: Change method visibility to public

The method retryOperation is now RetryOperation. This change makes the method public, allowing it to be accessed outside its original package.

The code changes are approved.


41-41: Use constants for maintainability

The hardcoded string has been replaced with the constant e2e.NginxHTMLPath. This change improves code maintainability by centralizing the path definition.

The code changes are approved.

e2e/system/build_from_git_test.go (1)

68-68: Change method visibility to public

The method retryOperation is now RetryOperation. This change makes the method public, allowing it to be accessed outside its original package.

The code changes are approved.

e2e/basic/reverse_proxy_test.go (2)

51-51: Change method visibility to public

The method createNginxInstance is now CreateNginxInstance. This change makes the method public, allowing it to be accessed outside its original package.

The code changes are approved.


79-79: Use constants for maintainability

The hardcoded port has been replaced with the constant e2e.NginxPort. This change improves code maintainability by centralizing the port configuration.

The code changes are approved.

e2e/suite.go (9)

17-20: LGTM!

The constants are correctly defined and improve maintainability by centralizing the path and port definitions.

The code changes are approved.


22-24: LGTM!

The constants are correctly defined and improve maintainability by centralizing the image and volume owner definitions.

The code changes are approved.


26-34: LGTM!

The Suite struct is correctly defined and includes necessary fields for managing the test suite.

The code changes are approved.


40-44: LGTM!

The SetupTest function is correctly implemented.

The code changes are approved.


46-56: LGTM!

The TearDownTest function is correctly implemented and ensures proper cleanup after the last test.

The code changes are approved.


58-64: LGTM!

The cleanupSuite function is correctly implemented and handles errors during the cleanup process.

The code changes are approved.


66-72: LGTM!

The CreateNginxInstance function is correctly implemented and handles instance creation, image setting, and port addition.

The code changes are approved.


75-82: LGTM!

The CreateNginxInstanceWithVolume function is correctly implemented and handles instance creation, directory addition, and volume addition.

The code changes are approved.


85-94: LGTM!

The RetryOperation function is correctly implemented and handles retry logic with exponential backoff.

The code changes are approved.

e2e/system/file_test.go (5)

29-33: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


38-38: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


46-46: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


54-54: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


61-61: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.

e2e/system/files_to_volumes_cm_test.go (10)

26-26: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


54-54: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


92-92: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


104-104: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


148-148: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


157-157: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


201-201: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


209-210: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


214-214: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.


227-227: LGTM!

The changes to use public methods and centralized path constants improve maintainability and consistency.

The code changes are approved.

e2e/netshaper/suite_setup_test.go Show resolved Hide resolved
e2e/basic/suite_setup_test.go Show resolved Hide resolved
Copy link
Member

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

LGTM, if my understanding of my comment is correct just resolve so you can merge.

@mojtaba-esk mojtaba-esk disabled auto-merge August 29, 2024 14:57
@mojtaba-esk mojtaba-esk merged commit 6eb685d into main Aug 29, 2024
18 checks passed
@mojtaba-esk mojtaba-esk deleted the mojtaba/552-a-common-suite-to-be-used-by-all-tests branch August 29, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Use the Suite struct to just be in the e2e package
2 participants