util

package
v0.1.71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 143 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderAzure    ProviderType = "azure"
	ProviderKeycloak ProviderType = "keycloak"

	ExternalOIDCUIDExpressionPrefix        = "testuid-"
	ExternalOIDCUIDExpressionSubfix        = "-uidtest"
	ExternalOIDCExtraKeyBar                = "extratest.openshift.com/bar"
	ExternalOIDCExtraKeyBarValueExpression = "extra-test-mark"
	ExternalOIDCExtraKeyFoo                = "extratest.openshift.com/foo"
	ExternalOIDCExtraKeyFooValueExpression = "claims.email" // This is a variable, not a string literal
)
View Source
const (
	KubeletConfigVerifierDaemonSetName = "kubelet-config-verifier"
	KubeletConfigVerifierNamespace     = "kube-system"
	NodePullSecretPath                 = "/var/lib/kubelet/config.json"
)
View Source
const (
	DefaultCIBaseDomain = "origin-ci-int-aws.dev.rhcloud.com"
)
View Source
const (
	// Metrics
	// TODO (jparrill): We need to separate the metrics.go from the main pkg in the hypershift-operator.
	//     Delete these references when it's done and import it from there
	HypershiftOperatorInfoName = "hypershift_operator_info"
)
View Source
const OAuthServerConfigKey = "config.yaml"

Variables

View Source
var (
	// y-stream versions supported by e2e in main
	Version421 = semver.MustParse("4.21.0")
	Version420 = semver.MustParse("4.20.0")
	Version419 = semver.MustParse("4.19.0")
	Version418 = semver.MustParse("4.18.0")
	Version417 = semver.MustParse("4.17.0")
	Version416 = semver.MustParse("4.16.0")
	Version415 = semver.MustParse("4.15.0")
	Version414 = semver.MustParse("4.14.0")
)

Functions

func AtLeast added in v0.1.48

func AtLeast(t *testing.T, version semver.Version)

func CPOAtLeast added in v0.1.56

func CPOAtLeast(t *testing.T, version semver.Version, hc *hyperv1.HostedCluster)

func ChangeClientForKeycloakExtOIDC added in v0.1.66

func ChangeClientForKeycloakExtOIDC(t *testing.T, ctx context.Context, clientCfg *rest.Config, authConfig *ExtOIDCConfig) crclient.Client

ChangeClientForKeycloakExtOIDC changes the guest client using a keycloak user config

func ChangeUserForKeycloakExtOIDC added in v0.1.66

func ChangeUserForKeycloakExtOIDC(t *testing.T, ctx context.Context, clientCfg *rest.Config, authConfig *ExtOIDCConfig) *rest.Config

ChangeUserForKeycloakExtOIDC changes the user of current CLI session for a Keycloak external OIDC cluster

func CleanupOIDCBucketObjects added in v0.1.4

func CleanupOIDCBucketObjects(log logr.Logger, s3Client *s3.S3, bucketName, issuerURL string)

func CleanupSharedOIDCProvider added in v0.1.70

func CleanupSharedOIDCProvider(opts *Options, log logr.Logger)

func CorrelateDaemonSet

func CorrelateDaemonSet(ds *appsv1.DaemonSet, nodePool *hyperv1.NodePool, dsName string)

func CreateKubeletConfigVerifierDaemonSet added in v0.1.66

func CreateKubeletConfigVerifierDaemonSet(ctx context.Context, guestClient crclient.Client, dsImage string) error

CreateKubeletConfigVerifierDaemonSet creates a DaemonSet that verifies the config.json file on all nodes of the cluster, comparing it with the cluster's pull secret

func DeleteNamespace

func DeleteNamespace(t *testing.T, ctx context.Context, client crclient.Client, namespace string) error

DeleteNamespace deletes and finalizes the given namespace, logging any failures along the way.

func DestroyOIDCProvider added in v0.1.4

func DestroyOIDCProvider(log logr.Logger, iamClient iamiface.IAMAPI, issuerURL string)

func EnsureAPIUX added in v0.1.43

func EnsureAPIUX(t *testing.T, ctx context.Context, hostClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureAdmissionPolicies added in v0.1.44

func EnsureAdmissionPolicies(t *testing.T, ctx context.Context, mgmtClient crclient.Client, hc *hyperv1.HostedCluster)

func EnsureAllContainersHavePullPolicyIfNotPresent

func EnsureAllContainersHavePullPolicyIfNotPresent(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureAllContainersHaveTerminationMessagePolicyFallbackToLogsOnError added in v0.1.60

func EnsureAllContainersHaveTerminationMessagePolicyFallbackToLogsOnError(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureAllReqServingPodsLandOnReqServingNodes added in v0.1.16

func EnsureAllReqServingPodsLandOnReqServingNodes(t *testing.T, ctx context.Context, client crclient.Client)

func EnsureAllRoutesUseHCPRouter

func EnsureAllRoutesUseHCPRouter(t *testing.T, ctx context.Context, hostClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureAppLabel added in v0.1.66

func EnsureAppLabel(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureCNOOperatorConfiguration added in v0.1.67

func EnsureCNOOperatorConfiguration(t *testing.T, ctx context.Context, mgmtClient crclient.Client, guestClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

EnsureCNOOperatorConfiguration tests that changes to the CNO operator configuration on the HostedCluster are properly reflected in the hosted cluster's API and that the CNO doesn't report any errors via HCP conditions.

func EnsureConsoleCapabilityDisabled added in v0.1.64

func EnsureConsoleCapabilityDisabled(ctx context.Context, t *testing.T, g Gomega, clients *GuestClients)

EnsureConsoleCapabilityDisabled validates the expectations for when ConsoleCapability is Disabled

func EnsureCustomLabels added in v0.1.52

func EnsureCustomLabels(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureCustomTolerations added in v0.1.55

func EnsureCustomTolerations(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureDefaultSecurityGroupTags added in v0.1.64

func EnsureDefaultSecurityGroupTags(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, clusterOpts PlatformAgnosticOptions)

func EnsureFeatureGateStatus added in v0.1.69

func EnsureFeatureGateStatus(t *testing.T, ctx context.Context, guestClient crclient.Client)

NOTE: This function assumes that it is not called in the middle of a version rollout i.e. It expects that the first entry in ClusterVersion history is Completed

func EnsureGlobalPullSecret added in v0.1.66

func EnsureGlobalPullSecret(t *testing.T, ctx context.Context, mgmtClient crclient.Client, entryHostedCluster *hyperv1.HostedCluster)

func EnsureGuestWebhooksValidated added in v0.1.10

func EnsureGuestWebhooksValidated(t *testing.T, ctx context.Context, guestClient crclient.Client)

func EnsureHCPContainersHaveResourceRequests

func EnsureHCPContainersHaveResourceRequests(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureHCPPodsAffinitiesAndTolerations added in v0.1.16

func EnsureHCPPodsAffinitiesAndTolerations(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureImageRegistryCapabilityDisabled added in v0.1.58

func EnsureImageRegistryCapabilityDisabled(ctx context.Context, t *testing.T, g Gomega, clients *GuestClients)

EnsureImageRegistryCapabilityDisabled validates the expectations for when ImageRegistryCapability is Disabled

func EnsureIngressCapabilityDisabled added in v0.1.66

func EnsureIngressCapabilityDisabled(ctx context.Context, t *testing.T, clients *GuestClients, mgmtClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

EnsureIngressCapabilityDisabled validates the expectations for when IngressCapability is Disabled

func EnsureIngressOperatorConfiguration added in v0.1.71

func EnsureIngressOperatorConfiguration(t *testing.T, ctx context.Context, mgmtClient crclient.Client, guestClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

EnsureIngressOperatorConfiguration tests that the Ingress Operator configuration on the HostedCluster is properly reflected in the hosted cluster's IngressController and that the Ingress Operator doesn't report any errors via HCP conditions.

func EnsureInsightsCapabilityDisabled added in v0.1.63

func EnsureInsightsCapabilityDisabled(ctx context.Context, t *testing.T, g Gomega, clients *GuestClients)

EnsureInsightsCapabilityDisabled validates the expectations for when InsightsCapability is Disabled

func EnsureKubeAPIDNSNameCustomCert added in v0.1.58

func EnsureKubeAPIDNSNameCustomCert(t *testing.T, ctx context.Context, mgmtClient crclient.Client, entryHostedCluster *hyperv1.HostedCluster)

func EnsureKubeAPIServerAllowedCIDRs added in v0.1.66

func EnsureKubeAPIServerAllowedCIDRs(t *testing.T, ctx context.Context, mgmtClient crclient.Client, guestConfig *rest.Config, hc *hyperv1.HostedCluster)

func EnsureMachineDeploymentGeneration

func EnsureMachineDeploymentGeneration(t *testing.T, ctx context.Context, hostClient crclient.Client, hostedCluster *hyperv1.HostedCluster, expectedGeneration int64)

func EnsureNetworkPolicies added in v0.1.10

func EnsureNetworkPolicies(t *testing.T, ctx context.Context, c crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNoCrashingPods

func EnsureNoCrashingPods(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNoHCPPodsLandOnDefaultNode added in v0.1.17

func EnsureNoHCPPodsLandOnDefaultNode(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNoPodsWithTooHighPriority

func EnsureNoPodsWithTooHighPriority(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNoRapidDeploymentRollouts added in v0.1.53

func EnsureNoRapidDeploymentRollouts(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNodeCommunication

func EnsureNodeCommunication(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureNodeCountMatchesNodePoolReplicas

func EnsureNodeCountMatchesNodePoolReplicas(t *testing.T, ctx context.Context, hostClient, guestClient crclient.Client, platform hyperv1.PlatformType, nodePoolNamespace string)

func EnsureNodeTuningCapabilityDisabled added in v0.1.66

func EnsureNodeTuningCapabilityDisabled(ctx context.Context, t *testing.T, clients *GuestClients, mgmtClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

EnsureNodeTuningCapabilityDisabled validates the expectations for when NodeTuningCapability is Disabled

func EnsureNodesLabelsAndTaints added in v0.1.10

func EnsureNodesLabelsAndTaints(t *testing.T, nodePool hyperv1.NodePool, nodes []corev1.Node)

func EnsureNodesRuntime added in v0.1.51

func EnsureNodesRuntime(t *testing.T, nodes []corev1.Node)

EnsureNodesRuntime ensures that all nodes in the NodePool have the expected runtime handlers. This is only supported on 4.18+ when the default runtime is changed to crun.

func EnsureOAPIMountsTrustBundle added in v0.1.40

func EnsureOAPIMountsTrustBundle(t *testing.T, ctx context.Context, mgmtClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureOAuthWithIdentityProvider added in v0.1.2

func EnsureOAuthWithIdentityProvider(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureOnlyRequestServingPodsOnRequestServingNodes added in v0.1.16

func EnsureOnlyRequestServingPodsOnRequestServingNodes(t *testing.T, ctx context.Context, client crclient.Client)

func EnsureOpenshiftSamplesCapabilityDisabled added in v0.1.60

func EnsureOpenshiftSamplesCapabilityDisabled(ctx context.Context, t *testing.T, g Gomega, clients *GuestClients)

EnsureOpenshiftSamplesCapabilityDisabled validates the expectations for when OpenShiftSamplesCapability is Disabled

func EnsurePSANotPrivileged added in v0.1.10

func EnsurePSANotPrivileged(t *testing.T, ctx context.Context, guestClient crclient.Client)

func EnsurePayloadArchSetCorrectly added in v0.1.48

func EnsurePayloadArchSetCorrectly(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsurePodsWithEmptyDirPVsHaveSafeToEvictAnnotations added in v0.1.10

func EnsurePodsWithEmptyDirPVsHaveSafeToEvictAnnotations(t *testing.T, ctx context.Context, hostClient crclient.Client, hcpNs string)

func EnsureReadOnlyRootFilesystem added in v0.1.67

func EnsureReadOnlyRootFilesystem(t *testing.T, ctx context.Context, hostClient crclient.Client, hcpNs string)

func EnsureSATokenNotMountedUnlessNecessary added in v0.1.19

func EnsureSATokenNotMountedUnlessNecessary(t *testing.T, ctx context.Context, c crclient.Client, hostedCluster *hyperv1.HostedCluster)

func EnsureSecretEncryptedUsingKMS

func EnsureSecretEncryptedUsingKMS(t *testing.T, ctx context.Context, hostedCluster *hyperv1.HostedCluster, guestClient crclient.Client)

func EnsureSecretEncryptedUsingKMSV1 added in v0.1.43

func EnsureSecretEncryptedUsingKMSV1(t *testing.T, ctx context.Context, hostedCluster *hyperv1.HostedCluster, guestClient crclient.Client)

func EnsureSecretEncryptedUsingKMSV2 added in v0.1.43

func EnsureSecretEncryptedUsingKMSV2(t *testing.T, ctx context.Context, hostedCluster *hyperv1.HostedCluster, guestClient crclient.Client)

func EnsureSecurityContextUID added in v0.1.66

func EnsureSecurityContextUID(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

EnsureSecurityContextUID validates that all pods in the control plane namespace have the expected SecurityContext UID. TestCreateClusterDefaultSecurityContextUID ensures uniqueness across namespaces.

func EventuallyObject added in v0.1.38

func EventuallyObject[T client.Object](t *testing.T, ctx context.Context, objective string, getter func(context.Context) (T, error), predicates []Predicate[T], options ...EventuallyOption)

EventuallyObject polls until the predicate is fulfilled on the object.

func EventuallyObjects added in v0.1.38

func EventuallyObjects[T client.Object](t *testing.T, ctx context.Context, objective string, getter func(context.Context) ([]T, error), groupPredicates []Predicate[[]T], predicates []Predicate[T], options ...EventuallyOption)

EventuallyObjects polls until the predicate is fulfilled on each of a set of objects.

func ExtractVersionFromReleaseImage added in v0.1.71

func ExtractVersionFromReleaseImage(releaseImage string) string

ExtractVersionFromReleaseImage extracts the version from a release image reference. For example: "quay.io/openshift-release-dev/ocp-release:4.19.10-x86_64" -> "4.19.10"

func GenerateCustomCertificate added in v0.1.58

func GenerateCustomCertificate(dnsNames []string, validity time.Duration) ([]byte, []byte, error)

GenerateCustomCertificate generates a self-signed certificate for the given DNS names

func GetClient

func GetClient() (crclient.Client, error)

GetClient creates a controller-runtime client for Kubernetes

func GetClientConfigForKeycloakOIDCUser added in v0.1.66

func GetClientConfigForKeycloakOIDCUser(clientCfg *rest.Config, authConfig *ExtOIDCConfig, tokenCacheDir string) *rest.Config

GetClientConfigForKeycloakOIDCUser gets a client config for an external OIDC cluster

func GetConfig

func GetConfig() (*rest.Config, error)

GetConfig creates a REST config from current context

func GetCustomKubeconfigClients added in v0.1.58

func GetCustomKubeconfigClients(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, serverAddress string) (*kubeclient.Clientset, crclient.Client)

func GetDefaultSecurityGroup added in v0.1.64

func GetDefaultSecurityGroup(awsCreds, awsRegion, sgID string) (*ec2.SecurityGroup, error)

func GetFakeClient added in v0.1.70

func GetFakeClient(objects ...crclient.Object) crclient.Client

func GetGuestKubeconfigHost added in v0.1.40

func GetGuestKubeconfigHost(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) (string, error)

func GetHyperShiftOperatorImage added in v0.1.54

func GetHyperShiftOperatorImage(ctx context.Context, client crclient.Client, opts HyperShiftOperatorInstallOptions) (string, error)

GetHyperShiftOperatorImage returns the current rolled-out image of the HyperShift operator

func GetIAMClient added in v0.1.4

func GetIAMClient(awsCreds, awsRegion string) iamiface.IAMAPI

func GetKMSKeyArn

func GetKMSKeyArn(awsCreds, awsRegion, alias string) (*string, error)

func GetMetricsFromPod added in v0.1.69

func GetMetricsFromPod(ctx context.Context, c crclient.Client, componentName, containerName, namespaceName, port string) (map[string]*dto.MetricFamily, error)

GetMetricsFromPod exec curl command in a pod metrics endpoint and return metric values if any Requires curl to be installed in the container

func GetS3Client added in v0.1.4

func GetS3Client(awsCreds, awsRegion string) *s3.S3

func GetUserForToken added in v0.1.2

func GetUserForToken(config *restclient.Config, token string) (*userv1.User, error)

func GinkgoAtLeast added in v0.1.70

func GinkgoAtLeast(version semver.Version)

func HasFieldInCRDSchema added in v0.1.70

func HasFieldInCRDSchema(ctx context.Context, client crclient.Client, crdName, fieldPath string) (bool, error)

HasFieldInCRDSchema checks if a field path exists in the CRD schema by recursively traversing the JSONSchemaProps. The fieldPath should be dot-separated (e.g., "spec.platform.gcp").

func InstallHyperShiftOperator added in v0.1.54

func InstallHyperShiftOperator(ctx context.Context, opts HyperShiftOperatorInstallOptions) error

InstallHyperShiftOperator generates and applies the manifests needed to install the HyperShift Operator starting with the all the HyperShift CRDs. It will wait for the HyperShift Operator to be ready before it returns.

func IsExternalOIDCCluster added in v0.1.66

func IsExternalOIDCCluster(t *testing.T, ctx context.Context, clientCfg *rest.Config) (bool, error)

IsExternalOIDCCluster checks if the cluster is using external OIDC.

func IsGreaterThanOrEqualTo added in v0.1.64

func IsGreaterThanOrEqualTo(version semver.Version) bool

func IsLessThan added in v0.1.48

func IsLessThan(version semver.Version) bool

func KubeletConfigVerifierDaemonSet added in v0.1.71

func KubeletConfigVerifierDaemonSet() *appsv1.DaemonSet

Manifests KubeletConfigVerifierDaemonSet returns a manifest for the kubelet config verifier DaemonSet

func NewHypershiftTest added in v0.1.10

func NewHypershiftTest(t *testing.T, ctx context.Context, test hypershiftTestFunc) *hypershiftTest

func NewLogr

func NewLogr(t *testing.T) logr.Logger

func NewPrometheusClient added in v0.1.6

func NewPrometheusClient(ctx context.Context) (prometheusv1.API, error)

func NoticePreemptionOrFailedScheduling

func NoticePreemptionOrFailedScheduling(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func OpenshiftOVNKubeDaemonSet added in v0.1.71

func OpenshiftOVNKubeDaemonSet() *appsv1.DaemonSet

OpenshiftOVNKubeDaemonSet returns a manifest for the OVN-Kubernetes DaemonSet

func PutRolePolicy added in v0.1.66

func PutRolePolicy(awsCreds, awsRegion, roleARN string, policy string) (func() error, error)

func RunCommandInPod added in v0.1.10

func RunCommandInPod(ctx context.Context, c crclient.Client, component, namespace string, command []string, containerName string, timeout time.Duration) (string, error)

func SetReleaseImageVersion added in v0.1.48

func SetReleaseImageVersion(ctx context.Context, latestReleaseImage string, pullSecretFile string) error

func SetReleaseVersionFromHostedCluster added in v0.1.70

func SetReleaseVersionFromHostedCluster(ctx context.Context, hostedCluster *hyperv1.HostedCluster) error

func SetupReqServingClusterNodePools added in v0.1.17

func SetupReqServingClusterNodePools(ctx context.Context, t *testing.T, kubeconfigPath, mgmtHCNamespace, mgmtHCName string) []*hyperv1.NodePool

func SetupSharedOIDCProvider added in v0.1.70

func SetupSharedOIDCProvider(opts *Options, artifactDir string) error

setup a shared OIDC provider to be used by all HostedClusters

func TearDownNodePools added in v0.1.17

func TearDownNodePools(ctx context.Context, t *testing.T, kubeconfigPath string, nodePools []*hyperv1.NodePool)

func UpdateObject added in v0.1.6

func UpdateObject[T crclient.Object](t *testing.T, ctx context.Context, client crclient.Client, original T, mutate func(obj T)) error

func ValidateAuthenticationSpec added in v0.1.66

func ValidateAuthenticationSpec(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, config *ExtOIDCConfig)

ValidateAuthenticationSpec validates the external OIDC configuration and the expected HostedCluster authentication configuration before running the test

func ValidateConfigurationStatus added in v0.1.69

func ValidateConfigurationStatus(t *testing.T, ctx context.Context, mgmtClient crclient.Client, guestClient crclient.Client, hostedCluster *hyperv1.HostedCluster)

ValidateConfigurationStatus validates that the HCP and HC configuration status matches the Authentication resource status from the hosted cluster

func ValidateHostedClusterConditions added in v0.1.64

func ValidateHostedClusterConditions(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, hasWorkerNodes bool, timeout time.Duration)

func ValidateMetricPresence added in v0.1.69

func ValidateMetricPresence(t *testing.T, mf map[string]*dto.MetricFamily, query, labelKey, labelValue, metricName string, areMetricsExpectedToBePresent bool) bool

ValidateMetricPresence checks if a metric meets the expected presence criteria Returns true if validation passes, false otherwise

func ValidateMetrics added in v0.1.10

func ValidateMetrics(t *testing.T, ctx context.Context, client crclient.Client, hc *hyperv1.HostedCluster, metricsNames []string, areMetricsExpectedToBePresent bool)

Verifies that the given metrics are defined for the given hosted cluster if areMetricsExpectedToBePresent is set to true. Verifies that the given metrics are not defined otherwise.

func ValidatePrivateCluster added in v0.1.10

func ValidatePrivateCluster(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, clusterOpts *PlatformAgnosticOptions)

func ValidatePublicCluster added in v0.1.10

func ValidatePublicCluster(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, clusterOpts *PlatformAgnosticOptions)

func VerifyCPOOverrideImage added in v0.1.71

func VerifyCPOOverrideImage(t *testing.T, ctx context.Context, mgtClient crclient.Client, controlPlaneNamespace, releaseImage, platform string)

VerifyCPOOverrideImage verifies that the control-plane-operator pod is running with the expected override image from overrides.yaml. Skips gracefully if no override is configured for the platform/version.

func VerifyKubeletConfigWithDaemonSet added in v0.1.66

func VerifyKubeletConfigWithDaemonSet(t *testing.T, ctx context.Context, guestClient crclient.Client, dsImage string)

VerifyKubeletConfigWithDaemonSet implements complete verification using DaemonSet

func WaitForConditionsOnHostedControlPlane

func WaitForConditionsOnHostedControlPlane(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, image string)

func WaitForControlPlaneComponentRollout added in v0.1.68

func WaitForControlPlaneComponentRollout(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, initialVersion string)

func WaitForCustomKubeconfig added in v0.1.58

func WaitForCustomKubeconfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) []byte

WaitForCustomKubeconfig waits for a KAS custom kubeconfig to be published for the given HostedCluster.

func WaitForGuestClient

func WaitForGuestClient(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) crclient.Client

func WaitForGuestKubeConfig

func WaitForGuestKubeConfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) []byte

func WaitForGuestKubeconfigHostResolutionUpdate added in v0.1.56

func WaitForGuestKubeconfigHostResolutionUpdate(t *testing.T, ctx context.Context, uri string, endpointAccess hyperv1.AWSEndpointAccessType)

func WaitForGuestKubeconfigHostUpdate added in v0.1.40

func WaitForGuestKubeconfigHostUpdate(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, oldHost string)

func WaitForGuestRestConfig added in v0.1.66

func WaitForGuestRestConfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) *rest.Config

func WaitForImageRollout

func WaitForImageRollout(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func WaitForNReadyNodes

func WaitForNReadyNodes(t *testing.T, ctx context.Context, client crclient.Client, n int32, platform hyperv1.PlatformType) []corev1.Node

func WaitForNReadyNodesWithOptions added in v0.1.40

func WaitForNReadyNodesWithOptions(t *testing.T, ctx context.Context, client crclient.Client, n int32, platform hyperv1.PlatformType, suffix string, opts ...NodePoolPollOption) []corev1.Node

func WaitForNodePoolConfigUpdateComplete added in v0.1.51

func WaitForNodePoolConfigUpdateComplete(t *testing.T, ctx context.Context, client crclient.Client, np *hyperv1.NodePool)

func WaitForNodePoolConfigUpdateCompleteWithPlatform added in v0.1.71

func WaitForNodePoolConfigUpdateCompleteWithPlatform(t *testing.T, ctx context.Context, client crclient.Client, np *hyperv1.NodePool, platform hyperv1.PlatformType)

func WaitForNodePoolDesiredNodes added in v0.1.6

func WaitForNodePoolDesiredNodes(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func WaitForOAuthRouteReady added in v0.1.2

func WaitForOAuthRouteReady(t *testing.T, ctx context.Context, client crclient.Client, restConfig *restclient.Config, hostedCluster *hyperv1.HostedCluster) *routev1.Route

func WaitForOAuthToken added in v0.1.2

func WaitForOAuthToken(t *testing.T, ctx context.Context, oauthRoute *routev1.Route, restConfig *restclient.Config, username, password string) string

func WaitForOauthConfig added in v0.1.6

func WaitForOauthConfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster)

func WaitForReadyNodesByLabels added in v0.1.54

func WaitForReadyNodesByLabels(t *testing.T, ctx context.Context, client crclient.Client, platform hyperv1.PlatformType, replicas int32, nodeLabels map[string]string) []corev1.Node

func WaitForReadyNodesByNodePool added in v0.1.40

func WaitForReadyNodesByNodePool(t *testing.T, ctx context.Context, client crclient.Client, np *hyperv1.NodePool, platform hyperv1.PlatformType, opts ...NodePoolPollOption) []corev1.Node

Types

type Condition added in v0.1.38

type Condition struct {
	Type    string
	Status  metav1.ConditionStatus
	Reason  string
	Message string
}

Condition is a generic structure required to adapt all the different concrete condition types into one.

func Conditions added in v0.1.38

func Conditions(item client.Object) ([]Condition, error)

Conditions extracts conditions from the item and adapts them to the generic wrapper.

func (Condition) Matches added in v0.1.38

func (needle Condition) Matches(condition Condition) bool

func (Condition) String added in v0.1.38

func (c Condition) String() string

String formats a condition in the canonical way.

type ConfigurableClusterOptions added in v0.1.54

type ConfigurableClusterOptions struct {
	AWSCredentialsFile                    string
	AWSEndpointAccess                     string
	AWSKmsKeyAlias                        string
	AWSMultiArch                          bool
	AWSOidcS3BucketName                   string
	Annotations                           stringMapVar
	AzureCredentialsFile                  string
	AzureManagedIdentitiesFile            string
	AzureIssuerURL                        string
	AzureMultiArch                        bool
	AzureServiceAccountTokenIssuerKeyPath string
	AzureDataPlaneIdentities              string
	AzureWorkloadIdentitiesFile           string
	AzureEncryptionKeyID                  string
	AzureKMSUserAssignedCredsSecretName   string
	OpenStackCredentialsFile              string
	OpenStackCACertFile                   string
	AzureLocation                         string
	AzureMarketplaceOffer                 string
	AzureMarketplacePublisher             string
	AzureMarketplaceSKU                   string
	AzureMarketplaceVersion               string
	BaseDomain                            string
	ClusterCIDR                           stringSliceVar
	ControlPlaneOperatorImage             string
	EtcdStorageClass                      string
	ExternalDNSDomain                     string
	KubeVirtContainerDiskImage            string
	KubeVirtInfraKubeconfigFile           string
	KubeVirtInfraNamespace                string
	KubeVirtNodeCores                     uint
	KubeVirtNodeMemory                    string
	KubeVirtRootVolumeSize                uint
	KubeVirtRootVolumeVolumeMode          string
	NetworkType                           string
	NodePoolReplicas                      int
	OpenStackExternalNetworkID            string
	OpenStackNodeAvailabilityZone         string
	OpenStackNodeFlavor                   string
	OpenStackNodeImageName                string
	OpenStackDNSNameservers               stringSliceVar
	PowerVSCloudConnection                string
	PowerVSCloudInstanceID                string
	PowerVSMemory                         int
	PowerVSPER                            bool
	PowerVSProcType                       hyperv1.PowerVSNodePoolProcType
	PowerVSProcessors                     string
	PowerVSRegion                         string
	PowerVSResourceGroup                  string
	PowerVSSysType                        string
	PowerVSTransitGateway                 string
	PowerVSTransitGatewayLocation         string
	PowerVSVPC                            string
	PowerVSVpcRegion                      string
	PowerVSZone                           string
	PullSecretFile                        string
	Region                                string
	SSHKeyFile                            string
	ServiceCIDR                           stringSliceVar
	Zone                                  stringSliceVar
}

type DaemonSetManifest added in v0.1.71

type DaemonSetManifest struct {
	GetFunc           func() *appsv1.DaemonSet
	AllowPartialNodes bool
}

DaemonSetManifest represents a DaemonSet to be verified

type DefaultRemoteExecutor

type DefaultRemoteExecutor struct{}

DefaultRemoteExecutor is the standard implementation of remote command execution

func (*DefaultRemoteExecutor) Execute

func (*DefaultRemoteExecutor) Execute(ctx context.Context, method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error

type EventuallyOption added in v0.1.38

type EventuallyOption func(*EventuallyOptions)

EventuallyOption configures a

func WithDelayedStart added in v0.1.38

func WithDelayedStart() EventuallyOption

WithDelayedStart configures the asynchronous assertion to start immediately.

func WithFilteredConditionDump added in v0.1.38

func WithFilteredConditionDump(matchers ...Condition) EventuallyOption

WithFilteredConditionDump configures the asynchronous assertion to only dump the specified conditions.

func WithInterval added in v0.1.38

func WithInterval(interval time.Duration) EventuallyOption

WithInterval sets the polling interval.

func WithTimeout added in v0.1.38

func WithTimeout(timeout time.Duration) EventuallyOption

WithTimeout sets the polling timeout.

func WithoutConditionDump added in v0.1.38

func WithoutConditionDump() EventuallyOption

WithoutConditionDump configures the asynchronous assertion to dump conditions on failure.

type EventuallyOptions added in v0.1.38

type EventuallyOptions struct {
	// contains filtered or unexported fields
}

EventuallyOptions configure asynchronous assertion behavior.

type ExtOIDCConfig added in v0.1.66

type ExtOIDCConfig struct {
	ExternalOIDCProvider     ProviderType
	OIDCProviderName         string
	CliClientID              string
	ConsoleClientID          string
	IssuerURL                string
	GroupPrefix              string
	UserPrefix               string
	ConsoleClientSecretName  string
	ConsoleClientSecretValue string

	// format: “user1:psw1,user2:psw2”, it is used for keycloak oidc
	TestUsers string

	// for oidcProviders.issuer.issuerCertificateAuthority
	IssuerCAConfigmapName string
	IssuerCABundleFile    string
}

func GetExtOIDCConfig added in v0.1.66

func GetExtOIDCConfig(provider, cliClientID, consoleClientID, issuerURL, consoleSecret, issuerCABundleFile, testUsers string) *ExtOIDCConfig

func (*ExtOIDCConfig) GetAuthenticationConfig added in v0.1.66

func (config *ExtOIDCConfig) GetAuthenticationConfig() *configv1.AuthenticationSpec

type GuestClients added in v0.1.60

type GuestClients struct {
	CfgClient  *configv1client.Clientset
	KubeClient *kubeclient.Clientset
}

func InitGuestClients added in v0.1.60

func InitGuestClients(ctx context.Context, t *testing.T, g Gomega, mgtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) *GuestClients

InitGuestClients initializes the Kubernetes and OpenShift config clients for the guest cluster

type HyperShiftOperatorInstallOptions added in v0.1.54

type HyperShiftOperatorInstallOptions struct {
	AWSOidcS3BucketName                    string
	AWSOidcS3Credentials                   string
	AWSOidcS3Region                        string
	AWSPrivateCredentialsFile              string
	AWSPrivateRegion                       string
	EnableCIDebugOutput                    bool
	ExternalDNSCredentials                 string
	ExternalDNSDomain                      string
	ExternalDNSDomainFilter                string
	ExternalDNSProvider                    string
	HyperShiftOperatorLatestImage          string
	PlatformMonitoring                     string
	PrivatePlatform                        string
	EnableSizeTagging                      bool
	EnableDedicatedRequestServingIsolation bool
	EnableCPOOverrides                     bool
	EnableEtcdRecovery                     bool
	DryRun                                 bool
	DryRunDir                              string
}

type KubeVirtInfra added in v0.1.32

type KubeVirtInfra struct {
	// contains filtered or unexported fields
}

func NewKubeVirtInfra added in v0.1.32

func NewKubeVirtInfra(ctx context.Context, mgmtClient crclient.Client, hostedCluster *hyperv1.HostedCluster) KubeVirtInfra

func (KubeVirtInfra) ComposeOVNKLayer2NAD added in v0.1.32

func (k KubeVirtInfra) ComposeOVNKLayer2NAD(namespace string) (crclient.Object, error)

func (KubeVirtInfra) CreateOVNKLayer2NAD added in v0.1.32

func (k KubeVirtInfra) CreateOVNKLayer2NAD(namespace string) error

func (KubeVirtInfra) Ctx added in v0.1.32

func (k KubeVirtInfra) Ctx() context.Context

func (KubeVirtInfra) DiscoverClient added in v0.1.32

func (k KubeVirtInfra) DiscoverClient() (crclient.Client, error)

func (KubeVirtInfra) HostedCluster added in v0.1.32

func (k KubeVirtInfra) HostedCluster() *hyperv1.HostedCluster

func (KubeVirtInfra) MGMTClient added in v0.1.32

func (k KubeVirtInfra) MGMTClient() crclient.Client

func (KubeVirtInfra) NADName added in v0.1.32

func (k KubeVirtInfra) NADName() string

func (KubeVirtInfra) Namespace added in v0.1.32

func (k KubeVirtInfra) Namespace() string

type NameGenerator

type NameGenerator interface {
	// GenerateName generates a valid name from the base name, adding a random suffix to the
	// the base. If base is valid, the returned name must also be valid. The generator is
	// responsible for knowing the maximum valid name length.
	GenerateName(base string) string
}

NameGenerator generates names for objects. Some backends may have more information available to guide selection of new names and this interface hides those details.

var SimpleNameGenerator NameGenerator = simpleNameGenerator{}

SimpleNameGenerator is a generator that returns the name plus a random suffix of five alphanumerics when a name is requested. The string is guaranteed to not exceed the length of a standard Kubernetes name (63 characters)

type NodePoolPollOption added in v0.1.40

type NodePoolPollOption func(*NodePoolPollOptions)

func WithClientOptions added in v0.1.40

func WithClientOptions(clientOpts ...crclient.ListOption) NodePoolPollOption

func WithCollectionPredicates added in v0.1.40

func WithCollectionPredicates(predicates ...Predicate[[]*corev1.Node]) NodePoolPollOption

func WithPredicates added in v0.1.40

func WithPredicates(predicates ...Predicate[*corev1.Node]) NodePoolPollOption

func WithSuffix added in v0.1.40

func WithSuffix(suffix string) NodePoolPollOption

type NodePoolPollOptions added in v0.1.40

type NodePoolPollOptions struct {
	// contains filtered or unexported fields
}

type Options added in v0.1.54

type Options struct {
	LatestReleaseImage   string
	PreviousReleaseImage string
	N4MinorReleaseImage  string
	N3MinorReleaseImage  string
	N2MinorReleaseImage  string
	N1MinorReleaseImage  string
	IsRunningInCI        bool
	ArtifactDir          string

	// BeforeApply is a function passed to the CLI create command giving the test
	// code an opportunity to inspect or mutate the resources the CLI will create
	// before they're applied.
	BeforeApply func(client.Object) `json:"-"`

	Platform    hyperv1.PlatformType
	PlatformRaw string

	ConfigurableClusterOptions ConfigurableClusterOptions
	AdditionalTags             stringSliceVar

	IssuerURL                string
	ServiceAccountSigningKey []byte

	// If set, the CreateCluster test will create a cluster with request serving
	// isolation topology.
	RequestServingIsolation bool

	// If testing request serving isolation topology, we need a kubeconfig to the
	// parent of the management cluster, name and namespace of the management cluster
	// so we can create additional nodepools for it.
	ManagementParentKubeconfig string
	ManagementClusterNamespace string
	ManagementClusterName      string
	// If set, the UpgradeControlPlane test will upgrade control plane without
	// reconciling PKI.
	DisablePKIReconciliation bool

	HyperShiftOperatorLatestImage string

	// This is used in tests which include the HyperShift Operator as part of
	// the test such as the UpgradeHyperShiftOperatorTest
	HOInstallationOptions HyperShiftOperatorInstallOptions
	// RunUpgradeTest is set to run HyperShift Operator upgrade test
	RunUpgradeTest bool

	// external oidc for authentication in spec.configurations
	ExternalOIDCProvider        string
	ExternalOIDCCliClientID     string
	ExternalOIDCConsoleClientID string
	ExternalOIDCIssuerURL       string
	ExternalOIDCConsoleSecret   string
	ExternalOIDCCABundleFile    string
	ExternalOIDCTestUsers       string
}

Options are global test options applicable to all scenarios.

func (*Options) Complete added in v0.1.54

func (o *Options) Complete() error

Complete is intended to be called after flags have been bound and sets up additional contextual defaulting.

func (*Options) DefaultAWSOptions added in v0.1.54

func (o *Options) DefaultAWSOptions() hypershiftaws.RawCreateOptions

func (*Options) DefaultAzureOptions added in v0.1.54

func (o *Options) DefaultAzureOptions() azure.RawCreateOptions

func (*Options) DefaultClusterOptions added in v0.1.54

func (o *Options) DefaultClusterOptions(t *testing.T) PlatformAgnosticOptions

func (*Options) DefaultKubeVirtOptions added in v0.1.54

func (o *Options) DefaultKubeVirtOptions() kubevirt.RawCreateOptions

func (*Options) DefaultNoneOptions added in v0.1.54

func (o *Options) DefaultNoneOptions() none.RawCreateOptions

func (*Options) DefaultOpenStackOptions added in v0.1.54

func (p *Options) DefaultOpenStackOptions() hypershiftopenstack.RawCreateOptions

func (*Options) DefaultPowerVSOptions added in v0.1.54

func (o *Options) DefaultPowerVSOptions() powervs.RawCreateOptions

func (*Options) Validate added in v0.1.54

func (o *Options) Validate() error

Validate is intended to be called after Complete and validates the options are usable by tests.

type PlatformAgnosticOptions added in v0.1.38

type PlatformAgnosticOptions struct {
	core.RawCreateOptions

	NonePlatform      none.RawCreateOptions
	AWSPlatform       aws.RawCreateOptions
	KubevirtPlatform  kubevirt.RawCreateOptions
	AzurePlatform     azure.RawCreateOptions
	PowerVSPlatform   powervs.RawCreateOptions
	OpenStackPlatform openstack.RawCreateOptions

	ExtOIDCConfig *ExtOIDCConfig
}

type PodExecOptions

type PodExecOptions struct {
	StreamOptions

	Command []string

	PodName       string
	Namespace     string
	ContainerName string

	Timeout time.Duration

	Executor RemoteExecutor
	Config   *restclient.Config
}

PodExecOptions declare the arguments accepted by the Exec command

func (*PodExecOptions) Run

func (p *PodExecOptions) Run(ctx context.Context) error

Run executes a validated remote execution against a pod.

func (*PodExecOptions) Validate

func (p *PodExecOptions) Validate() error

Validate checks that the provided exec options are specified.

type Predicate added in v0.1.38

type Predicate[T any] func(T) (done bool, reasons string, err error)

Predicate evaluates an object. Return whether the object in question matches your predicate, the reasons why or why not, and whether an error occurred. If determining that an object does not match a predicate, a message is required. Returning an error is fatal to the asynchronous assertion using this predicate.

func ConditionPredicate added in v0.1.38

func ConditionPredicate[T client.Object](needle Condition) Predicate[T]

ConditionPredicate returns a predicate that validates that a particular condition type exists and has the requisite status, reason and/or message.

type PrometheusResponse added in v0.1.6

type PrometheusResponse struct {
	Data prometheusResponseData `json:"data"`
}

PrometheusResponse is used to contain prometheus query results

func RunQueryAtTime added in v0.1.6

func RunQueryAtTime(ctx context.Context, log logr.Logger, prometheusClient prometheusv1.API, query string, evaluationTime time.Time) (*PrometheusResponse, error)

type ProviderType added in v0.1.66

type ProviderType string

type RemoteExecutor

type RemoteExecutor interface {
	Execute(ctx context.Context, method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool) error
}

RemoteExecutor defines the interface accepted by the Exec command - provided for test stubbing

type StreamOptions

type StreamOptions struct {
	Stdin bool
	TTY   bool

	genericclioptions.IOStreams
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL