Documentation
¶
Index ¶
- Constants
- type JournalOpts
- type TestVM
- func (v *TestVM) GetServiceLogs(serviceName string) (string, error)
- func (v *TestVM) JournalLogs(opts JournalOpts) (string, error)
- func (v *TestVM) ParseCloudInit() error
- func (v *TestVM) RunSSH(inputArgs []string, stdin *bytes.Buffer) (*bytes.Buffer, error)
- func (v *TestVM) RunSSHWithUser(inputArgs []string, stdin *bytes.Buffer, user string) (*bytes.Buffer, error)
- func (v *TestVM) SSHCommand(inputArgs []string) *exec.Cmd
- func (v *TestVM) SSHCommandWithUser(inputArgs []string, user string) *exec.Cmd
- func (v *TestVM) WaitForSSHToBeReady() error
- type TestVMInterface
- type VMInLibvirt
- func (v *VMInLibvirt) CreateDomain() error
- func (v *VMInLibvirt) CreateSnapshot(name string) error
- func (v *VMInLibvirt) Delete() (err error)
- func (v *VMInLibvirt) DeleteSnapshot(name string) error
- func (v *VMInLibvirt) EnsureConsoleStream() error
- func (v *VMInLibvirt) Exists() (bool, error)
- func (v *VMInLibvirt) ForceDelete() (err error)
- func (v *VMInLibvirt) GetConsoleOutput() string
- func (v *VMInLibvirt) HasSnapshot(name string) (bool, error)
- func (v *VMInLibvirt) IsRunning() (exists bool, err error)
- func (v *VMInLibvirt) Pause() error
- func (v *VMInLibvirt) Resume() error
- func (v *VMInLibvirt) RevertToSnapshot(name string) error
- func (v *VMInLibvirt) Run() error
- func (v *VMInLibvirt) RunAndWaitForSSH() error
- func (v *VMInLibvirt) Shutdown() (err error)
Constants ¶
const DefaultDiskSizeGB = 10
Default disk size in GB for VM instances
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JournalOpts ¶ added in v0.9.0
type JournalOpts struct {
Unit string
Since string // time string like "20 minutes ago" or empty for all logs
LastBoot bool // false by default, when true restricts logs to current boot
}
JournalOpts collects optional filters. Zero values mean "all units" / "start of journal".
type TestVM ¶
type TestVM struct {
TestDir string
VMName string
LibvirtUri string //linux only
DiskImagePath string
VMUser string //user to use when connecting to the VM
CloudInitDir string
NoCredentials bool
CloudInitData bool
SSHPassword string
SSHPort int
Cmd []string
RemoveVm bool
MemoryFilePath string // Path for external snapshot memory file
DiskSizeGB int
// contains filtered or unexported fields
}
func (*TestVM) GetServiceLogs ¶ added in v0.10.0
GetServiceLogs returns the logs from the specified service using journalctl. This method uses the systemd invocation ID to get logs from the latest service invocation.
func (*TestVM) JournalLogs ¶ added in v0.9.0
func (v *TestVM) JournalLogs(opts JournalOpts) (string, error)
func (*TestVM) ParseCloudInit ¶
func (*TestVM) RunSSHWithUser ¶ added in v0.6.0
func (*TestVM) SSHCommand ¶
RunSSH runs a command over ssh or starts an interactive ssh connection if no command is provided
func (*TestVM) SSHCommandWithUser ¶ added in v0.6.0
func (*TestVM) WaitForSSHToBeReady ¶
type TestVMInterface ¶
type TestVMInterface interface {
Run() error
ForceDelete() error
Shutdown() error
Delete() error
IsRunning() (bool, error)
WaitForSSHToBeReady() error
RunAndWaitForSSH() error
SSHCommand(inputArgs []string) *exec.Cmd
SSHCommandWithUser(nputArgs []string, user string) *exec.Cmd
RunSSH(inputArgs []string, stdin *bytes.Buffer) (*bytes.Buffer, error)
RunSSHWithUser(inputArgs []string, stdin *bytes.Buffer, user string) (*bytes.Buffer, error)
Exists() (bool, error)
GetConsoleOutput() string
EnsureConsoleStream() error
JournalLogs(opts JournalOpts) (string, error)
GetServiceLogs(serviceName string) (string, error)
// Snapshot methods for performance optimization
CreateSnapshot(name string) error
RevertToSnapshot(name string) error
DeleteSnapshot(name string) error
Pause() error
Resume() error
HasSnapshot(name string) (bool, error)
// Domain creation without starting
CreateDomain() error
}
func StartAndWaitForSSH ¶
func StartAndWaitForSSH(params TestVM) (vm TestVMInterface, err error)
type VMInLibvirt ¶
type VMInLibvirt struct {
TestVM
// contains filtered or unexported fields
}
func NewVM ¶
func NewVM(params TestVM) (vm *VMInLibvirt, err error)
func (*VMInLibvirt) CreateDomain ¶ added in v0.10.0
func (v *VMInLibvirt) CreateDomain() error
CreateDomain creates the libvirt domain without starting the VM
func (*VMInLibvirt) CreateSnapshot ¶ added in v0.10.0
func (v *VMInLibvirt) CreateSnapshot(name string) error
CreateSnapshot creates an external snapshot of the VM with memory state
func (*VMInLibvirt) DeleteSnapshot ¶ added in v0.10.0
func (v *VMInLibvirt) DeleteSnapshot(name string) error
DeleteSnapshot deletes a specific snapshot
func (*VMInLibvirt) EnsureConsoleStream ¶ added in v0.10.0
func (v *VMInLibvirt) EnsureConsoleStream() error
EnsureConsoleStream ensures the console stream is properly established
func (*VMInLibvirt) Exists ¶
func (v *VMInLibvirt) Exists() (bool, error)
func (*VMInLibvirt) ForceDelete ¶
func (v *VMInLibvirt) ForceDelete() (err error)
ForceDelete stops and removes the VM
func (*VMInLibvirt) GetConsoleOutput ¶
func (v *VMInLibvirt) GetConsoleOutput() string
cummulatively read console output from the VM
func (*VMInLibvirt) HasSnapshot ¶ added in v0.10.0
func (v *VMInLibvirt) HasSnapshot(name string) (bool, error)
HasSnapshot checks if a snapshot exists
func (*VMInLibvirt) IsRunning ¶
func (v *VMInLibvirt) IsRunning() (exists bool, err error)
func (*VMInLibvirt) Pause ¶ added in v0.10.0
func (v *VMInLibvirt) Pause() error
Pause pauses the VM
func (*VMInLibvirt) Resume ¶ added in v0.10.0
func (v *VMInLibvirt) Resume() error
Resume resumes the VM
func (*VMInLibvirt) RevertToSnapshot ¶ added in v0.10.0
func (v *VMInLibvirt) RevertToSnapshot(name string) error
RevertToSnapshot reverts the VM to a specific snapshot with retry logic
func (*VMInLibvirt) Run ¶
func (v *VMInLibvirt) Run() error
func (*VMInLibvirt) RunAndWaitForSSH ¶
func (v *VMInLibvirt) RunAndWaitForSSH() error