Skip to content

Files

Latest commit

Jun 19, 2025
2d2675a · Jun 19, 2025

History

History
86 lines (61 loc) · 3.38 KB
·

File metadata and controls

86 lines (61 loc) · 3.38 KB
·

Addon Testing Framework

The testaddons package provides a comprehensive framework for testing IBM Cloud add-ons in IBM Cloud Projects. This framework automates the complete lifecycle of addon testing, from catalog setup to deployment validation and cleanup.

Quick Start

For most addon testing scenarios, you'll want to use the standard Terraform addon approach:

package test

import (
    "testing"
    "github.com/stretchr/testify/assert"
    "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
    "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons"
)

func TestBasicAddon(t *testing.T) {
    t.Parallel()

    options := testaddons.TestAddonsOptionsDefault(&testaddons.TestAddonOptions{
        Testing:       t,
        Prefix:        "test-addon",
        ResourceGroup: "my-project-rg",
    })

    options.AddonConfig = cloudinfo.NewAddonConfigTerraform(
        options.Prefix,        // prefix for unique resource naming
        "my-addon",           // offering name
        "standard",           // offering flavor
        map[string]interface{}{ // inputs
            "prefix": options.Prefix,
            "region": "us-south",
        },
    )

    err := options.RunAddonTest()
    assert.NoError(t, err, "Addon Test had an unexpected error")
}

Documentation Structure

The addon testing documentation is organized into the following focused guides:

Key Features

  • Automated Lifecycle Management: Handles catalog creation, offering import, project setup, deployment, and cleanup
  • Built-in Validations: Reference validation, dependency validation, and local change checks
  • Parallel Testing Support: Run multiple test configurations simultaneously with matrix testing
  • Flexible Hooks: Inject custom code at key points in the testing process
  • Comprehensive Logging: Detailed logging throughout the testing process
  • Dependency Management: Automatic dependency discovery and validation

Core Concepts

Test Options

The TestAddonOptions structure is the primary configuration object that controls all aspects of your addon test.

Addon Configuration

The AddonConfig structure defines what addon to test, which flavor to use, and what inputs to provide.

Dependencies

The framework automatically handles addon dependencies, deploying required dependencies and validating their configuration.

Hooks

Hook functions allow you to inject custom code at specific points in the testing lifecycle for validation, configuration, or cleanup.

Next Steps