Documentation
¶
Index ¶
- Constants
- Variables
- func ConditionExists(d *v1alpha1.Device, condType v1alpha1.ConditionType, ...) bool
- func ConditionStatusExists(conditions []v1alpha1.Condition, condType v1alpha1.ConditionType, ...) bool
- func GetDeviceConfig[T any](device *v1alpha1.Device, configType v1alpha1.ConfigProviderType, ...) (T, error)
- func GetRenderedVersion(device *v1alpha1.Device) (int, error)
- type ConsoleSession
- type Harness
- func (h *Harness) AddConfigToDeviceWithRetries(deviceId string, config v1alpha1.ConfigProviderSpec) error
- func (h *Harness) AddMultipleVMs(vmParamsList []vm.TestVM) ([]vm.TestVMInterface, error)
- func (h *Harness) AddVM(vmParams vm.TestVM) (vm.TestVMInterface, error)
- func (h *Harness) ApiEndpoint() string
- func (h *Harness) ApproveEnrollment(id string, approval *v1alpha1.EnrollmentRequestApproval)
- func (h *Harness) CLI(args ...string) (string, error)
- func (h *Harness) CLIWithStdin(stdin string, args ...string) (string, error)
- func (h *Harness) CheckApplicationComposeFileExist(applicationName string, ComposeFile string) error
- func (h *Harness) CheckApplicationDirectoryExist(applicationName string) error
- func (h Harness) CheckApplicationStatus(deviceId string, applicationName string) (v1alpha1.ApplicationStatusType, error)
- func (h *Harness) CheckDeviceStatus(deviceId string, status v1alpha1.DeviceSummaryStatusType) (*v1alpha1.Device, error)
- func (h *Harness) CheckEnvInjectedToApplication(envVarName string, image string) (string, error)
- func (h *Harness) CheckRunningContainers() (string, error)
- func (h *Harness) CleanUpAllResources() error
- func (h *Harness) CleanUpResources(resourceType string) (string, error)
- func (h *Harness) Cleanup(printConsole bool)
- func (h *Harness) CreateFleetDeviceSpec(deviceImageTag string, additionalConfigs ...v1alpha1.ConfigProviderSpec) (v1alpha1.DeviceSpec, error)
- func (h *Harness) CreateOrUpdateTestFleet(testFleetName string, fleetSpecOrSelector interface{}, ...) error
- func (h *Harness) CreateRepository(repositorySpec v1alpha1.RepositorySpec, metadata v1alpha1.ObjectMeta) error
- func (h *Harness) CreateTestFleetWithConfig(testFleetName string, testFleetSelector v1alpha1.LabelSelector, ...) error
- func (h *Harness) DeleteFleet(testFleetName string) error
- func (h *Harness) DeleteRepository(name string) error
- func (h *Harness) EnrollAndWaitForOnlineStatus() (string, *v1alpha1.Device)
- func (h *Harness) EnsureDeviceContents(deviceId string, description string, condition func(*v1alpha1.Device) bool, ...)
- func (h *Harness) FixNetworkFailure() error
- func (h *Harness) FixNetworkFailureForCLI(ip, port string) error
- func (h *Harness) GetCertificateSigningRequestByYaml(csrYaml string) v1alpha1.CertificateSigningRequest
- func (h *Harness) GetCurrentDeviceGeneration(deviceId string) (deviceRenderedVersionInt int64, err error)
- func (h *Harness) GetCurrentDeviceRenderedVersion(deviceId string) (int, error)
- func (h *Harness) GetDevice(deviceId string) (*v1alpha1.Device, error)
- func (h *Harness) GetDeviceByYaml(deviceYaml string) v1alpha1.Device
- func (h *Harness) GetDeviceGitConfig(device *v1alpha1.Device, configName string) (v1alpha1.GitConfigProviderSpec, error)
- func (h *Harness) GetDeviceHttpConfig(device *v1alpha1.Device, configName string) (v1alpha1.HttpConfigProviderSpec, error)
- func (h *Harness) GetDeviceInlineConfig(device *v1alpha1.Device, configName string) (v1alpha1.InlineConfigProviderSpec, error)
- func (h *Harness) GetDeviceOsImage(device *v1alpha1.Device) (image string, err error)
- func (h *Harness) GetDeviceSystemInfo(deviceID string) *v1alpha1.DeviceSystemInfo
- func (h *Harness) GetDeviceWithStatusSummary(enrollmentID string) (v1alpha1.DeviceSummaryStatusType, error)
- func (h *Harness) GetDeviceWithStatusSystem(enrollmentID string) (*apiclient.GetDeviceResponse, error)
- func (h *Harness) GetDeviceWithUpdateStatus(enrollmentID string) (v1alpha1.DeviceUpdatedStatusType, error)
- func (h *Harness) GetEnrollmentIDFromConsole(vms ...vm.TestVMInterface) string
- func (h *Harness) GetEnrollmentRequestByYaml(erYaml string) *v1alpha1.EnrollmentRequest
- func (h *Harness) GetFleet(fleetName string) (*v1alpha1.Fleet, error)
- func (h *Harness) GetFleetByYaml(fleetYaml string) v1alpha1.Fleet
- func (h *Harness) GetRepositoryByYaml(repoYaml string) v1alpha1.Repository
- func (h *Harness) GetResourceSyncByYaml(rSyncYaml string) v1alpha1.ResourceSync
- func (h *Harness) GetResourcesByName(resourceType string, resourceName ...string) (string, error)
- func (h *Harness) GetRolloutStatus(fleetName string) (v1alpha1.Condition, error)
- func (h *Harness) GetSelectedDevicesForBatch(fleetName string) ([]*v1alpha1.Device, error)
- func (h *Harness) GetUnavailableDevicesPerGroup(fleetName string, groupBy []string) (map[string][]*v1alpha1.Device, error)
- func (h *Harness) GetUpdatedDevices(fleetName string) ([]*v1alpha1.Device, error)
- func (h *Harness) ManageResource(operation, resource string, args ...string) (string, error)
- func (h *Harness) MarkClientAccessTokenExpired(filePath string) error
- func (h *Harness) NewConsoleSession(deviceID string) *ConsoleSession
- func (h *Harness) PrepareNextDeviceGeneration(deviceId string) (int64, error)
- func (h *Harness) PrepareNextDeviceVersion(deviceId string) (int, error)
- func (h *Harness) ReadClientConfig(filePath string) (*client.Config, error)
- func (h *Harness) ReadPrimaryVMAgentLogs(since string) (string, error)
- func (h *Harness) RegistryEndpoint() string
- func (h *Harness) ReplaceRepository(repositorySpec v1alpha1.RepositorySpec, metadata v1alpha1.ObjectMeta) error
- func (h *Harness) ReplaceVariableInString(s string, old string, new string) string
- func (h *Harness) ResetAgent() error
- func (h *Harness) RunConsoleCommand(deviceID string, flags []string, cmd ...string) (string, error)
- func (h *Harness) RunGetDevices(args ...string) (string, error)
- func (h *Harness) RunGetEvents(args ...string) (string, error)
- func (h *Harness) RunInteractiveCLI(args ...string) (io.WriteCloser, io.ReadCloser, error)
- func (h *Harness) SH(command string, args ...string) (string, error)
- func (h *Harness) SHWithStdin(stdin, command string, args ...string) (string, error)
- func (h *Harness) SetLabelsForDevice(deviceId string, labels map[string]string) error
- func (h *Harness) SetLabelsForDevicesByIndex(deviceIDs []string, labelsList []map[string]string, fleetName string) error
- func (h *Harness) SimulateNetworkFailure() error
- func (h *Harness) SimulateNetworkFailureForCLI(ip, port string) (func() error, error)
- func (h *Harness) StartMultipleVMAndEnroll(count int) ([]string, error)
- func (h *Harness) StartVMAndEnroll() string
- func (h *Harness) UpdateApplication(withRetries bool, deviceId string, appName string, appProvider any, ...) error
- func (h *Harness) UpdateDevice(deviceId string, updateFunction func(*v1alpha1.Device)) error
- func (h *Harness) UpdateDeviceConfigWithRetries(deviceId string, configs []v1alpha1.ConfigProviderSpec, ...) error
- func (h *Harness) UpdateDeviceWithRetries(deviceId string, updateFunction func(*v1alpha1.Device)) error
- func (h *Harness) UpdateFleet(fleetName string, updateFunc func(*v1alpha1.Fleet)) error
- func (h *Harness) UpdateFleetWithRetries(fleetName string, updateFunction func(*v1alpha1.Fleet))
- func (h *Harness) WaitForBatchStart(fleetName string, batchNumber int)
- func (h *Harness) WaitForBootstrapAndUpdateToVersion(deviceId string, version string) (*v1alpha1.Device, string, error)
- func (h *Harness) WaitForClusterRegistered(deviceId string, timeout time.Duration) error
- func (h *Harness) WaitForDeviceContents(deviceId string, description string, condition func(*v1alpha1.Device) bool, ...)
- func (h *Harness) WaitForDeviceNewGeneration(deviceId string, newGeneration int64) (err error)
- func (h *Harness) WaitForDeviceNewRenderedVersion(deviceId string, newRenderedVersionInt int) (err error)
- func (h *Harness) WaitForEnrollmentRequest(id string) *v1alpha1.EnrollmentRequest
- func (h *Harness) WaitForFileInDevice(filePath string, timeout string, polling string) (*bytes.Buffer, error)
- func (h *Harness) WaitForFleetContents(fleetName string, description string, ...)
- func (h *Harness) WaitForFleetUpdateToFail(fleetName string) error
Constants ¶
const LONGTIMEOUT = "10m"
const POLLING = "250ms"
const POLLINGLONG = "1s"
const TIMEOUT = "60s"
Variables ¶
var (
InvalidRenderedVersionErr = fmt.Errorf("invalid rendered version")
)
Functions ¶
func ConditionExists ¶ added in v0.7.0
func ConditionExists(d *v1alpha1.Device, condType v1alpha1.ConditionType, condStatus v1alpha1.ConditionStatus, condReason string) bool
ConditionExists checks if a specific condition exists for the device with the given type, status, and reason.
func ConditionStatusExists ¶ added in v0.9.0
func ConditionStatusExists(conditions []v1alpha1.Condition, condType v1alpha1.ConditionType, status v1alpha1.ConditionStatus) bool
ConditionStatusExists returns true if the specified type and status exists on the condition slice
func GetDeviceConfig ¶ added in v0.6.0
func GetDeviceConfig[T any](device *v1alpha1.Device, configType v1alpha1.ConfigProviderType, asConfig func(v1alpha1.ConfigProviderSpec) (T, error)) (T, error)
GetDeviceConfig is a generic helper function to retrieve device configurations
Types ¶
type ConsoleSession ¶ added in v0.9.0
type ConsoleSession struct {
Stdin io.WriteCloser
Stdout *Buffer
}
ConsoleSession represents a PTY console session to a device
func (*ConsoleSession) Close ¶ added in v0.9.0
func (cs *ConsoleSession) Close()
Close terminates the console session
func (*ConsoleSession) MustExpect ¶ added in v0.9.0
func (cs *ConsoleSession) MustExpect(pattern string)
MustExpect waits for a pattern to appear in the console output
func (*ConsoleSession) MustSend ¶ added in v0.9.0
func (cs *ConsoleSession) MustSend(cmd string)
MustSend sends a command to the console session
type Harness ¶
type Harness struct {
VMs []vm.TestVMInterface
Client *apiclient.ClientWithResponses
Context context.Context
Cluster kubernetes.Interface
VM vm.TestVMInterface
// contains filtered or unexported fields
}
func NewTestHarness ¶
func (*Harness) AddConfigToDeviceWithRetries ¶ added in v0.9.0
func (h *Harness) AddConfigToDeviceWithRetries(deviceId string, config v1alpha1.ConfigProviderSpec) error
func (*Harness) AddMultipleVMs ¶ added in v0.8.1
func (*Harness) ApiEndpoint ¶
func (*Harness) ApproveEnrollment ¶
func (h *Harness) ApproveEnrollment(id string, approval *v1alpha1.EnrollmentRequestApproval)
func (*Harness) CLIWithStdin ¶
func (*Harness) CheckApplicationComposeFileExist ¶ added in v0.8.0
func (*Harness) CheckApplicationDirectoryExist ¶ added in v0.8.0
func (Harness) CheckApplicationStatus ¶ added in v0.8.0
func (*Harness) CheckDeviceStatus ¶ added in v0.6.0
func (h *Harness) CheckDeviceStatus(deviceId string, status v1alpha1.DeviceSummaryStatusType) (*v1alpha1.Device, error)
Check that the device summary status is equal to the status input
func (*Harness) CheckEnvInjectedToApplication ¶ added in v0.8.0
func (*Harness) CheckRunningContainers ¶ added in v0.7.0
CheckRunningContainers verifies the expected number of running containers on the VM.
func (*Harness) CleanUpAllResources ¶ added in v0.4.0
func (*Harness) CleanUpResources ¶ added in v0.4.0
func (*Harness) Cleanup ¶
Harness cleanup, this will delete the VM and cancel the context if something failed we try to gather logs, console logs are optional and can be enabled by setting printConsole to true
func (*Harness) CreateFleetDeviceSpec ¶ added in v0.8.1
func (h *Harness) CreateFleetDeviceSpec(deviceImageTag string, additionalConfigs ...v1alpha1.ConfigProviderSpec) (v1alpha1.DeviceSpec, error)
func (*Harness) CreateOrUpdateTestFleet ¶ added in v0.6.0
func (h *Harness) CreateOrUpdateTestFleet(testFleetName string, fleetSpecOrSelector interface{}, deviceSpec ...v1alpha1.DeviceSpec) error
Create a test fleet resource
func (*Harness) CreateRepository ¶ added in v0.6.0
func (h *Harness) CreateRepository(repositorySpec v1alpha1.RepositorySpec, metadata v1alpha1.ObjectMeta) error
Create a repository resource
func (*Harness) CreateTestFleetWithConfig ¶ added in v0.6.0
func (h *Harness) CreateTestFleetWithConfig(testFleetName string, testFleetSelector v1alpha1.LabelSelector, configProviderSpec v1alpha1.ConfigProviderSpec) error
Create a test fleet with a configuration
func (*Harness) DeleteFleet ¶ added in v0.9.0
func (*Harness) DeleteRepository ¶ added in v0.9.0
DeleteRepository deletes the specified repository
func (*Harness) EnrollAndWaitForOnlineStatus ¶ added in v0.4.0
func (*Harness) EnsureDeviceContents ¶ added in v0.9.0
func (h *Harness) EnsureDeviceContents(deviceId string, description string, condition func(*v1alpha1.Device) bool, timeout string)
EnsureDeviceContents ensures that the contents of the device match the specified condition for the entire timeout
func (*Harness) FixNetworkFailure ¶ added in v0.8.1
func (*Harness) FixNetworkFailureForCLI ¶ added in v0.8.1
FixNetworkFailureForCLI removes an entry from iptables if it exists. returns an error if no entry for the ip:port combo exists
func (*Harness) GetCertificateSigningRequestByYaml ¶ added in v0.4.0
func (h *Harness) GetCertificateSigningRequestByYaml(csrYaml string) v1alpha1.CertificateSigningRequest
Wrapper function for CertificateSigningRequest
func (*Harness) GetCurrentDeviceGeneration ¶ added in v0.6.0
func (*Harness) GetCurrentDeviceRenderedVersion ¶ added in v0.4.0
func (*Harness) GetDeviceByYaml ¶ added in v0.4.0
Wrapper function for Device
func (*Harness) GetDeviceGitConfig ¶ added in v0.6.0
func (h *Harness) GetDeviceGitConfig(device *v1alpha1.Device, configName string) (v1alpha1.GitConfigProviderSpec, error)
Get GitConfig
func (*Harness) GetDeviceHttpConfig ¶ added in v0.6.0
func (h *Harness) GetDeviceHttpConfig(device *v1alpha1.Device, configName string) (v1alpha1.HttpConfigProviderSpec, error)
Get HttpConfig
func (*Harness) GetDeviceInlineConfig ¶ added in v0.6.0
func (h *Harness) GetDeviceInlineConfig(device *v1alpha1.Device, configName string) (v1alpha1.InlineConfigProviderSpec, error)
Get InlineConfig
func (*Harness) GetDeviceOsImage ¶ added in v0.6.0
Get an http config of a device resource
func (*Harness) GetDeviceSystemInfo ¶ added in v0.9.0
func (h *Harness) GetDeviceSystemInfo(deviceID string) *v1alpha1.DeviceSystemInfo
GetDeviceSystemInfo returns the device system info with proper error handling
func (*Harness) GetDeviceWithStatusSummary ¶ added in v0.4.0
func (h *Harness) GetDeviceWithStatusSummary(enrollmentID string) (v1alpha1.DeviceSummaryStatusType, error)
func (*Harness) GetDeviceWithStatusSystem ¶
func (h *Harness) GetDeviceWithStatusSystem(enrollmentID string) (*apiclient.GetDeviceResponse, error)
func (*Harness) GetDeviceWithUpdateStatus ¶ added in v0.4.0
func (h *Harness) GetDeviceWithUpdateStatus(enrollmentID string) (v1alpha1.DeviceUpdatedStatusType, error)
func (*Harness) GetEnrollmentIDFromConsole ¶
func (h *Harness) GetEnrollmentIDFromConsole(vms ...vm.TestVMInterface) string
func (*Harness) GetEnrollmentRequestByYaml ¶ added in v0.4.0
func (h *Harness) GetEnrollmentRequestByYaml(erYaml string) *v1alpha1.EnrollmentRequest
Wrapper function for EnrollmentRequest
func (*Harness) GetFleetByYaml ¶ added in v0.4.0
Wrapper function for Fleet
func (*Harness) GetRepositoryByYaml ¶ added in v0.4.0
func (h *Harness) GetRepositoryByYaml(repoYaml string) v1alpha1.Repository
Wrapper function for Repository
func (*Harness) GetResourceSyncByYaml ¶ added in v0.4.0
func (h *Harness) GetResourceSyncByYaml(rSyncYaml string) v1alpha1.ResourceSync
Wrapper function for ResourceSync
func (*Harness) GetResourcesByName ¶ added in v0.8.1
Wrapper function for Shell command to get resources by name
func (*Harness) GetRolloutStatus ¶ added in v0.8.1
func (*Harness) GetSelectedDevicesForBatch ¶ added in v0.8.1
func (*Harness) GetUnavailableDevicesPerGroup ¶ added in v0.8.1
func (*Harness) GetUpdatedDevices ¶ added in v0.8.1
func (*Harness) ManageResource ¶ added in v0.7.0
ManageResource performs an operation ("apply", "delete", or "approve") on a specified resource.
func (*Harness) MarkClientAccessTokenExpired ¶ added in v0.8.1
MarkClientAccessTokenExpired updates the client configuration at the specified path by marking the token as expired If no path is supplied, the default config path will be used
func (*Harness) NewConsoleSession ¶ added in v0.9.0
func (h *Harness) NewConsoleSession(deviceID string) *ConsoleSession
NewConsoleSession starts a PTY console session to the specified device.
func (*Harness) PrepareNextDeviceGeneration ¶ added in v0.6.0
func (*Harness) PrepareNextDeviceVersion ¶ added in v0.4.0
func (*Harness) ReadClientConfig ¶ added in v0.8.1
ReadClientConfig returns the client config for at the specified location. The default config path is used if no path is specified
func (*Harness) ReadPrimaryVMAgentLogs ¶ added in v0.9.0
ReadPrimaryVMAgentLogs reads flightctl-agent journalctl logs from the primary VM
func (*Harness) RegistryEndpoint ¶ added in v0.4.0
func (*Harness) ReplaceRepository ¶ added in v0.9.0
func (h *Harness) ReplaceRepository(repositorySpec v1alpha1.RepositorySpec, metadata v1alpha1.ObjectMeta) error
ReplaceRepository ensures the specified repository exists and is updated to the appropriate values
func (*Harness) ReplaceVariableInString ¶ added in v0.4.0
func (*Harness) RunConsoleCommand ¶ added in v0.9.0
RunConsoleCommand executes the flightctl console command for the given device.
flags – optional CLI flags that go before "--" (e.g. "--notty").
cmd – remote command (and its args) to execute after "--". Must contain
at least one string; for interactive sessions use NewConsoleSession.
func (*Harness) RunGetDevices ¶ added in v0.7.0
RunGetDevices executes "get devices" CLI command with optional arguments.
func (*Harness) RunGetEvents ¶ added in v0.8.1
RunGetEvents executes "get events" CLI command with optional arguments.
func (*Harness) RunInteractiveCLI ¶
func (h *Harness) RunInteractiveCLI(args ...string) (io.WriteCloser, io.ReadCloser, error)
func (*Harness) SHWithStdin ¶ added in v0.3.0
func (*Harness) SetLabelsForDevice ¶ added in v0.9.0
func (*Harness) SetLabelsForDevicesByIndex ¶ added in v0.8.1
func (*Harness) SimulateNetworkFailure ¶ added in v0.8.1
func (*Harness) SimulateNetworkFailureForCLI ¶ added in v0.8.1
SimulateNetworkFailureForCLI adds an entry to iptables to drop tcp traffic to the specified port:ip It returns a function that will only execute once to undo the iptables modification
func (*Harness) StartMultipleVMAndEnroll ¶ added in v0.8.1
func (*Harness) StartVMAndEnroll ¶
func (*Harness) UpdateApplication ¶ added in v0.8.0
func (*Harness) UpdateDevice ¶ added in v0.6.0
func (*Harness) UpdateDeviceConfigWithRetries ¶ added in v0.8.1
func (h *Harness) UpdateDeviceConfigWithRetries(deviceId string, configs []v1alpha1.ConfigProviderSpec, nextRenderedVersion int) error
UpdateDeviceConfigWithRetries updates the configuration of a device with retries using the provided harness and config specs. It applies the provided configuration and waits for the device to reach the specified rendered version.
func (*Harness) UpdateDeviceWithRetries ¶ added in v0.3.0
func (*Harness) UpdateFleet ¶ added in v0.9.0
func (*Harness) UpdateFleetWithRetries ¶ added in v0.9.0
func (*Harness) WaitForBatchStart ¶ added in v0.8.1
func (*Harness) WaitForBootstrapAndUpdateToVersion ¶ added in v0.4.0
func (*Harness) WaitForClusterRegistered ¶ added in v0.8.1
func (*Harness) WaitForDeviceContents ¶ added in v0.3.0
func (*Harness) WaitForDeviceNewGeneration ¶ added in v0.6.0
func (*Harness) WaitForDeviceNewRenderedVersion ¶ added in v0.4.0
func (*Harness) WaitForEnrollmentRequest ¶
func (h *Harness) WaitForEnrollmentRequest(id string) *v1alpha1.EnrollmentRequest