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, _ *api.ClientWithResponses, userID string, ...) 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 ExecCommandAsDefaultUserWithOutput(tb testing.TB, ctx context.Context, sbx *api.Sandbox, ...) (string, 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 MatchesAPIKeyMask(apiKey string, prefix string, maskPrefix string, maskSuffix string) bool
- func NewRequest(sbx *api.Sandbox, url *url.URL, port int, extraHeaders *http.Header) *http.Request
- func RequestTemplateWithoutBuild(tb testing.TB, name string, reqEditors ...api.RequestEditorFn) *api.TemplateRequestResponseV3
- 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 UploadFileAs(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 WithAutoPauseMemory(memory 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 CreateTeamWithUser ¶
func CreateTextFile ¶
func ExecCommand ¶
func ExecCommandAsDefaultUserWithOutput ¶
func ExecCommandAsDefaultUserWithOutput(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, command string, args ...string) (string, error)
ExecCommandAsDefaultUserWithOutput runs a command without sending a user header, so envd falls back to the default user set at /init time. This is the path that exercises the template's default user/workdir (it differs from passing an explicit "user").
func ExecCommandAsRoot ¶
func ExecCommandWithCwd ¶
func ExecCommandWithOptions ¶
func ExecCommandWithOutput ¶
func MatchesAPIKeyMask ¶
func NewRequest ¶
func RequestTemplateWithoutBuild ¶
func RequestTemplateWithoutBuild(tb testing.TB, name string, reqEditors ...api.RequestEditorFn) *api.TemplateRequestResponseV3
RequestTemplateWithoutBuild creates a template without starting (or waiting for) its build. The template row, a build in the "waiting" state, the alias, and the default tag assignment all exist as soon as the request returns, so the template can be listed, updated (e.g. visibility), and deleted.
Use this instead of BuildSimpleTemplate in tests that only exercise template metadata or authorization and never need a runnable build - a real build boots a Firecracker VM and takes minutes, while this is a single API call.
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 UploadFileAs ¶
func UploadFileAs(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, path, content, username string)
UploadFileAs uploads content to path as username, for the paths the default user cannot write.
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 WithAutoPauseMemory ¶
func WithAutoPauseMemory(memory bool) SandboxOption
WithAutoPauseMemory controls the snapshot kind taken when the sandbox auto-pauses on timeout. false requests a filesystem-only auto-pause.
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