Documentation ¶
Overview ¶
Package host provides a way to interact with an e2e remote host and capture its state.
Index ¶
- Constants
- type FakeAgent
- type FileInfo
- type Host
- func (h *Host) AssertPackageInstalledByInstaller(pkgs ...string)
- func (h *Host) AssertPackageInstalledByPackageManager(pkgs ...string)
- func (h *Host) AssertPackageNotInstalledByPackageManager(pkgs ...string)
- func (h *Host) AssertSystemdEvents(since JournaldTimestamp, events SystemdEventSequence)
- func (h *Host) AssertUnitProperty(unit, property, value string)
- func (h *Host) BootstraperVersion() string
- func (h *Host) CallExamplePythonApp(traceID string)
- func (h *Host) CallExamplePythonAppInDocker(traceID string)
- func (h *Host) DeletePath(path string)
- func (h *Host) FileExists(path string) (bool, error)
- func (h *Host) GetDockerRuntimePath(runtime string) string
- func (h *Host) GetPkgManager() string
- func (h *Host) InstallDocker()
- func (h *Host) InstallerVersion() string
- func (h *Host) LastJournaldTimestamp() JournaldTimestamp
- func (h *Host) ReadFile(path string) ([]byte, error)
- func (h *Host) RemoveBrokenDockerConfig()
- func (h *Host) Run(command string, env ...string) string
- func (h *Host) SetBrokenDockerConfig()
- func (h *Host) SetBrokenDockerConfigAdditionalFields()
- func (h *Host) SetupFakeAgentExp() FakeAgent
- func (h *Host) StartExamplePythonApp()
- func (h *Host) StartExamplePythonAppInDocker()
- func (h *Host) State() State
- func (h *Host) StopExamplePythonApp()
- func (h *Host) StopExamplePythonAppInDocker()
- func (h *Host) WaitForUnitActive(units ...string)
- type JournaldTimestamp
- type LoadState
- type Option
- type State
- func (s *State) AssertDirExists(path string, perms fs.FileMode, user string, group string)
- func (s *State) AssertFileExists(path string, perms fs.FileMode, user string, group string)
- func (s *State) AssertGroupExists(groupName string)
- func (s *State) AssertPathDoesNotExist(path string)
- func (s *State) AssertSymlinkExists(path string, target string, user string, group string)
- func (s *State) AssertUnitsDead(names ...string)
- func (s *State) AssertUnitsEnabled(names ...string)
- func (s *State) AssertUnitsLoaded(names ...string)
- func (s *State) AssertUnitsNotEnabled(names ...string)
- func (s *State) AssertUnitsNotLoaded(names ...string)
- func (s *State) AssertUnitsRunning(names ...string)
- func (s *State) AssertUserExists(userName string)
- func (s *State) AssertUserHasGroup(userName, groupName string)
- type SubState
- type SystemdEvent
- type SystemdEventSequence
- func (s SystemdEventSequence) Failed(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Sigkill(unit string) SystemdEventSequence
- func (s SystemdEventSequence) SigtermTimed(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Skipped(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Started(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Starting(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Stopped(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Stopping(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Timed(unit string) SystemdEventSequence
- func (s SystemdEventSequence) Unordered(events SystemdEventSequence) SystemdEventSequence
- type SystemdUnitInfo
Constants ¶
const ( // Loaded is the load state of a systemd unit. Loaded LoadState = "loaded" // NotLoaded is the load state of a systemd unit. NotLoaded LoadState = "not-found" // Masked is the load state of a systemd unit. Masked LoadState = "masked" // Error is the load state of a systemd unit. Error LoadState = "error" // Running is the sub state of a systemd unit. Running SubState = "running" // Dead is the sub state of a systemd unit. Dead SubState = "dead" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeAgent ¶
type FakeAgent struct {
// contains filtered or unexported fields
}
FakeAgent represents a fake Agent.
func (FakeAgent) SetStopWithSigkill ¶
SetStopWithSigkill sets the fake Agent to stop with SIGKILL.
func (FakeAgent) SetStopWithSigterm ¶
SetStopWithSigterm sets the fake Agent to stop with SIGTERM.
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo struct mimics os.FileInfo
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is a remote host environment.
func New ¶
func New(t *testing.T, remote *components.RemoteHost, os e2eos.Descriptor, arch e2eos.Architecture, opts ...Option) *Host
New creates a new Host.
func (*Host) AssertPackageInstalledByInstaller ¶
AssertPackageInstalledByInstaller checks if a package is installed by the installer on the host.
func (*Host) AssertPackageInstalledByPackageManager ¶
AssertPackageInstalledByPackageManager checks if a package is installed by the package manager on the host.
func (*Host) AssertPackageNotInstalledByPackageManager ¶
AssertPackageNotInstalledByPackageManager checks if a package is not installed by the package manager on the host.
func (*Host) AssertSystemdEvents ¶
func (h *Host) AssertSystemdEvents(since JournaldTimestamp, events SystemdEventSequence)
AssertSystemdEvents asserts that the systemd events have been logged since the given timestamp
func (*Host) AssertUnitProperty ¶
AssertUnitProperty asserts that the given systemd unit has the given property
func (*Host) BootstraperVersion ¶
BootstraperVersion returns the version of the bootstraper on the host.
func (*Host) CallExamplePythonApp ¶
CallExamplePythonApp calls the example Python app
func (*Host) CallExamplePythonAppInDocker ¶
CallExamplePythonAppInDocker calls the example Python app in Docker
func (*Host) DeletePath ¶
DeletePath deletes a path on the host.
func (*Host) FileExists ¶
FileExists checks if a file exists on the host.
func (*Host) GetDockerRuntimePath ¶
GetDockerRuntimePath returns the runtime path of a docker runtime
func (*Host) GetPkgManager ¶
GetPkgManager returns the package manager of the host.
func (*Host) InstallDocker ¶
func (h *Host) InstallDocker()
InstallDocker installs Docker on the host if it is not already installed.
func (*Host) InstallerVersion ¶
InstallerVersion returns the version of the installer on the host.
func (*Host) LastJournaldTimestamp ¶
func (h *Host) LastJournaldTimestamp() JournaldTimestamp
LastJournaldTimestamp returns the monotonic timestamp of the last journald log entry
func (*Host) RemoveBrokenDockerConfig ¶
func (h *Host) RemoveBrokenDockerConfig()
RemoveBrokenDockerConfig removes the broken configuration from the Docker daemon
func (*Host) SetBrokenDockerConfig ¶
func (h *Host) SetBrokenDockerConfig()
SetBrokenDockerConfig injects a broken JSON in the Docker daemon configuration
func (*Host) SetBrokenDockerConfigAdditionalFields ¶
func (h *Host) SetBrokenDockerConfigAdditionalFields()
SetBrokenDockerConfigAdditionalFields injects additional fields in the Docker daemon configuration these fields are not supported
func (*Host) SetupFakeAgentExp ¶
SetupFakeAgentExp sets up a fake Agent experiment with configurable options.
func (*Host) StartExamplePythonApp ¶
func (h *Host) StartExamplePythonApp()
StartExamplePythonApp starts an example Python app
func (*Host) StartExamplePythonAppInDocker ¶
func (h *Host) StartExamplePythonAppInDocker()
StartExamplePythonAppInDocker starts the example Python app in Docker
func (*Host) StopExamplePythonApp ¶
func (h *Host) StopExamplePythonApp()
StopExamplePythonApp stops the example Python app
func (*Host) StopExamplePythonAppInDocker ¶
func (h *Host) StopExamplePythonAppInDocker()
StopExamplePythonAppInDocker stops the example Python app in Docker
func (*Host) WaitForUnitActive ¶
WaitForUnitActive waits for a systemd unit to be active
type JournaldTimestamp ¶
type JournaldTimestamp int64
JournaldTimestamp represents a monotonic timestamp of a journald log entry
type State ¶
type State struct { Users []user.User Groups []user.Group FS map[string]FileInfo Units map[string]SystemdUnitInfo // contains filtered or unexported fields }
State is the state of a remote host.
func (*State) AssertDirExists ¶
AssertDirExists asserts that a directory exists on the host with the given perms, user, and group.
func (*State) AssertFileExists ¶
AssertFileExists asserts that a file exists on the host with the given perms, user, and group.
func (*State) AssertGroupExists ¶
AssertGroupExists asserts that a group exists on the host.
func (*State) AssertPathDoesNotExist ¶
AssertPathDoesNotExist asserts that a path does not exist on the host.
func (*State) AssertSymlinkExists ¶
AssertSymlinkExists asserts that a symlink exists on the host with the given target, user, and group.
func (*State) AssertUnitsDead ¶
AssertUnitsDead asserts that a systemd unit is not running.
func (*State) AssertUnitsEnabled ¶
AssertUnitsEnabled asserts that a systemd unit is not loaded.
func (*State) AssertUnitsLoaded ¶
AssertUnitsLoaded asserts that units are enabled on the host.
func (*State) AssertUnitsNotEnabled ¶
AssertUnitsNotEnabled asserts that a systemd unit is not enabled
func (*State) AssertUnitsNotLoaded ¶
AssertUnitsNotLoaded asserts that a systemd unit is not loaded.
func (*State) AssertUnitsRunning ¶
AssertUnitsRunning asserts that a systemd unit is running.
func (*State) AssertUserExists ¶
AssertUserExists asserts that a user exists on the host.
func (*State) AssertUserHasGroup ¶
AssertUserHasGroup asserts that a user has a group on the host.
type SystemdEvent ¶
SystemdEvent represents a systemd event
type SystemdEventSequence ¶
type SystemdEventSequence struct {
Events [][]SystemdEvent
}
SystemdEventSequence represents a sequence of systemd events
func SystemdEvents ¶
func SystemdEvents() SystemdEventSequence
SystemdEvents returns a new SystemdEventSequence
func (SystemdEventSequence) Failed ¶
func (s SystemdEventSequence) Failed(unit string) SystemdEventSequence
Failed adds a "Failed" event to the sequence
func (SystemdEventSequence) Sigkill ¶
func (s SystemdEventSequence) Sigkill(unit string) SystemdEventSequence
Sigkill adds a "Sigkill" event to the sequence
func (SystemdEventSequence) SigtermTimed ¶
func (s SystemdEventSequence) SigtermTimed(unit string) SystemdEventSequence
SigtermTimed adds a "SigtermTimed" event to the sequence
func (SystemdEventSequence) Skipped ¶
func (s SystemdEventSequence) Skipped(unit string) SystemdEventSequence
Skipped adds a "Skipped" event to the sequence
func (SystemdEventSequence) Started ¶
func (s SystemdEventSequence) Started(unit string) SystemdEventSequence
Started adds a "Started" event to the sequence
func (SystemdEventSequence) Starting ¶
func (s SystemdEventSequence) Starting(unit string) SystemdEventSequence
Starting adds a "Starting" event to the sequence
func (SystemdEventSequence) Stopped ¶
func (s SystemdEventSequence) Stopped(unit string) SystemdEventSequence
Stopped adds a "Stopped" event to the sequence
func (SystemdEventSequence) Stopping ¶
func (s SystemdEventSequence) Stopping(unit string) SystemdEventSequence
Stopping adds a "Stopping" event to the sequence
func (SystemdEventSequence) Timed ¶
func (s SystemdEventSequence) Timed(unit string) SystemdEventSequence
Timed adds a "Timed" event to the sequence
func (SystemdEventSequence) Unordered ¶
func (s SystemdEventSequence) Unordered(events SystemdEventSequence) SystemdEventSequence
Unordered adds an unordered sequence of events to the sequence