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 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) 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 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