Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-3239

New Billable Usage API to perform hourly aggregation

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • swatch-billable-usage
    • None

      The workflow would look like as:

      1. Get remittances with status pending in batches ordered by the "BillableUsageAggregateKey" class and remittance_pending_date and filter out the records older than a concrete amount of time defined in configuration.
      2. If the usage has billing provider Red Hat
        1. Update the usage to status “In Progress” and updated_at to now()
        2. Transform the usage entity to the usage message
        3. Send the usage message to the platform.rhsm-subscriptions.billable-usage topic
        4. If the above transaction fails, update the records to "Pending" status
        5. If the above transaction works, update the records to “Sent” status.
      3. If the usage has billing provider AWS or Azure
        1. Aggregate the usage into the hourly aggregate message
        2. Send aggregations to the “platform.rhsm-subscriptions.billable-usage-hourly-aggregate” topic
        3. If the above transaction fails, update the records to "Pending" status
        4. If the above transaction works, update the records to “Sent” status.

      Changes

      • Add a new configuration property in the billable usage service to limit how long time we will query the usages (default value is 7 days?). So, pending usages older than 7 days will not be reprocessed.

      New Tests to add

      Given existing pending remittance entities for all the billing providers, 
      When the running hourly aggregation
      And the existing pending remittance change to “In Progress” status
      And the billable usage service is shutdown before sending the aggregation to the topic
      Then after running the daily clean up process, these entities are in “Pending” status
      
      Given existing pending remittance entities, 
      When the running hourly aggregation
      And the existing pending remittance change to “In Progress” status
      And the billable usage service is shutdown after sending the aggregation to the topic
      And the SWATCH producers handle the sent aggregation and send a message to update the status
      Then after running the daily clean up process, these entities are NOT in “Pending” status
      
      Given existing pending remittance entities, 
      When the running hourly aggregation
      And the existing pending remittance change to “Sent” status
      And the SWATCH producers do not handle the sent aggregation
      Then after running the daily clean up process, these entities are in “Unknown” status
      
      Given existing In Progress remittance with value “2”
      And pending remittance for the same key with value “4”
      When running the hourly aggregation
      Then only the remittance for the same key with value “4” is processed
      
      Given existing In Progress remittance with value “2”
      And pending remittance for the same key with value “4”
      And the daily clean up process updates the status from “In Progress” to “pending”
      When running the hourly aggregation
      Then aggregated remittance has value “4”
      

              Unassigned Unassigned
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: