Documentation
¶
Index ¶
- Constants
- Variables
- func AreFlightCtlServicesHealthy(ctx string) bool
- func AreFlightCtlServicesHealthyKubernetes(mainNamespace, workerNamespace string) bool
- func AreFlightCtlServicesHealthyPodman() bool
- func BinaryExistsOnPath(binaryName string) bool
- func CanConnectToRedis(ctx string) bool
- func CleanupTempYAMLFile(tempFilePath string)
- func CleanupTempYAMLFiles(tempFilePaths []string)
- func CreateRepositories(ctx context.Context, numRepositories int, storeInst store.Store, ...) error
- func CreateTestAuthProvider(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, ...)
- func CreateTestAuthProviderWithDynamicOrg(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, ...)
- func CreateTestAuthProviderWithPerUserOrg(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, ...)
- func CreateTestAuthProviderWithStaticOrg(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, ...)
- func CreateTestAuthProviders(ctx context.Context, numProviders int, authStore store.AuthProvider, ...)
- func CreateTestAuthProvidersWithOffset(ctx context.Context, numProviders int, authStore store.AuthProvider, ...)
- func CreateTestDevice(ctx context.Context, deviceStore store.Device, orgId uuid.UUID, name string, ...)
- func CreateTestDevices(ctx context.Context, numDevices int, deviceStore store.Device, orgId uuid.UUID, ...)
- func CreateTestDevicesWithOffset(ctx context.Context, numDevices int, deviceStore store.Device, orgId uuid.UUID, ...)
- func CreateTestEnrolmentRequests(numEnrollmentRequests int, ctx context.Context, store store.Store, ...)
- func CreateTestFleet(ctx context.Context, fleetStore store.Fleet, orgId uuid.UUID, name string, ...)
- func CreateTestFleets(ctx context.Context, numFleets int, fleetStore store.Fleet, orgId uuid.UUID, ...)
- func CreateTestOrganization(ctx context.Context, storeInst store.Store, orgId uuid.UUID) error
- func CreateTestOrganizationAssignment() api.AuthOrganizationAssignment
- func CreateTestResourceSyncs(ctx context.Context, numResourceSyncs int, storeInst store.Store, ...)
- func CreateTestTemplateVersion(ctx context.Context, tvStore store.TemplateVersion, orgId uuid.UUID, ...) error
- func CreateTestTemplateVersions(ctx context.Context, numTemplateVersions int, tvStore store.TemplateVersion, ...) error
- func CreateUniqueYAMLFile(originalYAMLPath, testID string) (string, error)
- func DetectRedisNamespace() string
- func EventuallySlow(actual any) types.AsyncAssertion
- func GetCurrentYearBounds() (string, string)
- func GetEnrollmentIdFromText(text string) string
- func GetExtIP() string
- func GetJournalLogs(serviceName string, since string) (string, error)
- func GetRedisClient(ctx string) *redis.Client
- func GetRedisPassword(ctx string) string
- func GetScriptPath(script string) string
- func GetSystemdStatus(pattern string) (string, error)
- func GetTestExamplesYamlPath(yamlName string) string
- func GetTopLevelDir() string
- func InitLogsWithDebug() *logrus.Logger
- func InitSuiteTracerForGinkgo(description string) context.Context
- func InitTracerForTests() func(context.Context) error
- func IsAcmInstalled() (bool, bool, error)
- func IsRPMInstalled(packageName string) (bool, string, error)
- func IsRedisRunning(ctx string) bool
- func IsRedisRunningKubernetes(namespace string) bool
- func IsRedisRunningPodman() bool
- func ListSystemdUnits(pattern string) ([]string, error)
- func NewAgentClient(serverUrl string, caBundle []*x509.Certificate, ...) (*agentclient.ClientWithResponses, error)
- func NewBackoff() wait.Backoff
- func NewBareHTTPsClient(caBundle []*x509.Certificate, clientCert *crypto.TLSCertificateConfig) (*http.Client, error)
- func NewClient(serverUrl string, caBundle []*x509.Certificate) (*client.ClientWithResponses, error)
- func NewComposeSpec(images ...string) string
- func NewPollConfig() poll.Config
- func NewTestAgentServer(ctx context.Context, log logrus.FieldLogger, cfg *config.Config, ...) (*agentserver.AgentServer, net.Listener, error)
- func NewTestApiServer(log logrus.FieldLogger, cfg *config.Config, store store.Store, ...) (*apiserver.Server, net.Listener, error)
- func NewTestCerts(cfg *config.Config) (*crypto.CAClient, *crypto.TLSCertificateConfig, *crypto.TLSCertificateConfig, ...)
- func NewTestProvider(log logrus.FieldLogger) queues.Provider
- func NewTestStore(ctx context.Context, cfg config.Config, log *logrus.Logger) (store.Store, string, error)
- func ParseURIForIPAndPort(rawURI string) (string, string, error)
- func RandString(n int) (string, error)
- func RestartRedis(ctx, namespace string) error
- func RestartRedisKubernetes(namespace string) error
- func RestartRedisPodman() error
- func ReturnTestAuthProvider(orgId uuid.UUID, name string, issuer string, labels *map[string]string) api.AuthProvider
- func ReturnTestDevice(orgId uuid.UUID, name string, owner *string, tv *string, ...) api.Device
- func RunTable[T any](cases []TestCase[T], runFunc func(T))
- func StartRedis(ctx, namespace string) error
- func StartRedisKubernetes(namespace string) error
- func StartRedisPodman() error
- func StartSpecTracerForGinkgo(parent context.Context) context.Context
- func StopRedis(ctx, namespace string) error
- func StopRedisKubernetes(namespace string) error
- func StopRedisPodman() error
- func SystemdUnitExists(unitName string) (bool, error)
- func TestEnrollmentApproval() *v1beta1.EnrollmentRequestApproval
- func TestTempEnv(key, value string) func()
- func VerifyRedisRecovery(ctx, namespace string) bool
- func WaitForRedisPodReady(namespace string, timeout time.Duration) bool
- func WaitForRedisReady(ctx, namespace string, timeout time.Duration) bool
- func WaitForServiceReady(serviceName string, timeout time.Duration) error
- type DeviceIDKeyType
- type DeviceKeyType
- type Message
- type QueueState
- type TestCase
- type TestContextKeyType
- type TestIDKeyType
- type TestOrgCache
Constants ¶
const ( Device = "device" Fleet = "fleet" EnrollmentRequest = "enrollmentrequest" Repository = "repository" ResourceSync = "resourcesync" CertificateSigningRequest = "certificatesigningrequest" //resource related ApplyAction = "apply" DenyAction = "deny" DeviceResource = "Device" RepoResource = "Repository" ErResource = "EnrollmentRequest" FleetResource = "Fleet" SystemResource = "System" //example yaml names DeviceYAMLName = "device.yaml" FleetYAMLName = "fleet.yaml" FleetBYAMLName = "fleet-b.yaml" RepoYAMLName = "repository-flightctl.yaml" ErYAMLName = "enrollmentrequest.yaml" // events ForceFlag = "-f" EventCreated = "created" EventDeleted = "deleted" EventUpdated = "updated" //Event reasons ResourceCreated = "ResourceCreated" DeviceApplicationError = "DeviceApplicationError" DeviceApplicationHealthy = "DeviceApplicationHealthy" DeviceSpecInvalid = "DeviceSpecInvalid" DeviceSpecValid = "DeviceSpecValid" DeviceContentOutOfDate = "DeviceContentOutOfDate" DeviceContentUpToDate = "DeviceContentUpToDate" DeviceUpdateFailed = "DeviceUpdateFailed" // Eventually polling timeout/interval constants TIMEOUT = time.Minute LONG_TIMEOUT = 10 * time.Minute POLLING = time.Second LONG_POLLING = 10 * time.Second DURATION_TIMEOUT = 5 * time.Minute SHORT_POLLING = "250ms" TIMEOUT_5M = "5m" LONGTIMEOUT = "10m" )
Resource types
const E2E_NAMESPACE = "flightctl-e2e"
const E2E_REGISTRY_NAME = "registry"
const FLIGHTCTL_AGENT_SERVICE = "flightctl-agent"
const KIND = "KIND"
const OCP = "OCP"
Variables ¶
var ( DeviceIDKey = DeviceIDKeyType{} DeviceKey = DeviceKeyType{} TestContextKey = TestContextKeyType{} )
var DefaultSystemInfo = []string{
"hostname",
"kernel",
"distroName",
"distroVersion",
"productName",
"productUuid",
"productSerial",
"netInterfaceDefault",
"netIpDefault",
"netMacDefault",
}
RequiredSystemInfoKeys defines the required system info keys that should be present
var ResourceTypes = [...]string{ ResourceSync, Fleet, Device, EnrollmentRequest, Repository, CertificateSigningRequest, }
var TestIDKey = TestIDKeyType{}
Functions ¶
func AreFlightCtlServicesHealthy ¶ added in v1.0.0
AreFlightCtlServicesHealthy checks if FlightCtl services are healthy ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func AreFlightCtlServicesHealthyKubernetes ¶ added in v1.0.0
AreFlightCtlServicesHealthyKubernetes checks if FlightCtl services are healthy in kubernetes mode mainNamespace is where flightctl-api is deployed, workerNamespace is where flightctl-worker is deployed
func AreFlightCtlServicesHealthyPodman ¶ added in v1.0.0
func AreFlightCtlServicesHealthyPodman() bool
AreFlightCtlServicesHealthyPodman checks if FlightCtl services are healthy in podman mode
func BinaryExistsOnPath ¶ added in v0.8.1
func CanConnectToRedis ¶ added in v1.0.0
CanConnectToRedis checks if we can connect to Redis ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func CleanupTempYAMLFile ¶ added in v0.10.0
func CleanupTempYAMLFile(tempFilePath string)
CleanupTempYAMLFile removes the temporary YAML file
func CleanupTempYAMLFiles ¶ added in v0.10.0
func CleanupTempYAMLFiles(tempFilePaths []string)
CleanupTempYAMLFiles removes multiple temporary YAML files
func CreateRepositories ¶
func CreateTestAuthProvider ¶ added in v1.0.0
func CreateTestAuthProvider(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, name string, issuer string, labels *map[string]string)
CreateTestAuthProvider creates a test auth provider in the store
func CreateTestAuthProviderWithDynamicOrg ¶ added in v1.0.0
func CreateTestAuthProviderWithDynamicOrg(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, name string)
CreateTestAuthProviderWithDynamicOrg creates a test OIDC provider with dynamic organization assignment
func CreateTestAuthProviderWithPerUserOrg ¶ added in v1.0.0
func CreateTestAuthProviderWithPerUserOrg(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, name string, prefix *string, suffix *string)
CreateTestAuthProviderWithPerUserOrg creates a test OIDC provider with per-user organization assignment
func CreateTestAuthProviderWithStaticOrg ¶ added in v1.0.0
func CreateTestAuthProviderWithStaticOrg(ctx context.Context, authStore store.AuthProvider, orgId uuid.UUID, name string, orgName string)
CreateTestAuthProviderWithStaticOrg creates a test OIDC provider with static organization assignment
func CreateTestAuthProviders ¶ added in v1.0.0
func CreateTestAuthProviders(ctx context.Context, numProviders int, authStore store.AuthProvider, orgId uuid.UUID, sameVals bool)
CreateTestAuthProviders creates multiple test auth providers
func CreateTestAuthProvidersWithOffset ¶ added in v1.0.0
func CreateTestAuthProvidersWithOffset(ctx context.Context, numProviders int, authStore store.AuthProvider, orgId uuid.UUID, sameVals bool, offset int)
CreateTestAuthProvidersWithOffset creates multiple test OIDC providers with an offset
func CreateTestDevice ¶
func CreateTestDevices ¶
func CreateTestEnrolmentRequests ¶ added in v0.8.1
func CreateTestFleet ¶
func CreateTestFleets ¶
func CreateTestOrganization ¶ added in v0.9.0
func CreateTestOrganizationAssignment ¶ added in v1.0.0
func CreateTestOrganizationAssignment() api.AuthOrganizationAssignment
CreateTestOrganizationAssignment creates a test organization assignment
func CreateTestResourceSyncs ¶ added in v0.8.1
func CreateTestTemplateVersion ¶
func CreateTestTemplateVersion(ctx context.Context, tvStore store.TemplateVersion, orgId uuid.UUID, fleet, name string, status *api.TemplateVersionStatus) error
func CreateUniqueYAMLFile ¶ added in v0.10.0
CreateUniqueYAMLFile creates a temporary YAML file with unique resource names based on test ID
func DetectRedisNamespace ¶ added in v1.0.0
func DetectRedisNamespace() string
DetectRedisNamespace tries to find the namespace where Redis (flightctl-kv) is deployed This is exported so tests can use it to get the correct namespace
func EventuallySlow ¶ added in v0.10.0
func EventuallySlow(actual any) types.AsyncAssertion
func GetCurrentYearBounds ¶ added in v0.7.0
GetCurrentYearBounds returns start of current and next year in RFC3339 format.
func GetEnrollmentIdFromText ¶ added in v0.2.0
GetEnrollmentIdFromText returns the enrollment ID from the given text. The enrollment ID is expected to be part of url path like https://example.com/enroll/1234
func GetJournalLogs ¶ added in v1.0.0
GetJournalLogs retrieves systemd journal logs for a service
func GetRedisClient ¶ added in v1.0.0
GetRedisClient creates a Redis client connection ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func GetRedisPassword ¶ added in v1.0.0
GetRedisPassword gets Redis password from environment, Kubernetes secret, or default ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func GetScriptPath ¶
func GetSystemdStatus ¶ added in v1.0.0
GetSystemdStatus gets the status of systemd units matching a pattern
func GetTestExamplesYamlPath ¶ added in v0.6.0
func GetTopLevelDir ¶
func GetTopLevelDir() string
func InitLogsWithDebug ¶ added in v1.0.0
InitLogsWithDebug creates a logger with debug level if LOG_LEVEL=debug is set
func InitSuiteTracerForGinkgo ¶ added in v0.8.1
func InitTracerForTests ¶ added in v0.8.1
func IsAcmInstalled ¶ added in v0.10.0
IsAcmInstalled checks if ACM is installed and if it is running. returns: isAcmInstalled, isAcmRunning, error
func IsRPMInstalled ¶ added in v1.0.0
IsRPMInstalled checks if an RPM package is installed and returns its version
func IsRedisRunning ¶ added in v1.0.0
IsRedisRunning checks if Redis is running ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func IsRedisRunningKubernetes ¶ added in v1.0.0
IsRedisRunningKubernetes checks if Redis is running in kubernetes mode
func IsRedisRunningPodman ¶ added in v1.0.0
func IsRedisRunningPodman() bool
IsRedisRunningPodman checks if Redis is running in podman mode
func ListSystemdUnits ¶ added in v1.0.0
ListSystemdUnits lists all systemd units matching a pattern
func NewAgentClient ¶
func NewAgentClient(serverUrl string, caBundle []*x509.Certificate, clientCert *crypto.TLSCertificateConfig) (*agentclient.ClientWithResponses, error)
NewClient creates a new client with the given server URL and certificates. If the certs are nil a http client will be created.
func NewBackoff ¶ added in v0.6.0
func NewBareHTTPsClient ¶
func NewBareHTTPsClient(caBundle []*x509.Certificate, clientCert *crypto.TLSCertificateConfig) (*http.Client, error)
func NewClient ¶
func NewClient(serverUrl string, caBundle []*x509.Certificate) (*client.ClientWithResponses, error)
NewClient creates a new client with the given server URL and certificates. If the certs are nil a http client will be created.
func NewComposeSpec ¶ added in v0.6.0
func NewPollConfig ¶ added in v0.9.0
func NewTestAgentServer ¶
func NewTestAgentServer(ctx context.Context, log logrus.FieldLogger, cfg *config.Config, store store.Store, ca *crypto.CAClient, serverCerts *crypto.TLSCertificateConfig, queuesProvider queues.Provider) (*agentserver.AgentServer, net.Listener, error)
NewTestAgentServer creates a new test server and returns the server and the listener listening on localhost's next available port.
func NewTestApiServer ¶
func NewTestApiServer(log logrus.FieldLogger, cfg *config.Config, store store.Store, ca *crypto.CAClient, serverCerts *crypto.TLSCertificateConfig, queuesProvider queues.Provider) (*apiserver.Server, net.Listener, error)
NewTestApiServer creates a new test server and returns the server and the listener listening on localhost's next available port.
func NewTestCerts ¶
func NewTestCerts(cfg *config.Config) (*crypto.CAClient, *crypto.TLSCertificateConfig, *crypto.TLSCertificateConfig, error)
NewTestCerts creates new test certificates in the service certstore and returns the CA, server certificate, and enrollment certificate.
func NewTestProvider ¶
func NewTestProvider(log logrus.FieldLogger) queues.Provider
func NewTestStore ¶
func NewTestStore(ctx context.Context, cfg config.Config, log *logrus.Logger) (store.Store, string, error)
NewTestStore creates a new test store and returns the store and the database name.
func ParseURIForIPAndPort ¶ added in v0.8.1
ParseURIForIPAndPort parses a string URI and attempts to extract the IP address and port. It handles URIs with or without a scheme. If no port is specified, it attempts to deduce it from common schemes (http: 80, https: 443). If no scheme is supplied, http is assumed
func RandString ¶ added in v0.7.0
RandString generates a random string of length 'n' using lowercase alphabetic characters.
func RestartRedis ¶ added in v1.0.0
RestartRedis restarts Redis based on context ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func RestartRedisKubernetes ¶ added in v1.0.0
RestartRedisKubernetes restarts Redis in kubernetes mode
func RestartRedisPodman ¶ added in v1.0.0
func RestartRedisPodman() error
RestartRedisPodman restarts Redis in podman mode
func ReturnTestAuthProvider ¶ added in v1.0.0
func ReturnTestAuthProvider(orgId uuid.UUID, name string, issuer string, labels *map[string]string) api.AuthProvider
ReturnTestAuthProvider creates a test auth provider with the given parameters
func ReturnTestDevice ¶ added in v0.3.0
func RunTable ¶ added in v0.8.1
RunTable executes the provided run function for each test case in the cases slice.
func StartRedis ¶ added in v1.0.0
StartRedis starts Redis based on context ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func StartRedisKubernetes ¶ added in v1.0.0
StartRedisKubernetes starts Redis in kubernetes mode
func StartRedisPodman ¶ added in v1.0.0
func StartRedisPodman() error
StartRedisPodman starts Redis in podman mode
func StartSpecTracerForGinkgo ¶ added in v0.8.1
func StopRedis ¶ added in v1.0.0
StopRedis stops Redis based on context ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func StopRedisKubernetes ¶ added in v1.0.0
StopRedisKubernetes stops Redis in kubernetes mode
func StopRedisPodman ¶ added in v1.0.0
func StopRedisPodman() error
StopRedisPodman stops Redis in podman mode
func SystemdUnitExists ¶ added in v1.0.0
SystemdUnitExists checks if a systemd unit exists
func TestEnrollmentApproval ¶
func TestEnrollmentApproval() *v1beta1.EnrollmentRequestApproval
func TestTempEnv ¶
func TestTempEnv(key, value string) func()
TestTempEnv sets the environment variable key to value and returns a function that will reset the environment variable to its original value.
func VerifyRedisRecovery ¶ added in v1.0.0
VerifyRedisRecovery verifies that Redis and services have recovered after restart ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func WaitForRedisPodReady ¶ added in v1.0.0
WaitForRedisPodReady waits for Redis pod to be ready in kubernetes
func WaitForRedisReady ¶ added in v1.0.0
WaitForRedisReady waits for Redis to be ready after restart/start ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
Types ¶
type DeviceIDKeyType ¶ added in v0.10.0
type DeviceIDKeyType struct{}
Context keys for storing test data
type DeviceKeyType ¶ added in v0.10.0
type DeviceKeyType struct{}
type QueueState ¶ added in v1.0.0
type QueueState struct {
Accessible bool
TaskQueueExists bool
HasConsumerGroup bool
InFlightTasks int
FailedMessages int
QueueLength int64 // Number of messages in the task-queue stream
}
QueueState represents the state of Redis queues
func CheckQueueState ¶ added in v1.0.0
func CheckQueueState(ctx string) QueueState
CheckQueueState checks the state of Redis queues ctx should be KIND, OCP (for kubernetes), or empty string (for podman)
func CheckQueueStateKubernetes ¶ added in v1.0.0
func CheckQueueStateKubernetes(namespace, password string) QueueState
CheckQueueStateKubernetes checks queue state using kubectl exec in Kubernetes mode
type TestCase ¶ added in v0.8.1
RunTable runs a table of test cases with the given run function. Each test case has a description and parameters of type T.
type TestContextKeyType ¶ added in v0.10.0
type TestContextKeyType struct{}
type TestIDKeyType ¶ added in v0.10.0
type TestIDKeyType struct{}
TestIDKey is the context key used to store the test ID
type TestOrgCache ¶ added in v0.10.0
type TestOrgCache struct {
// contains filtered or unexported fields
}
func (*TestOrgCache) Get ¶ added in v0.10.0
func (c *TestOrgCache) Get(id uuid.UUID) *model.Organization
func (*TestOrgCache) Set ¶ added in v0.10.0
func (c *TestOrgCache) Set(id uuid.UUID, org *model.Organization)