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

[AAP-39884] - Improve code coverage and fix some minor issues in analytics collection #1207

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

hsong-rh
Copy link
Contributor

@hsong-rh hsong-rh commented Feb 6, 2025

https://issues.redhat.com/browse/AAP-39884

This PR covers:

  1. Add more Pytest cases to improve code coverage for analytics collection
  2. Fix errors when the audit_rule table is empty
Traceback (most recent call last):
  File "/home/runner/.cache/pypoetry/virtualenvs/aap-eda-mUpJWeoH-py3.11/lib/python3.11/site-packages/insights_analytics_collector/collection.py", line 59, in gather
    result = self.fnc_collecting(
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/eda-server/eda-server/src/aap_eda/analytics/analytics_collectors.py", line 289, in audit_rules_table
    audit_rules = _get_audit_rule_qs(since, until).values(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/pypoetry/virtualenvs/aap-eda-mUpJWeoH-py3.11/lib/python3.11/site-packages/django/db/models/query.py", line 1313, in values
    clone = self._values(*fields, **expressions)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/pypoetry/virtualenvs/aap-eda-mUpJWeoH-py3.11/lib/python3.11/site-packages/django/db/models/query.py", line 1308, in _values
    clone.query.set_values(fields)
  File "/home/runner/.cache/pypoetry/virtualenvs/aap-eda-mUpJWeoH-py3.11/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2463, in set_values
    self.add_fields(field_names, True)
  File "/home/runner/.cache/pypoetry/virtualenvs/aap-eda-mUpJWeoH-py3.11/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2195, in add_fields
    raise FieldError(
django.core.exceptions.FieldError: Cannot resolve keyword 'created_at' into field. Choices are: activation, activation_id, activation_pod_id, activationinstancejobinstance, auditrule, ended_at, git_hash, id, log_read_at, name, organization, organization_id, parent_type, rulebookprocesslog, rulebookprocessqueue, started_at, status, status_message, updated_at
  1. Fix the previous two failed Pytest cases:
FAILED tests/integration/analytics/test_gather_analytics.py::test_gather_analytics_invalid_settings[https://url-True-Analytics collection is done] - requests.exceptions.ConnectionError: HTTPSConnectionPool(host='url', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9acaca9950>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
FAILED tests/integration/analytics/test_gather_analytics.py::test_gather_analytics_command[--ship-INFO-Analytics collection is done] - requests.exceptions.ConnectionError: HTTPSConnectionPool(host='url', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9acb3f0a90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
====== 2 failed, 922 passed, 24 skipped, 15 warnings in 391.17s (0:06:31) ======

@hsong-rh hsong-rh requested a review from a team as a code owner February 6, 2025 20:46
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (feature/analytics@58ce34c). Learn more about missing BASE report.

@@                 Coverage Diff                  @@
##             feature/analytics    #1207   +/-   ##
====================================================
  Coverage                     ?   93.77%           
====================================================
  Files                        ?      282           
  Lines                        ?    16522           
  Branches                     ?        0           
====================================================
  Hits                         ?    15494           
  Misses                       ?     1028           
  Partials                     ?        0           
Flag Coverage Δ
unit-int-tests-3.11 93.71% <100.00%> (?)
unit-int-tests-3.12 93.77% <100.00%> (?)

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

Files with missing lines Coverage Δ
src/aap_eda/analytics/analytics_collectors.py 97.58% <100.00%> (ø)
src/aap_eda/analytics/collector.py 100.00% <100.00%> (ø)
src/aap_eda/analytics/package.py 100.00% <100.00%> (ø)
src/aap_eda/analytics/utils.py 100.00% <100.00%> (ø)
src/aap_eda/settings/default.py 89.30% <100.00%> (ø)
...integration/analytics/test_analytics_collectors.py 100.00% <100.00%> (ø)
tests/integration/analytics/test_collector.py 100.00% <100.00%> (ø)
...sts/integration/analytics/test_gather_analytics.py 100.00% <100.00%> (ø)
tests/integration/analytics/test_package.py 100.00% <100.00%> (ø)
tests/integration/analytics/test_utils.py 100.00% <100.00%> (ø)

@hsong-rh hsong-rh force-pushed the fix_controller_info branch 2 times, most recently from 709cc76 to a870f7d Compare February 7, 2025 16:03
@Alex-Izquierdo
Copy link
Collaborator

It would be good to have some description in the PR

@hsong-rh
Copy link
Contributor Author

hsong-rh commented Feb 7, 2025

e2e failed because the eda-qa API client is out of date here

@hsong-rh hsong-rh force-pushed the fix_controller_info branch 3 times, most recently from d96da1b to 7377ae7 Compare February 10, 2025 14:16
@hsong-rh hsong-rh force-pushed the fix_controller_info branch from 7377ae7 to 5a84223 Compare February 10, 2025 15:30
Alex-Izquierdo
Alex-Izquierdo previously approved these changes Feb 10, 2025
Alex-Izquierdo
Alex-Izquierdo previously approved these changes Feb 10, 2025
Alex-Izquierdo
Alex-Izquierdo previously approved these changes Feb 10, 2025
@hsong-rh hsong-rh merged commit f71b9f8 into ansible:feature/analytics Feb 13, 2025
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants