Documentation
¶
Index ¶
- Constants
- func AssertEqual(t *testing.T, expected, actual interface{}, msg string)
- func AssertNoError(t *testing.T, err error, msg string)
- func AssertNotEmpty(t *testing.T, value string, msg string)
- func GenerateTestName(prefix string) string
- type CLIResult
- type CLITestContext
- func (ctx *CLITestContext) DeleteInstanceCLI(name string) error
- func (ctx *CLITestContext) LaunchInstanceCLI(templateSlug, instanceName, size string) (*CLIResult, error)
- func (ctx *CLITestContext) ListInstancesCLI() ([]string, error)
- func (ctx *CLITestContext) Prism(args ...string) *CLIResult
- func (ctx *CLITestContext) PrismJSON(target interface{}, args ...string) error
- func (ctx *CLITestContext) PrismQuiet(args ...string) *CLIResult
- func (ctx *CLITestContext) StopInstanceCLI(name string) error
- func (ctx *CLITestContext) VerifyInstanceInAWS(name string) error
- type TestContext
- func (ctx *TestContext) AddCleanup(fn func())
- func (ctx *TestContext) AssertInstanceExists(name string) *types.Instance
- func (ctx *TestContext) AssertInstanceState(name, expectedState string)
- func (ctx *TestContext) Cleanup()
- func (ctx *TestContext) DeleteInstance(name string) error
- func (ctx *TestContext) HibernateInstance(name string) error
- func (ctx *TestContext) LaunchInstance(templateSlug, instanceName, size string) (*types.Instance, error)
- func (ctx *TestContext) StartDaemon()
- func (ctx *TestContext) StartInstance(name string) error
- func (ctx *TestContext) StopInstance(name string) error
- func (ctx *TestContext) TrackInstance(name string)
- func (ctx *TestContext) TrackVolume(name string)
- func (ctx *TestContext) WaitForInstanceDeleted(name string, timeout time.Duration) error
- func (ctx *TestContext) WaitForInstanceRunning(name string) (*types.Instance, error)
- func (ctx *TestContext) WaitForInstanceState(name, desiredState string, timeout time.Duration) error
Constants ¶
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 ¶
AssertEqual fails test if values are not equal
func AssertNoError ¶
AssertNoError fails test if error is not nil
func AssertNotEmpty ¶
AssertNotEmpty fails test if string is empty
func GenerateTestName ¶
GenerateTestName creates a unique test resource name
Types ¶
type CLIResult ¶ added in v0.6.0
CLIResult captures the result of a CLI command execution
func (*CLIResult) AssertContains ¶ added in v0.6.0
AssertContains fails test if output does not contain expected string
func (*CLIResult) AssertFailure ¶ added in v0.6.0
AssertFailure fails test if CLI command succeeded (expected non-zero exit code)
func (*CLIResult) AssertNotContains ¶ added in v0.6.0
AssertNotContains fails test if output contains unexpected string
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) WaitForInstanceDeleted ¶ added in v0.7.7
func (ctx *TestContext) WaitForInstanceDeleted(name string, timeout time.Duration) error
WaitForInstanceDeleted waits for an instance to disappear from the list after deletion. Uses exponential backoff to handle AWS eventual consistency (deletion can take several minutes to propagate).
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 using exponential backoff. Backoff starts at 5s, doubles each attempt, caps at 30s (matches AWS eventual consistency).