Help us shape the future of Go! Take the 2026 Go Developer Survey

integration

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

README

Persona-Based Integration Tests

This directory contains integration tests based on the 5 persona walkthroughs documented in docs/USER_SCENARIOS/.

Purpose

These tests validate real-world user workflows against actual AWS infrastructure, ensuring that the documented persona scenarios work end-to-end.

Test Configuration

AWS Profile: aws AWS Region: us-west-2

Running Tests

# Run all persona integration tests
go test ./test/integration -v -timeout 30m

# Run specific persona
go test ./test/integration -v -timeout 30m -run TestSoloResearcherPersona

# Skip integration tests (default in CI)
go test ./... -short

Test Structure

Each persona test follows this structure:

  1. Setup: Configure test environment with AWS profile and region
  2. Execute: Run through the documented workflow step-by-step
  3. Verify: Check that each step produces expected results
  4. Cleanup: Delete all created resources (instances, volumes, etc.)

Test Personas

1. Solo Researcher (Dr. Sarah Chen)

File: personas_test.go::TestSoloResearcherPersona Workflow: Launch workspace → Enable hibernation → Daily work cycle → Cost tracking Duration: ~10 minutes Resources: 1 instance, 1 hibernation profile

2. Lab Environment (Prof. Martinez)

File: personas_test.go::TestLabEnvironmentPersona Workflow: Multi-user setup → Shared storage → Team collaboration Duration: ~15 minutes Resources: 3 instances, 1 EFS volume, 3 research users

3. University Class (Prof. Thompson)

File: personas_test.go::TestUniversityClassPersona Workflow: Bulk launch → Student access → Template standardization Duration: ~20 minutes Resources: 25 instances (simulated), shared template

4. Conference Workshop (Dr. Patel)

File: personas_test.go::TestConferenceWorkshopPersona Workflow: Rapid deployment → Public access → Time-limited workspaces Duration: ~10 minutes Resources: 10 instances (simulated), auto-termination

5. Cross-Institutional Collaboration (Dr. Kim)

File: personas_test.go::TestCrossInstitutionalPersona Workflow: Multi-profile setup → Shared EFS → Budget tracking Duration: ~15 minutes Resources: 2 instances, 1 shared EFS, 2 AWS profiles

Important Notes

Cost Considerations

These tests create real AWS resources and incur real costs. Estimated cost per full test run: ~$1.50

Resource Cleanup

All tests include comprehensive cleanup in defer statements. If tests fail mid-execution, resources may remain. Check with:

./bin/prism list
./bin/prism storage list
Test Isolation

Each test uses unique names with timestamps to avoid conflicts when running tests in parallel.

CI/CD Integration

Integration tests are skipped by default in CI (testing.Short()). Run manually with:

go test ./test/integration -v -timeout 30m

Troubleshooting

Authentication Errors

Ensure AWS profile 'aws' is configured:

aws configure --profile aws
aws sts get-caller-identity --profile aws
Timeout Errors

Some workflows (instance launch) can take 5-8 minutes. Tests have 30-minute timeout. Increase if needed:

go test ./test/integration -v -timeout 60m
Resource Conflicts

If test fails to cleanup, manually delete resources:

./bin/prism delete test-* --force
./bin/prism storage delete test-* --force

Adding New Tests

  1. Read persona walkthrough in docs/USER_SCENARIOS/
  2. Create test function following naming pattern: TestXXXPersona
  3. Use helper functions from helpers.go
  4. Include comprehensive cleanup
  5. Document expected duration and resource usage

Success Criteria

A successful persona test should:

  • ✅ Complete all documented workflow steps
  • ✅ Verify outputs match expected values
  • ✅ Clean up all created resources
  • ✅ Complete within expected timeframe
  • ✅ Work on first run (no manual setup required)

Documentation

Index

Constants

View Source
const (
	// Test configuration
	TestAWSProfile = "aws"
	TestAWSRegion  = "us-west-2"
	DaemonURL      = "http://localhost:8947"

	// Timeouts
	DaemonStartTimeout    = 30 * time.Second
	InstanceReadyTimeout  = 10 * time.Minute
	InstanceStopTimeout   = 10 * time.Minute // GPU instances can take 10+ minutes to stop
	InstanceDeleteTimeout = 5 * time.Minute
	PollInterval          = 10 * time.Second
)

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(t *testing.T, expected, actual interface{}, msg string)

AssertEqual fails test if values are not equal

func AssertNoError

func AssertNoError(t *testing.T, err error, msg string)

AssertNoError fails test if error is not nil

func AssertNotEmpty

func AssertNotEmpty(t *testing.T, value string, msg string)

AssertNotEmpty fails test if string is empty

func GenerateTestName

func GenerateTestName(prefix string) string

GenerateTestName creates a unique test resource name

Types

type CLIResult added in v0.6.0

type CLIResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Duration time.Duration
	Err      error
}

CLIResult captures the result of a CLI command execution

func (*CLIResult) AssertContains added in v0.6.0

func (r *CLIResult) AssertContains(t *testing.T, expected, msg string)

AssertContains fails test if output does not contain expected string

func (*CLIResult) AssertFailure added in v0.6.0

func (r *CLIResult) AssertFailure(t *testing.T, msg string)

AssertFailure fails test if CLI command succeeded (expected non-zero exit code)

