Skip to content

Conversation

TenSt
Copy link
Contributor

@TenSt TenSt commented Oct 15, 2025

Description

This PR:

  • updates the getTableSizes function to gather data about tables from all used schemas, not just public
  • updates tests
  • updates readme on how to run single or a set of tests in containers (vs. local)

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Fix table size collection to include all schemas, update tests to reflect schema-qualified table names, and improve test-run documentation.

Bug Fixes:

  • Fix getTableSizes to fetch table sizes from public, inventory, and repack schemas with schema-qualified keys.

Documentation:

  • Update README and go_test.sh with instructions for running individual tests or test sets in containers and locally.

Tests:

  • Adjust metrics_db_test to expect schema-qualified table names and include inventory schema tables.

Copy link

jira-linking bot commented Oct 15, 2025

Referenced Jiras:
https://issues.redhat.com/browse/RHINENG-16453

Copy link

sourcery-ai bot commented Oct 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR enhances table size gathering by fully qualifying table names across multiple schemas, updates corresponding tests for the new key format, and refines the README and test script to simplify running individual tests in containers or locally.

ER diagram for table size gathering across multiple schemas

erDiagram
    PG_TABLES {
        string schemaname
        string tablename
    }
    TABLE_SIZES {
        string key
        int value
    }
    PG_TABLES ||--o| TABLE_SIZES : "generates size for"
Loading

Class diagram for updated getTableSizes function and keyValue usage

classDiagram
    class keyValue {
        +string key
        +int value
    }
    class metrics_db {
        +getTableSizes() []keyValue
    }
    metrics_db --> keyValue: returns
Loading

File-Level Changes

Change Details Files
Expand table size query to cover all relevant schemas and qualify table names
  • Changed SQL select to concat schemaname and tablename as key
  • Updated pg_total_relation_size call to use schema-qualified names
  • Adjusted schema filter to include public, inventory, and repack
tasks/vmaas_sync/metrics_db.go
Adapt tests to validate schema-qualified table size keys
  • Prefixed expected table keys with schema
  • Added assertion for an inventory schema table
  • Retained length checks for consistency
tasks/vmaas_sync/metrics_db_test.go
Enhance documentation and scripts for running targeted tests
  • Added instructions in README for single-test execution in containers and locally
  • Modified go_test.sh to include commented example for running one test
  • Preserved existing all-tests execution command
README.md
scripts/go_test.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider dynamically determining which schemas to include (e.g. exclude system schemas) instead of hardcoding public, inventory, and repack.
  • Use quote_ident on both schemaname and tablename when building the identifier in pg_total_relation_size to avoid any edge cases with special characters.
  • Add an assertion in TestTableSizes to verify that tables from the repack schema are included, similar to the inventory.hosts_v1_0 check.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider dynamically determining which schemas to include (e.g. exclude system schemas) instead of hardcoding public, inventory, and repack.
- Use quote_ident on both schemaname and tablename when building the identifier in pg_total_relation_size to avoid any edge cases with special characters.
- Add an assertion in TestTableSizes to verify that tables from the repack schema are included, similar to the inventory.hosts_v1_0 check.

## Individual Comments

### Comment 1
<location> `README.md:68` </location>
<code_context>
+- Run the same command as for running all tests (from above)
+
+### Run single test locally
 After running all test suit, testing platform components are still running (kafka, platform, db). This is especially useful when fixing some test or adding a new one. You need to have golang installed.
 ~~~bash
 podman-compose -f docker-compose.test.yml up --build --no-start # build images
</code_context>

<issue_to_address>
**issue (typo):** Typo: 'test suit' should be 'test suite'.

Please update the wording to 'test suite'.

```suggestion
After running all test suite, testing platform components are still running (kafka, platform, db). This is especially useful when fixing some test or adding a new one. You need to have golang installed.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@app-sre-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@TenSt TenSt changed the title fix(metrics): gather table sizes from all used schemas, not only public RHINENG-16453: gather table sizes from all used schemas, not only public Oct 17, 2025
@TenSt TenSt force-pushed the stepan/RHINENG-16453-get-table-sizes-from-all-used-schemas branch from e49c695 to 5121e93 Compare October 17, 2025 12:59
@MichaelMraka
Copy link
Collaborator

/ok-to-test

@TenSt TenSt force-pushed the stepan/RHINENG-16453-get-table-sizes-from-all-used-schemas branch from 5121e93 to e7745c5 Compare October 20, 2025 08:42
@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.58%. Comparing base (29c09c3) to head (33973ec).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1883   +/-   ##
=======================================
  Coverage   57.58%   57.58%           
=======================================
  Files         131      131           
  Lines       10197    10198    +1     
=======================================
+ Hits         5872     5873    +1     
  Misses       3791     3791           
  Partials      534      534           
Flag Coverage Δ
unittests 57.58% <100.00%> (+<0.01%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelMraka
Copy link
Collaborator

/ok-to-test

@MichaelMraka
Copy link
Collaborator

/retest

@TenSt TenSt force-pushed the stepan/RHINENG-16453-get-table-sizes-from-all-used-schemas branch from 420a34a to 33973ec Compare October 21, 2025 13:23
@TenSt TenSt merged commit be14ab9 into RedHatInsights:master Oct 21, 2025
7 of 8 checks passed
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.

4 participants