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) AgentRuntimeConfig() (string, error)
- func (h *Host) AgentStableVersion() string
- func (h *Host) AssertPackageInstalledByInstaller(pkgs ...string)
- func (h *Host) AssertPackageInstalledByPackageManager(pkgs ...string)
- func (h *Host) AssertPackageNotInstalledByPackageManager(pkgs ...string)
- func (h *Host) AssertPackagePrefix(pkg string, semver string)
- func (h *Host) AssertPackageVersion(pkg string, version 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) SetUmask(mask string) (oldmask string)
- 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) WaitForFileExists(useSudo bool, filePaths ...string)
- func (h *Host) WaitForTraceAgentSocketReady()
- func (h *Host) WaitForUnitActivating(units ...string)
- func (h *Host) WaitForUnitActive(units ...string)
- func (h *Host) WriteFile(path string, content []byte) error
- type JournaldTimestamp
- type LoadState
- type LocalCDN
- 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) AssertFileExistsAnyUser(path string, perms fs.FileMode)
- 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)
- func (s *State) ListDirectory(path string) []FileInfo
- func (s *State) Stat(path string) (FileInfo, bool)
- 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) SkippedIf(unit string, condition bool) 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.
func (FakeAgent) SetStopWithSigtermExit0 ¶ added in v0.56.0
SetStopWithSigtermExit0 sets the fake Agent to stop with SIGTERM and exit with code 0.
type FileInfo ¶
type FileInfo struct { Name string Size int64 Perms fs.FileMode ModTime time.Time IsDir bool IsSymlink bool Link string User string Group string }
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) AgentRuntimeConfig ¶
AgentRuntimeConfig returns the runtime agent config on the host.
func (*Host) AgentStableVersion ¶ added in v0.57.0
AgentStableVersion returns the stable version of the agent on the 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) AssertPackagePrefix ¶ added in v0.57.0
AssertPackagePrefix checks if a package is installed with a version with the prefix
func (*Host) AssertPackageVersion ¶
AssertPackageVersion checks if a package is installed with the correct version
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) WaitForFileExists ¶ added in v0.56.0
WaitForFileExists waits for a file to exist on the host
func (*Host) WaitForTraceAgentSocketReady ¶ added in v0.57.0
func (h *Host) WaitForTraceAgentSocketReady()
WaitForTraceAgentSocketReady waits for the trace agent to be ready to receive traces This is because of a race condition where the trace agent is not ready to receive traces and we send them meaning that the traces are lost
func (*Host) WaitForUnitActivating ¶ added in v0.56.0
WaitForUnitActivating waits for a systemd unit to be activating
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 LocalCDN ¶ added in v0.59.0
type LocalCDN struct { // DirPath is the path to the local CDN directory. DirPath string // contains filtered or unexported fields }
LocalCDN is a local CDN for testing.
func NewLocalCDN ¶ added in v0.59.0
NewLocalCDN creates a new local CDN.
func (*LocalCDN) AddLayer ¶ added in v0.59.0
AddLayer adds a layer to the local CDN. It'll be last in order.
func (*LocalCDN) RemoveLayer ¶ added in v0.59.0
RemoveLayer removes a layer from the local CDN.
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) AssertFileExistsAnyUser ¶ added in v0.58.0
AssertFileExistsAnyUser asserts that a file exists on the host with the given perms.
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.
func (*State) ListDirectory ¶ added in v0.57.0
ListDirectory returns a list of entries in the directory and fails the test if it doesn't exist
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) SkippedIf ¶ added in v0.58.0
func (s SystemdEventSequence) SkippedIf(unit string, condition bool) SystemdEventSequence
SkippedIf adds a "Skipped" event to the sequence if the condition is true
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