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

Recording components logs and generate component yaml for smoke tests framework #5333

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zelinh
Copy link
Member

@zelinh zelinh commented Feb 20, 2025

Description

Recording components logs and generate component yaml for smoke tests framework

Issues Resolved

Part of #5320

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Zelin Hao <zelinhao@amazon.com>
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.07%. Comparing base (95f1b58) to head (b101065).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5333      +/-   ##
==========================================
+ Coverage   92.04%   92.07%   +0.03%     
==========================================
  Files         202      202              
  Lines        7042     7069      +27     
==========================================
+ Hits         6482     6509      +27     
  Misses        560      560              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -64,6 +67,31 @@ def validate_response_swagger(self, response: Any) -> None:
validate_response(response=response, spec=self.spec_, request=request)
logging.info("Response is validated.")

def record_test_result(self, component: str, test_api: str, api_action: str, stdout: str, stderr: str) -> None:
test_config = f"{api_action}_{test_api.replace('/', '_')}"
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what the actual line would be?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, test results folder will be looked like this:

-- test_results
  -- smoke_tests
       -- local_cluster_logs
            -- stdout.txt
            -- stderr.txt
       -- security 
            -- GET___plugins__security_api_account
                -- stdout.txt
                -- stderr.txt
                -- security.yml
            -- PUT___plugins__security_api_actiongroups_my-action-group
                -- stdout.txt
                -- stderr.txt
                -- security.yml
            -- POST_...
       -- ...
       -- ...

Copy link
Member

Choose a reason for hiding this comment

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

Do we really need stdout and stderr for each API? Feels like too many files for just a single API response.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the API test passes, the stderr will be empty and stdout will display all logging for this specific API path. There will be just two std files and a component yml file generated for each API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Each of the component yaml file(e.g. security.yml) will contain specific test results so I believe it's better to have them separately. WDYT @rishabh6788

Comment on lines +76 to +89
def setup_logging_buffers(self) -> Tuple[io.StringIO, io.StringIO, logging.StreamHandler, logging.StreamHandler]:
info_buffer = io.StringIO()
error_buffer = io.StringIO()

info_handler = logging.StreamHandler(info_buffer)
error_handler = logging.StreamHandler(error_buffer)

info_handler.setLevel(logging.INFO)
error_handler.setLevel(logging.ERROR)

logging.getLogger().addHandler(info_handler)
logging.getLogger().addHandler(error_handler)

return info_buffer, error_buffer, info_handler, error_handler
Copy link
Member

Choose a reason for hiding this comment

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

What values are re getting from this?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is to use log buffer and handler to record logging information in order to generate a output file.

@@ -64,6 +67,31 @@ def validate_response_swagger(self, response: Any) -> None:
validate_response(response=response, spec=self.spec_, request=request)
logging.info("Response is validated.")

def record_test_result(self, component: str, test_api: str, api_action: str, stdout: str, stderr: str) -> None:
test_config = f"{api_action}_{test_api.replace('/', '_')}"
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need stdout and stderr for each API? Feels like too many files for just a single API response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants