Skip to content

scramjetorg/billing-tests

Repository files navigation

Scramjet Cloud Platform - standalone billing module tests

About the Billing test suite

Note: curretly this test verifies standalone KillBill module deployed on Kubernetes cluster. Test is based on the assumption that we collect and measure usage of gigabyteseconds consumed by customer's instances and we calculate account balance per billing period based on fixed price per each gigabytesecond.

For now, all the functions in this simple billing cycle are simulated by the test suite by sending REST API calls to the KillBill API. In the next step, these simulated behaviours should be replaced by actual integrations with the Scramjet Cloud Platform backend and GUI.

References

KillBill - REST API reference

KillBill - Using Postman

KillBill - Subscription Billing

KilBill - Swagger Schema

KillBill Catalog XSD

Related Scramjet Projects

For KillBill deployment on k8s, please check this k8s-charts directory

Configuration for the test environment

Test uses env-cmd node package. You can pass environment variables from this .env or set them on command line while running billing test, for example ADMIN_USERNAME=superadmin yarn test:bdd --name="BILL-001"

Example .env file is provided as .env.sample file

# Based on this file you can create your own .env file placed in the root directory of this project
# Endpoint of the KillBill REST API Service
BILLING_ENDPOINT=http://<IP address/URL>:<Port>
# API Key set for the KillBill tenant
API_KEY=<Value from KillBill Tenant settings>
# API Secret set for the KillBill tenant
API_SECRET=<Value from KillBill Tenant settings>
# Admin username set for the KillBill tenant
ADMIN_USERNAME=<Value from KillBill Tenant>
# Admin password set for the KillBill tenant
ADMIN_PASSWORD=<Value from KillBill Tenant>

Running the test

In order to run this test, you need to execute the foloing steps:

  1. Clone this repository
  2. Ensure you have KillBill:
  • deployed on k8s (either locally or on Scramjet remote cluster)
  • that it has configured tenant with API key and API secret
  • that you can access its REST API endpoint from test machine
  1. Ensure you have access credentials to KillBill:
  • Priviledged user credentials (user that can execute API request, such as tenant admin) - username and password
  • Tenat's API key and API secret
  1. Configure environment variables in .env file (check .env.sample for help) or set them them during calling yarn test:bdd (for example ADMIN_USERNAME=admin yarn test:bdd --name="BILL-001"])
  2. Build the project yarn clean && yarn install && yarn build:all
  3. Run the project yarn test:bdd --name="BILL-001"
  4. Check the ./bdd/reports for report result

Configuration

Test is using simplified KillBill catalog configuration represented by config/catalog.xml file. This is purely test configuration, not intended to be used directly on production. It defines:

  • simple BASIC_PLAN with daily billing period
  • usage unit named gigabytesecond
  • fixed USD price for one gigabytesecond

This simple catalog file is uploaded to KillBill tenant for every test case. In case such catalog exists already, it is overwritten with the same file. This way, no additional manual configuration is requied for the test. In case of changes required in the catalog, one can validate config/catalog.xml file with config/catalog.xsd file provided by KillBill.

Tests in scope

Test project currently executes two scenarios:

  1. BILL-001 TC-001 Billing test gigabyteseconds simple usage
Given billing module is available
        When product catalog is uploaded to the billing tenant
        When new customer account for company "ACME" is registered
        Then customer account Id is retrieved by external key
        When SCP subscription is created for customer account
        Then subscription Id is retrieved by external key
        When instances gigabyteseconds usage is registered
        Then trigger dry run invoice generation and check balance amount
        Then trigger actual invoice generation
  1. BILL-001 TC-002 Billing test gigabyteseconds usage with credit from voucher
Given billing module is available
        When product catalog is uploaded to the billing tenant
        Then new customer account for company "COMPANY2" is registered
        Then customer account Id is retrieved by external key
        When SCP subscription is created for customer account
        Then subscription Id is retrieved by external key
        When voucher "VX32423" credit amount 100.00 is added to the customer account
        When instances gigabyteseconds usage is registered
        Then trigger dry run invoice generation and check balance amount
        Then trigger actual invoice generation

Sample test result

Example test result can be found below: Sample billing test report

About

SCP-3200

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages