Documentation
¶
Overview ¶
Package multivm contains utilities for working with more than one VM (ARCVM, Crostini, etc.) at a time.
Index ¶
- Constants
- Variables
- func ARCFromPre(pre *PreData) *arc.ARC
- func ArcCrostiniStarted() testing.Precondition
- func ArcCrostiniStartedWithDNSProxy() testing.Precondition
- func ArcStarted() testing.Precondition
- func CrostiniFromPre(pre *PreData) *vm.Container
- func CrostiniStarted() testing.Precondition
- func MemoryMetrics(ctx context.Context, base *BaseMetrics, pre *PreData, p *perf.Values, ...) error
- func NewMultiVMPrecondition(name string, vmState StateManager) testing.Precondition
- func NoVMStarted() testing.Precondition
- type ARCOptions
- type BaseMetrics
- type ChromeOptions
- type CrostiniOptions
- type PreData
- type StateManager
- func (s *StateManager) Activate(ctx context.Context, st StateManagerTestingState) (errRet error)
- func (s *StateManager) Active() bool
- func (s *StateManager) CheckAndReset(ctx context.Context, st StateManagerTestingState) error
- func (s *StateManager) Chrome() *chrome.Chrome
- func (s *StateManager) Deactivate(ctx context.Context) (errRet error)
- func (s *StateManager) Keyboard() *input.KeyboardEventWriter
- func (s *StateManager) TestAPIConn() *chrome.TestConn
- func (s *StateManager) Timeout() time.Duration
- func (s *StateManager) VMs() map[string]interface{}
- type StateManagerTestingState
- type VMActivation
- type VMOptions
Constants ¶
const ARCName = "ARC"
ARCName is a stable name for the ARC VM.
const CrostiniName = "Crostini"
CrostiniName is a stable name for the Crostini VM.
Variables ¶
var DefaultARCOptions = ARCOptions{}
DefaultARCOptions defines the default options for starting ARC VM.
var DefaultChromeOptions = ChromeOptions{ Timeout: chrome.LoginTimeout, }
DefaultChromeOptions defines the default options for creating Chrome.
var DefaultCrostiniOptions = CrostiniOptions{ LargeContainer: false, DebianVersion: vm.DebianBuster, }
DefaultCrostiniOptions defines the default options for starting Crostini.
Functions ¶
func ARCFromPre ¶
ARCFromPre returns the ARC instance setup by the multi-vm precondition, if available, and nil otherwise.
func ArcCrostiniStarted ¶
func ArcCrostiniStarted() testing.Precondition
ArcCrostiniStarted returns a Precondition that logs into Chrome and starts ARCVM an Crostini.
func ArcCrostiniStartedWithDNSProxy ¶
func ArcCrostiniStartedWithDNSProxy() testing.Precondition
ArcCrostiniStartedWithDNSProxy returns a Precondition that logs into Chrome with DNS proxy enabled and starts ARC and Crostini.
func ArcStarted ¶
func ArcStarted() testing.Precondition
ArcStarted returns a Precondition that logs into Chrome and starts ARCVM.
func CrostiniFromPre ¶
CrostiniFromPre returns the Crostini instance setup by the multi-vm precondition, if available, and nil otherwise.
func CrostiniStarted ¶
func CrostiniStarted() testing.Precondition
CrostiniStarted returns a Precondition that logs into Chrome and starts Crostini.
func MemoryMetrics ¶
func MemoryMetrics(ctx context.Context, base *BaseMetrics, pre *PreData, p *perf.Values, outdir, suffix string) error
MemoryMetrics is a thin wrapper around metrics.MemoryMetrics, scheduled for deletion. See details in BaseMetrics comment.
func NewMultiVMPrecondition ¶
func NewMultiVMPrecondition(name string, vmState StateManager) testing.Precondition
NewMultiVMPrecondition returns a new precondition that can be used be used by tests that expect multiple VMs to be started at the start of the test.
func NoVMStarted ¶
func NoVMStarted() testing.Precondition
NoVMStarted returns a Precondition that logs into Chrome without starting any VMs.
Types ¶
type ARCOptions ¶
type ARCOptions struct { }
ARCOptions describes how to start ARC.
func (ARCOptions) Activate ¶
func (o ARCOptions) Activate(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn, st StateManagerTestingState) (VMActivation, error)
Activate spins up the ARC VM.
func (ARCOptions) ActivateTimeout ¶
func (o ARCOptions) ActivateTimeout() time.Duration
ActivateTimeout returns the timeout needed to setup the ARC VM.
func (ARCOptions) ChromeOpts ¶
func (o ARCOptions) ChromeOpts() []chrome.Option
ChromeOpts returns the Chrome option(s) that should be passed to chrome.New().
func (ARCOptions) Name ¶
func (o ARCOptions) Name() string
Name returns a stable name for the ARC VM.
type BaseMetrics ¶
type BaseMetrics struct {
// contains filtered or unexported fields
}
BaseMetrics is a thin wrapper around metrics.BaseMetrics. This is only added to allow tests in other Depots to temporarily compile okay with this change, which renames multivm.BaseMetrics into metrics.BaseMetrics. TODO(raging): delete this class and this whole file when no code depends on it anymore.
func NewBaseMetrics ¶
func NewBaseMetrics() (*BaseMetrics, error)
NewBaseMetrics is a thin wrapper around metrics.NewBaseMetrics, scheduled for deletion. See details in BaseMetrics comment.
type ChromeOptions ¶
type ChromeOptions struct { EnableFeatures []string // extra Chrome features to enable ExtraArgs []string // passed to Chrome on initialization Timeout time.Duration }
ChromeOptions describe how to run chrome.New.
type CrostiniOptions ¶
type CrostiniOptions struct { DebianVersion vm.ContainerDebianVersion // OS version of the container image. MinDiskSize uint64 // The minimum size of the VM image in bytes. 0 to use default disk size. LargeContainer bool }
CrostiniOptions describe how to start Crostini.
func (CrostiniOptions) Activate ¶
func (o CrostiniOptions) Activate(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn, st StateManagerTestingState) (VMActivation, error)
Activate spins up the Crostini VM.
func (CrostiniOptions) ActivateTimeout ¶
func (o CrostiniOptions) ActivateTimeout() time.Duration
ActivateTimeout returns the time needed to setup the Crostini VM.
func (CrostiniOptions) ChromeOpts ¶
func (o CrostiniOptions) ChromeOpts() []chrome.Option
ChromeOpts returns the Chrome option(s) that should be passed to chrome.New().
func (CrostiniOptions) Name ¶
func (o CrostiniOptions) Name() string
Name returns a stable name for the Crostini VM.
type PreData ¶
type PreData struct { // Always available. Chrome *chrome.Chrome TestAPIConn *chrome.TestConn Keyboard *input.KeyboardEventWriter // The VMs set up by the precondition. It is recommended to access via the // VM-defined helper methods, such as multivm.ARCFromPre and // multivm.CrostiniFromPre. VMs map[string]interface{} }
PreData holds data allowing tests to interact with the VMs requested by their precondition.
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager allows Chrome and VMs to be activated, checked and cleaned between tests, and deactivated.
func NewStateManager ¶
func NewStateManager(crOptions ChromeOptions, vms ...VMOptions) StateManager
NewStateManager creates a state manager from ChromeOptions, and optional VMOptions, depending on the VMs to be launched.
func (*StateManager) Activate ¶
func (s *StateManager) Activate(ctx context.Context, st StateManagerTestingState) (errRet error)
Activate Chrome and any requested VMs.
func (*StateManager) Active ¶
func (s *StateManager) Active() bool
Active is true if Chrome and VMs are currently active.
func (*StateManager) CheckAndReset ¶
func (s *StateManager) CheckAndReset(ctx context.Context, st StateManagerTestingState) error
CheckAndReset Chrome and any requested VMs, so they can be re-used for another test.
func (*StateManager) Chrome ¶
func (s *StateManager) Chrome() *chrome.Chrome
Chrome gets the active chrome.Chrome.
func (*StateManager) Deactivate ¶
func (s *StateManager) Deactivate(ctx context.Context) (errRet error)
Deactivate the state. Safe to call even if not active, or partially active because initialization failed.
func (*StateManager) Keyboard ¶
func (s *StateManager) Keyboard() *input.KeyboardEventWriter
Keyboard gets the active KeyboardEventWriter.
func (*StateManager) TestAPIConn ¶
func (s *StateManager) TestAPIConn() *chrome.TestConn
TestAPIConn gets the active chrome.TestConn.
func (*StateManager) Timeout ¶
func (s *StateManager) Timeout() time.Duration
Timeout returns the total timeout needed to activate Chrome and all VMs.
func (*StateManager) VMs ¶
func (s *StateManager) VMs() map[string]interface{}
VMs returns the active VMs as map, keyed by a VM-defined name. Test code will typically not interact directly with this untyped collection, but use VM-specific helper methods like multivm.ARCFromPre, multivm.CrostiniFromPre to access it.
type StateManagerTestingState ¶
type StateManagerTestingState interface { DataPath(p string) string OutDir() string RequiredVar(name string) string Var(name string) (val string, ok bool) SoftwareDeps() []string }
StateManagerTestingState is the subset of testing.State or testing.PreState needed by StateManager.
type VMActivation ¶
type VMActivation interface { // CheckAndReset checks and cleans a VM, so it can be re-used for another test. CheckAndReset(ctx context.Context, st StateManagerTestingState) error // Deactivate the VM. Deactivate(ctx context.Context) error // VM returns a VM-specific object representing the active VM. VM() interface{} }
VMActivation represents an active VM instance. This interface is returned by VMOptions.Activate(...) to ensure the methods can only be called after activation has occurred.
type VMOptions ¶
type VMOptions interface { // Name returns a stable name for the VM. This is the same name that // must be passed to StateManager.VM() to retrieve the VM instance. Name() string // ChromeOpts returns the Chrome option(s) that should be passed to // chrome.New(). ChromeOpts() []chrome.Option // ActivateTimeout returns the time needed to activate the VM. ActivateTimeout() time.Duration // Activate activates the requested VM. The operation should either // succeed completely, or roll the VM back to a deactivated state. Activate(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn, st StateManagerTestingState) (VMActivation, error) }
VMOptions describes how to start a VM.