Documentation
¶
Index ¶
- Constants
- func AcquireSandboxSlot(t *testing.T) func()
- func AddUserToTeam(t *testing.T, db *setup.Database, teamID uuid.UUID, userID string)
- func BuildSimpleTemplate(tb testing.TB, name string, reqEditors ...api.RequestEditorFn) *api.TemplateRequestResponseV3
- func BuildTemplate(tb testing.TB, opts TemplateBuildOptions) *api.TemplateRequestResponseV3
- func CreateAPIKey(t *testing.T, ctx context.Context, c *api.ClientWithResponses, userID string, ...) string
- func CreateAccessToken(t *testing.T, db *setup.Database, userID uuid.UUID) string
- func CreateDir(tb testing.TB, sbx *api.Sandbox, path string)
- func CreateTeam(t *testing.T, db *setup.Database, teamName string) uuid.UUID
- func CreateTeamWithUser(t *testing.T, db *setup.Database, teamName, userID string) uuid.UUID
- func CreateTextFile(tb testing.TB, path string, content string) (*bytes.Buffer, string)
- func CreateUser(t *testing.T, db *setup.Database) uuid.UUID
- func ExecCommand(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) error
- func ExecCommandAsRoot(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) error
- func ExecCommandAsRootWithOutput(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) (string, error)
- func ExecCommandWithCwd(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) error
- func ExecCommandWithOptions(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) error
- func ExecCommandWithOutput(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) (string, error)
- func NewRequest(sbx *api.Sandbox, url *url.URL, port int, extraHeaders *http.Header) *http.Request
- func SetupSandboxWithCleanup(t *testing.T, c *api.ClientWithResponses, options ...SandboxOption) *api.Sandbox
- func TeardownSandbox(t *testing.T, c *api.ClientWithResponses, sandboxID string)
- func UploadFile(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...)
- func WaitForBuildCompletion(tb testing.TB, ctx context.Context, templateID string, buildID string, ...)
- func WaitForStatus(tb testing.TB, client *http.Client, sbx *api.Sandbox, url *url.URL, port int, ...) *http.Response
- type BuildLogHandler
- type SandboxConfig
- type SandboxOption
- func WithAllowInternetAccess(allow bool) SandboxOption
- func WithAutoPause(autoPause bool) SandboxOption
- func WithAutoResume(enabled bool) SandboxOption
- func WithMetadata(metadata api.SandboxMetadata) SandboxOption
- func WithNetwork(network *api.SandboxNetworkConfig) SandboxOption
- func WithSecure(secure bool) SandboxOption
- func WithTemplateID(templateID string) SandboxOption
- func WithTimeout(timeout int32) SandboxOption
- func WithoutAnyMetadata() SandboxOption
- type TemplateBuildOptions
Constants ¶
const ( DefaultBuildTimeout = 5 * time.Minute DefaultCPUCount = int32(2) DefaultMemoryMB = int32(1024) )
const MaxConcurrentSandboxes = 100
MaxConcurrentSandboxes gates parallel sandbox creation in tests. The integration test team is granted extra capacity in seed.go (base tier 20 + addon 200 = 220), so this can stay well below that ceiling.
Variables ¶
This section is empty.
Functions ¶
func AcquireSandboxSlot ¶
AcquireSandboxSlot blocks until a sandbox slot is available and returns an idempotent release function. The slot is also released automatically via t.Cleanup, so callers that tie the sandbox lifetime to the test can simply ignore the return value. Callers that tear down sandboxes inline (loops, sequential creates) can call the returned function early to free the slot sooner.
func AddUserToTeam ¶
func BuildSimpleTemplate ¶
func BuildSimpleTemplate(tb testing.TB, name string, reqEditors ...api.RequestEditorFn) *api.TemplateRequestResponseV3
BuildSimpleTemplate builds a simple template with Ubuntu 22.04 base image
func BuildTemplate ¶
func BuildTemplate(tb testing.TB, opts TemplateBuildOptions) *api.TemplateRequestResponseV3
BuildTemplate builds a template with the given options and waits for it to complete
func CreateAPIKey ¶
func CreateAccessToken ¶
func CreateTeamWithUser ¶
func CreateTextFile ¶
func ExecCommand ¶
func ExecCommandAsRoot ¶
func ExecCommandWithCwd ¶
func ExecCommandWithOptions ¶
func ExecCommandWithOutput ¶
func NewRequest ¶
func SetupSandboxWithCleanup ¶
func SetupSandboxWithCleanup(t *testing.T, c *api.ClientWithResponses, options ...SandboxOption) *api.Sandbox
SetupSandboxWithCleanup creates a new sandbox and returns its data. It acquires a semaphore slot to stay within the tier's concurrent instance limit; the slot is released after the sandbox is torn down in t.Cleanup.
func TeardownSandbox ¶
func TeardownSandbox(t *testing.T, c *api.ClientWithResponses, sandboxID string)
TeardownSandbox kills the sandbox with the given ID
func UploadFile ¶
func WaitForBuildCompletion ¶
func WaitForBuildCompletion( tb testing.TB, ctx context.Context, templateID string, buildID string, name string, logHandler BuildLogHandler, enableDebug bool, reqEditors ...api.RequestEditorFn, )
WaitForBuildCompletion waits for a template build to complete
Types ¶
type BuildLogHandler ¶
type BuildLogHandler func(alias string, entry api.BuildLogEntry)
BuildLogHandler is a function that handles build log entries
func DefaultBuildLogHandler ¶
func DefaultBuildLogHandler(tb testing.TB) BuildLogHandler
DefaultBuildLogHandler returns a default log handler that logs to the test logger
func NoOpBuildLogHandler ¶
func NoOpBuildLogHandler() BuildLogHandler
NoOpBuildLogHandler returns a log handler that does nothing
type SandboxConfig ¶
type SandboxConfig struct {
// contains filtered or unexported fields
}
type SandboxOption ¶
type SandboxOption func(config *SandboxConfig)
func WithAllowInternetAccess ¶
func WithAllowInternetAccess(allow bool) SandboxOption
func WithAutoPause ¶
func WithAutoPause(autoPause bool) SandboxOption
func WithAutoResume ¶
func WithAutoResume(enabled bool) SandboxOption
func WithMetadata ¶
func WithMetadata(metadata api.SandboxMetadata) SandboxOption
func WithNetwork ¶
func WithNetwork(network *api.SandboxNetworkConfig) SandboxOption
func WithSecure ¶
func WithSecure(secure bool) SandboxOption
func WithTemplateID ¶
func WithTemplateID(templateID string) SandboxOption
func WithTimeout ¶
func WithTimeout(timeout int32) SandboxOption
func WithoutAnyMetadata ¶
func WithoutAnyMetadata() SandboxOption
type TemplateBuildOptions ¶
type TemplateBuildOptions struct {
Name string
Tags *[]string
CPUCount *int32
MemoryMB *int32
BuildData api.TemplateBuildStartV2
Timeout time.Duration
LogHandler BuildLogHandler
EnableDebug bool
ReqEditors []api.RequestEditorFn
}
TemplateBuildOptions contains options for building a template