This document shows how to test usage reporting for the SaaS products that you
offer through Google Cloud Marketplace.

## Before you begin

- To test usage reporting, your product's pricing plan must be approved by
  Google. For more details, see
  [Submit your pricing for review](https://docs.cloud.google.com/marketplace/docs/partners/integrated-saas/select-pricing.md.txt#submit-pricing).

  > [!NOTE]
  > **Note:** When you make a change to your product's approved pricing plans, it might take up to four business days for Google to approve the changes.

- Make sure that you use a Test Billing Account, which has 100% discounted
  usage. For steps to set up a Test Billing Account, see
  [Create a Test Billing Account](https://docs.cloud.google.com/marketplace/docs/partners/create-test-billing-account.md.txt).

- Verify that you've turned on Customer incremental insights reports. This
  involves the following steps:

  - [Set up to receive reports](https://docs.cloud.google.com/marketplace/docs/partners/reports/set-up-reports.md.txt).
  - [Turn on Customer incremental insights reports](https://docs.cloud.google.com/marketplace/docs/partners/reports/report-customer-insight.md.txt#turn-on-customer-incremental-insights).
  - For details on the report structure and fields, see [Customer incremental insights reports](https://docs.cloud.google.com/marketplace/docs/partners/reports/report-customer-insight.md.txt).

## Run a test to generate usage

You verify your usage reporting by running a test that generates usage reports,
and then comparing the usage reports to your expected outcomes. To run the test,
do the following:

1. In Producer Portal, switch to a Google Cloud project that's
   associated with your Test Billing Account.

2. From your product's Google Cloud Marketplace listing page, use your Test Billing
   Account to purchase the product.

3. Send an initial usage report for a single, recognizable metric. This should
   equal more than US$0.01, and be less than the amount of usage that you expect
   for one hour of usage. For example, if your product bills per GiB per hour,
   send a single usage report that's equivalent to one GiB per hour. This makes
   it easier to verify that metering and billing are working as expected when
   you compare against the Customer incremental insights report.

   For details about how to send usage reports, including how to format reports
   and usage times, see
   [Reporting usage to Google](https://docs.cloud.google.com/marketplace/docs/partners/integrated-saas/backend-integration.md.txt#for_usage-based_pricing_reporting_usage_to_google).
4. Continue to send at least one usage report per hour for at least six hours.
   If you send more than one usage report per hour, this doesn't affect the
   required minimum length of the test, which remains six hours.

5. For the duration of the testing period, create logs that contain the usage
   information that you're reporting in Google Sheets or CSV format, with the
   following format:

   | Time (UTC) | `operationID` | `startTime` | `endTime` | `consumerId` | `metricName` | `metricValue` |
   |---|---|---|---|---|---|---|
   | <var translate="no">TIME</var> | <var translate="no">OPERATION_ID</var> | <var translate="no">START_TIME</var> | <var translate="no">END_TIME</var> | project_number: <var translate="no">PROJECT_NUMBER</var> | <var translate="no">METRIC_NAME</var> | <var translate="no">METRIC_VALUE</var> |

   Provide these logs, in Google Sheets or CSV format, to your
   Cloud Marketplace partner engineering team.
6. After you receive the Customer incremental insights report corresponding to
   the time period during which you ran your tests, Google compares the values
   in your report with your expected values, including the following fields:

   - `charges`
   - `sku_id`
   - `sku_description`
   - `usage`
   - `unit`
   - `currency`
   - `external_account_id`

   Google sends you the results of their comparison.

## Clean up after testing

After Google receives and verifies your usage from the testing period, you clean
up the resources that you created for testing by doing the following:

- Stop sending usage reports for the entitlements that you created for testing.
- Cancel all entitlements that you created for testing.
- Remove any Google team members that you added to your Cloud Billing account during testing.

## Related topics

- [Preview your product in Producer Portal](https://docs.cloud.google.com/marketplace/docs/partners/integrated-saas/test-preview.md.txt), to see how it appears to Cloud Marketplace users.
- [Preview your product's pricing](https://docs.cloud.google.com/marketplace/docs/partners/integrated-saas/test-preview-pricing.md.txt).