Documentation
¶
Overview ¶
Package ssm supplies a focused set of helper assertions for Terratest integration suites. Each helper runs a shell command on a target EC2 instance through AWS Systems Manager (SSM) and immediately translates the result into a testify assertion, providing declarative checks of common OS-level expectations:
- file or directory presence and permissions
- package installation status
- user, group, or service existence and state
- mount points, network reachability, DNS resolution
- arbitrary command output
The helpers hide repetitive SSM polling and error handling, so test code stays short, readable, and intent-focused.
Index ¶
- func CommandOutputContains(t *testing.T, ssmClient *ssm.Client, instanceID string, command string, ...)
- func DNSResolves(t *testing.T, ssmClient *ssm.Client, instanceID string, host string, ...)
- func DirectoryExists(t *testing.T, ssmClient *ssm.Client, instanceID string, path string)
- func FileContains(t *testing.T, ssmClient *ssm.Client, instanceID string, path string, ...)
- func FileContainsAs(t *testing.T, ssmClient *ssm.Client, instanceID string, user string, ...)
- func FileExecutable(t *testing.T, ssmClient *ssm.Client, instanceID string, path string)
- func FileExists(t *testing.T, ssmClient *ssm.Client, instanceID string, path string)
- func GroupExists(t *testing.T, ssmClient *ssm.Client, instanceID string, groupname string)
- func PackageInstalled(t *testing.T, ssmClient *ssm.Client, instanceID string, pkg string)
- func PathIsMount(t *testing.T, ssmClient *ssm.Client, instanceID string, path string)
- func PortReachable(t *testing.T, ssmClient *ssm.Client, instanceID string, host string, port int)
- func RunCommand(t *testing.T, ssmClient *ssm.Client, instanceID string, command string) string
- func RunCommandAs(t *testing.T, ssmClient *ssm.Client, instanceID string, user string, ...) string
- func ServiceDisabled(t *testing.T, ssmClient *ssm.Client, instanceID string, service string)
- func ServiceEnabled(t *testing.T, ssmClient *ssm.Client, instanceID string, service string)
- func ServiceRunning(t *testing.T, ssmClient *ssm.Client, instanceID string, service string)
- func UserExists(t *testing.T, ssmClient *ssm.Client, instanceID string, username string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandOutputContains ¶
func CommandOutputContains(t *testing.T, ssmClient *ssm.Client, instanceID string, command string, expected string)
CommandOutputContains asserts that a command output contains a specific string.
func DNSResolves ¶
func DNSResolves(t *testing.T, ssmClient *ssm.Client, instanceID string, host string, expectedIP string)
DNSResolves asserts that a hostname resolves to an IP.
func DirectoryExists ¶
DirectoryExists checks if a directory exists at the given path.
func FileContains ¶
func FileContains(t *testing.T, ssmClient *ssm.Client, instanceID string, path string, substr string)
FileContains asserts that a file contains a specific string.
func FileContainsAs ¶
func FileContainsAs(t *testing.T, ssmClient *ssm.Client, instanceID string, user string, path string, substr string)
FileContainsAs asserts that a file contains a specific string, as another user.
func FileExecutable ¶
FileExecutable checks if a file at the given path is executable.
func FileExists ¶
FileExists checks if a file exists at the given path.
func GroupExists ¶
GroupExists checks if a group exists.
func PackageInstalled ¶
PackageInstalled checks if a package is installed.
func PathIsMount ¶
PathIsMount checks if a path is a mount point.
func PortReachable ¶
PortReachable checks if a host and port are reachable from the EC2 instance.
func RunCommand ¶
RunCommand runs a command and returns the output.
func RunCommandAs ¶
func RunCommandAs(t *testing.T, ssmClient *ssm.Client, instanceID string, user string, command string) string
RunCommandAs runs a command as another user and returns the output.
func ServiceDisabled ¶
ServiceDisabled checks if a systemd service is disabled. The `|| true` guard is required because `systemctl is-enabled` exits non-zero for a disabled unit, which would otherwise be treated as a failed SSM command.
func ServiceEnabled ¶
ServiceEnabled checks if a systemd service is enabled.
func ServiceRunning ¶
ServiceRunning checks if a systemd service is running.
Types ¶
This section is empty.