koku icon indicating copy to clipboard operation
koku copied to clipboard

[COST-5093] Update mapped tags in EC2 summary table

Open djnakabaale opened this issue 1 year ago • 2 comments

Jira Ticket

COST-5093

Description

This change will update mapped tags for EC2 summary table by leveraging the existing update functionality for the aws daily summary table.

Testing

  1. Checkout Branch

  2. Load test data

    make create-test-customer ; make load-test-customer-data test_source=aws
    
  3. Create tag mappings with a PUT request to this endpoint and requires knowing tag uuids.

     http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/child/add/. 
    
    Example
     curl --location --request PUT 'http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/child/add/' \
     --header 'Content-Type: application/json' \
     --data '{
         "parent":  "ab1994b9-3b0f-441d-93ee-b731fd1956cf",
         "children": [
             "9c7ce1a3-3713-4657-a838-a471c77e049d",
             "db4df347-0924-4142-9786-0f3ed929446c",
             "9944e8b8-5e36-48f8-b9d8-ab06b18d3899",
             "c39ef51b-d459-41b3-b776-302f2836361a",
             "51e62c05-ee8c-47e0-a25b-e6edb7eb79cc",
             "92016af6-00b5-4c1c-86cb-4abbcec736c0",
             "66df0282-9c21-4674-9aed-f973cd536c6e",
             "31079e66-0885-4ebb-9b91-1ce4430f0b4d",
             "6ec4cdd2-b65b-4e7b-92bd-6603af2ed825",
             "93c60f52-ce91-4b0f-a381-85b5bd536353",
             "348285ae-f7a8-4ab3-b84f-9b67aaa55e32"
         ]
     }'
    
  4. Check these endpoints to

    • see the parent mapped tags, http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/parent/?source_type=AWS

        {
            "meta": {
                "count": 1,
                "limit": 1,
                "offset": 0
            },
            "links": {
                "first": "/api/cost-management/v1/settings/tags/mappings/parent/?limit=1&offset=0&source_type=AWS",
                "next": null,
                "previous": null,
                "last": "/api/cost-management/v1/settings/tags/mappings/parent/?limit=1&offset=0&source_type=AWS"
            },
            "data": [
                {
                    "uuid": "ab1994b9-3b0f-441d-93ee-b731fd1956cf",
                    "key": "Name",
                    "source_type": "AWS",
                    "cost_model_id": null
                }
            ]
        }
      
    • see mapped child tags, http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/child/

        {
            "meta": {
                "count": 2,
                "limit": 2,
                "offset": 0
            },
            "links": {
                "first": "/api/cost-management/v1/settings/tags/mappings/child/?limit=6&offset=0",
                "next": null,
                "previous": null,
                "last": "/api/cost-management/v1/settings/tags/mappings/child/?limit=6&offset=0"
            },
            "data": [
                {
                    "uuid": "3a56a865-8c2f-4649-8947-4e909464989f",
                    "key": "app",
                    "source_type": "OCP",
                    "cost_model_id": null
                },
                {
                    "uuid": "bfbb6b8a-9197-4d77-ab00-9b9bc8c177aa",
                    "key": "application",
                    "source_type": "OCP",
                    "cost_model_id": null
                }
            ]
        }
      
  5. Trigger a re-summary for the AWS source

  6. Then in the postgres shell, check to see that tags are updated in the EC2 table

    postgres=# select uuid, tags from reporting_awscostentrylineitem_summary_by_ec2_compute where tags ?| ARRAY['app', 'application'];
    (0 rows)
    
    postgres=# 
    
    

djnakabaale avatar Jun 05 '24 15:06 djnakabaale

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.1%. Comparing base (31f7de6) to head (4c167f9).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #5147   +/-   ##
=====================================
  Coverage   94.1%   94.1%           
=====================================
  Files        371     371           
  Lines      30927   30929    +2     
  Branches    4542    4542           
=====================================
+ Hits       29103   29105    +2     
  Misses      1163    1163           
  Partials     661     661           

codecov[bot] avatar Jun 05 '24 16:06 codecov[bot]

/retest

djnakabaale avatar Jun 06 '24 00:06 djnakabaale