func (*CLIResult) AssertNotContains added in v0.6.0

func (r *CLIResult) AssertNotContains(t *testing.T, unexpected, msg string)

AssertNotContains fails test if output contains unexpected string

func (*CLIResult) AssertSuccess added in v0.6.0

func (r *CLIResult) AssertSuccess(t *testing.T, msg string)

AssertSuccess fails test if CLI command did not succeed (exit code 0)

type CLITestContext added in v0.6.0

type CLITestContext struct {
	*TestContext
	PrismBin   string
	ConfigDir  string
	StateDir   string
	OutputLogs bool // If true, logs all CLI output to test logs
}

CLITestContext extends TestContext with CLI binary execution capabilities

func NewCLITestContext added in v0.6.0

func NewCLITestContext(t *testing.T) *CLITestContext

NewCLITestContext creates a test context with CLI capabilities

func (*CLITestContext) DeleteInstanceCLI added in v0.6.0

func (ctx *CLITestContext) DeleteInstanceCLI(name string) error

DeleteInstanceCLI deletes an instance using the prism CLI

func (*CLITestContext) LaunchInstanceCLI added in v0.6.0

func (ctx *CLITestContext) LaunchInstanceCLI(templateSlug, instanceName, size string) (*CLIResult, error)

LaunchInstanceCLI launches an instance using the prism CLI (not API)

func (*CLITestContext) ListInstancesCLI added in v0.6.0

func (ctx *CLITestContext) ListInstancesCLI() ([]string, error)

ListInstancesCLI lists instances using the prism CLI

func (*CLITestContext) Prism added in v0.6.0

func (ctx *CLITestContext) Prism(args ...string) *CLIResult

Prism executes the prism CLI with given arguments Returns CLIResult with exit code, stdout, stderr, and any execution errors

func (*CLITestContext) PrismJSON added in v0.6.0

func (ctx *CLITestContext) PrismJSON(target interface{}, args ...string) error

PrismJSON executes prism CLI expecting JSON output and unmarshals into target

func (*CLITestContext) PrismQuiet added in v0.6.0

func (ctx *CLITestContext) PrismQuiet(args ...string) *CLIResult

PrismQuiet executes prism CLI without logging output (for programmatic parsing)

func (*CLITestContext) StopInstanceCLI added in v0.6.0

func (ctx *CLITestContext) StopInstanceCLI(name string) error

StopInstanceCLI stops an instance using the prism CLI

func (*CLITestContext) VerifyInstanceInAWS added in v0.6.0

func (ctx *CLITestContext) VerifyInstanceInAWS(name string) error

VerifyInstanceInAWS verifies instance actually exists in AWS (not just in state)

type TestContext

type TestContext struct {
	T             *testing.T
	Client        client.PrismAPI
	DaemonCmd     *exec.Cmd
	CleanupFuncs  []func()
	InstanceNames []string
	VolumeNames   []string
}

TestContext holds common test resources

func NewTestContext

func NewTestContext(t *testing.T) *TestContext

NewTestContext creates a new test context with daemon and API client

func (*TestContext) AddCleanup

func (ctx *TestContext) AddCleanup(fn func())

AddCleanup adds a cleanup function to be called at test end

func (*TestContext) AssertInstanceExists

func (ctx *TestContext) AssertInstanceExists(name string) *types.Instance

AssertInstanceExists verifies instance can be retrieved

func (*TestContext) AssertInstanceState

func (ctx *TestContext) AssertInstanceState(name, expectedState string)

AssertInstanceState verifies instance is in expected state

func (*TestContext) Cleanup

func (ctx *TestContext) Cleanup()

Cleanup runs all cleanup functions in reverse order

func (*TestContext) DeleteInstance

func (ctx *TestContext) DeleteInstance(name string) error

DeleteInstance deletes an instance and removes from tracking

func (*TestContext) HibernateInstance

func (ctx *TestContext) HibernateInstance(name string) error

HibernateInstance hibernates an instance

func (*TestContext) LaunchInstance

func (ctx *TestContext) LaunchInstance(templateSlug, instanceName, size string) (*types.Instance, error)

LaunchInstance launches an instance and waits for it to be ready

func (*TestContext) StartDaemon

func (ctx *TestContext) StartDaemon()

StartDaemon starts the daemon process for testing

func (*TestContext) StartInstance

func (ctx *TestContext) StartInstance(name string) error

StartInstance starts a stopped/hibernated instance

func (*TestContext) StopInstance

func (ctx *TestContext) StopInstance(name string) error

StopInstance stops an instance and waits for stopped state

func (*TestContext) TrackInstance

func (ctx *TestContext) TrackInstance(name string)

TrackInstance adds an instance name to cleanup list

func (*TestContext) TrackVolume

func (ctx *TestContext) TrackVolume(name string)

TrackVolume adds a volume name to cleanup list

func (*TestContext) WaitForInstanceRunning

func (ctx *TestContext) WaitForInstanceRunning(name string) (*types.Instance, error)

WaitForInstanceRunning waits for instance to be running and returns instance details

func (*TestContext) WaitForInstanceState

func (ctx *TestContext) WaitForInstanceState(name, desiredState string, timeout time.Duration) error

WaitForInstanceState waits for instance to reach desired state

Jump to

Keyboard shortcuts

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