integration

package
v0.0.0-...-96a11e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

README

Integration Testing Strategy

This directory will contain integration tests for the Go API implementation. These tests will focus on complete workflows rather than individual endpoint behavior.

Planned Structure

integration/
├── flows/           # Test flows organized by feature/domain
│   ├── apis/        # API-related workflows 
│   ├── keys/        # Key-related workflows
│   ├── identities/  # Identity-related workflows
│   └── permissions/ # Permission-related workflows
├── fixtures/        # Shared test data
├── helpers/         # Shared test utilities
└── setup/           # Test environment setup

Implementation TODO

  • Create a shared TestEnvironment that sets up databases, services, and HTTP server
  • Build a TestClient wrapper for making HTTP requests to test endpoints
  • Implement test suites using testify/suite for consistent setup/teardown
  • Add build tags to control when integration tests run (//go:build integration)
  • Create Makefile targets for running integration tests separately from unit tests
  • Configure CI pipeline to run integration tests on main branch or when explicitly requested

Design Principles

  1. Tests should focus on complete user workflows rather than individual endpoints
  2. Use real HTTP requests to test the entire stack
  3. Organize tests by domain/feature rather than by endpoint
  4. Keep test data and setup centralized to avoid duplication
  5. Make tests independent and avoid inter-test dependencies

Example Test Flow

A typical integration test should validate complete user journeys such as:

  1. Create an API
  2. Create a key for that API
  3. Verify the key works
  4. Delete the API
  5. Verify the key no longer works

This validates not just individual endpoints but the entire system behavior.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoadbalancer

func NewLoadbalancer(h *Harness) *loadbalancer

Types

type ApiCluster

type ApiCluster struct {
	Addrs []string
}

ApiCluster represents a cluster of API containers

type ApiConfig

type ApiConfig struct {
	Nodes         int
	MysqlDSN      string
	ClickhouseDSN string
}

ApiConfig holds configuration for dynamic API container creation

type Config

type Config struct {
	// NumNodes is the number of API nodes to create in the cluster
	NumNodes int
}

Config contains configuration options for the test harness

type Harness

type Harness struct {
	Seed *seed.Seeder

	DB db.Database
	CH clickhouse.ClickHouse
	// contains filtered or unexported fields
}

Harness is a test harness for creating and managing a cluster of API nodes

func New

func New(t *testing.T, config Config) *Harness

New creates a new cluster test harness

func (*Harness) GetClusterAddrs

func (h *Harness) GetClusterAddrs() []string

GetClusterAddrs returns the addresses of all API containers

func (*Harness) Resources

func (h *Harness) Resources() seed.Resources

func (*Harness) RunAPI

func (h *Harness) RunAPI(config ApiConfig) *ApiCluster

RunAPI creates a cluster of API containers for chaos testing

type TestResponse

type TestResponse[TBody any] struct {
	Status  int
	Headers http.Header
	Body    TBody
	RawBody string
}

func CallNode

func CallNode[Req any, Res any](t *testing.T, addr, method string, path string, headers http.Header, req Req) (TestResponse[Res], error)

func CallRandomNode

func CallRandomNode[Req any, Res any](lb *loadbalancer, method string, path string, headers http.Header, req Req) (TestResponse[Res], error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL