Documentation ¶
Index ¶
- Constants
- Variables
- func CreateCatalogSourceFromConfigMap(logger logrus.FieldLogger, name, namespace, configMapName string, ...) error
- func CreateCatalogSourceFromImage(logger logrus.FieldLogger, client olmclientv1alpha1.OperatorsV1alpha1Interface, ...) (*olmv1alpha1.CatalogSource, error)
- func CreateRegistryDeployment(logger logrus.FieldLogger, client kubernetes.Interface, ...) error
- func CreateRegistryService(logger logrus.FieldLogger, client kubernetes.Interface, ...) (string, error)
- func CreateUpgradeConfigMap(logger logrus.FieldLogger, name, namespace, scriptPath string) error
- func DeleteAllReportDataSources(logger logrus.FieldLogger, client meteringclient.MeteringV1Interface, ...) error
- func DeleteAllTestReports(logger logrus.FieldLogger, client meteringclient.MeteringV1Interface, ...) error
- func DeleteRegistryDeployment(logger logrus.FieldLogger, client kubernetes.Interface, ...) error
- func DeleteRegistryService(logger logrus.FieldLogger, client kubernetes.Interface, ...) error
- func GetServiceAccountToken(client kubernetes.Interface, initialDelay, timeoutPeriod time.Duration, ...) (string, error)
- func UpdateExistingSubscription(logger logrus.FieldLogger, client olmclientv1alpha1.OperatorsV1alpha1Interface, ...) error
- func VerifyCatalogSourcePod(logger logrus.FieldLogger, client kubernetes.Interface, ...) error
- func VerifyConfigMap(logger logrus.FieldLogger, client kubernetes.Interface, name, namespace string) error
- func WaitForMeteringOperatorDeployment(logger logrus.FieldLogger, client kubernetes.Interface, name, namespace string) error
- func WaitForReportDataSources(logger logrus.FieldLogger, client meteringclient.MeteringV1Interface, ...) error
- func WaitForReportingOperatorDeployment(logger logrus.FieldLogger, client kubernetes.Interface, name, namespace string) error
- type DeployFramework
- func (df *DeployFramework) CreateCatalogSourceFromIndex(indexImage string) (string, string, error)
- func (df *DeployFramework) CreateRegistryResources(registryImage, meteringOperatorImage, reportingOperatorImage string) (string, string, error)
- func (df *DeployFramework) DeleteRegistryResources(registryProvisioned bool, name, namespace string) error
- func (df *DeployFramework) NewDeployerConfig(namespace, meteringOperatorImageRepo, meteringOperatorImageTag, ... string, ...) (*deploy.Config, error)
- func (df *DeployFramework) NewDeployerCtx(namespace, meteringOperatorImageRepo, meteringOperatorImageTag, ... string, ...) (*DeployerCtx, error)
- func (df *DeployFramework) WaitForPackageManifest(name, namespace, subscriptionChannel string) error
- type DeployerCtx
- func (ctx *DeployerCtx) MustGatherMeteringResources(scriptName string) error
- func (ctx *DeployerCtx) NewLocalCtx() *LocalCtx
- func (ctx *DeployerCtx) Setup(installFunc func() error) (*reportingframework.ReportingFramework, error)
- func (ctx *DeployerCtx) Teardown(uninstallFunc func() error) error
- func (ctx *DeployerCtx) Upgrade(catalogSourceName, catalogSourceNamespace, upgradeChannel string, ...) (*reportingframework.ReportingFramework, error)
- type LocalCtx
- type PodWaiter
Constants ¶
const ( DefaultTargetPods = 7 DefaultPlatform = "openshift" DefaultSubscriptionName = "metering-ocp" DefaultCatalogSourceName = "metering-dev-catalogsource" DefaultPackageName = "metering-ocp" DefaultDeleteNamespace = true DefaultDeleteCRB = true DefaultDeletePVC = true DefaultDeleteCRD = false )
Variables ¶
var ErrInstallPlanFailed = errors.New("detected failing InstallPlan")
ErrInstallPlanFailed represents a failing InstallPlan during an individual metering installation instantiated by OLM.
Functions ¶
func CreateCatalogSourceFromConfigMap ¶
func CreateCatalogSourceFromConfigMap(logger logrus.FieldLogger, name, namespace, configMapName string, client olmclientv1alpha1.OperatorsV1alpha1Interface) error
func CreateCatalogSourceFromImage ¶
func CreateCatalogSourceFromImage(logger logrus.FieldLogger, client olmclientv1alpha1.OperatorsV1alpha1Interface, name, namespace, imageName string) (*olmv1alpha1.CatalogSource, error)
CreateCatalogSourceFromImage is responsible for attempting to create a CatalogSource custom resource based on an index image source type.
func CreateRegistryDeployment ¶
func CreateRegistryDeployment( logger logrus.FieldLogger, client kubernetes.Interface, namespacePrefix, manifestPath, registryImage, meteringOperatorImage, reportingOperatorImage, namespace string, ) error
CreateRegistryDeployment is a helper function responsible for building up and creating a local registry Deployment based on the @manifestPath YAML manifest object. In the case where the metering-operator or reporting-operator images have been overrided, we need to do some manipulation of the decoded deployment object to ensure we propagate those custom images when manipulating the CSV images.
func CreateRegistryService ¶
func CreateRegistryService(logger logrus.FieldLogger, client kubernetes.Interface, namespacePrefix, manifestPath, namespace string) (string, error)
CreateRegistryService is a helper function responsible for decoding the @manifestPath registry Service YAML manifest into a Go object, which we then attempt to create in the @namespace. We're namely interested in the spec.ClusterIP that gets populated once the service object has been created, which we can then reference in a CatalogSource custom resource (`spec.addr`).
func CreateUpgradeConfigMap ¶
func CreateUpgradeConfigMap(logger logrus.FieldLogger, name, namespace, scriptPath string) error
CreateUpgradeConfigMap is a helper function responsible for creating a ConfigMap that contains the current version of the repositories' CRDs, CSV and metering-ocp package which OLM can then consume through a CatalogSource. In order to create this ConfigMap, we execute a bash script that handles the heavy-lifting, overriding any of the environment variables that the script uses, to match our current deployment context.
func DeleteAllReportDataSources ¶
func DeleteAllReportDataSources(logger logrus.FieldLogger, client meteringclient.MeteringV1Interface, namespace string) error
func DeleteAllTestReports ¶
func DeleteAllTestReports(logger logrus.FieldLogger, client meteringclient.MeteringV1Interface, namespace string) error
func DeleteRegistryDeployment ¶
func DeleteRegistryDeployment(logger logrus.FieldLogger, client kubernetes.Interface, namespace, labelSelector string) error
DeleteRegistryDeployment is a helper function responsible for listing all of the registry deployments in the @namespace that match the @labelSelector label selector, and deleting any deployments that get returned from that list.
func DeleteRegistryService ¶
func DeleteRegistryService(logger logrus.FieldLogger, client kubernetes.Interface, namespace, labelSelector string) error
DeleteRegistryService is a helper function responsible for listing all of the registry services in the @namespace that match the @labelSelector parameters, and deleting any services that get returned from that list
func GetServiceAccountToken ¶
func GetServiceAccountToken(client kubernetes.Interface, initialDelay, timeoutPeriod time.Duration, namespace, serviceAccountName string) (string, error)
GetServiceAccountToken queries the namespace for the service account and attempts to find the secret that contains the serviceAccount token and return it.
func UpdateExistingSubscription ¶
func UpdateExistingSubscription(logger logrus.FieldLogger, client olmclientv1alpha1.OperatorsV1alpha1Interface, name, namespace, catalogSourceName, catalogSourceNamespace, upgradeSubscriptionChannel string) error
UpdateExistingSubscription is a helper function responsible for upgrading an existing metering-ocp Subscription to use the newest payload and verify that the Subscription object is reporting a successful upgrade status.
func VerifyCatalogSourcePod ¶
func VerifyCatalogSourcePod(logger logrus.FieldLogger, client kubernetes.Interface, packageName, namespace string) error
VerifyCatalogSourcePod is a deployframework helper function that checks the @namespace and verifies that there's a ready Pod that was created by an OLM CatalogSource resource.
func VerifyConfigMap ¶
func VerifyConfigMap(logger logrus.FieldLogger, client kubernetes.Interface, name, namespace string) error
VerifyConfigMap is a helper function that polls until the @name ConfigMap has been created in the @namespace namespace.
func WaitForMeteringOperatorDeployment ¶
func WaitForMeteringOperatorDeployment(logger logrus.FieldLogger, client kubernetes.Interface, name, namespace string) error
WaitForMeteringOperatorDeployment is a helper function that will poll for the @name deployment every ten seconds, waiting until that deployment reports a single signed 32-bit integer for both of the UpdatedReplicas and Replicas status fields, which will indicate a successful upgrade status.
func WaitForReportDataSources ¶
func WaitForReportDataSources(logger logrus.FieldLogger, client meteringclient.MeteringV1Interface, namespace string) error
func WaitForReportingOperatorDeployment ¶
func WaitForReportingOperatorDeployment(logger logrus.FieldLogger, client kubernetes.Interface, name, namespace string) error
WaitForReportingOperatorDeployment is a helper function that will poll for the @name deployment every twenty seconds, waiting until that deployment reports a successful upgrade status. Note: the reporting-operator deployment uses a RollingUpdate strategy which means we need to be careful about marking a deployment as "Ready" when there's two reporting-operator Pods in the @namespace. This means we should instead keep polling until there's a single replica.
Types ¶
type DeployFramework ¶
type DeployFramework struct { RunLocal bool RunDevSetup bool KubeConfigPath string NamespacePrefix string RepoDir string RepoVersion string OperatorResources *deploy.OperatorResources Logger logrus.FieldLogger Config *rest.Config Client kubernetes.Interface APIExtClient apiextclientv1.CustomResourceDefinitionsGetter MeteringClient meteringclient.MeteringV1Interface OLMV1Client olmclientv1.OperatorsV1Interface OLMV1Alpha1Client olmclientv1alpha1.OperatorsV1alpha1Interface }
DeployFramework contains all the information necessary to deploy different metering instances and run tests against them
func New ¶
func New(logger logrus.FieldLogger, runLocal, runDevSetup bool, nsPrefix, repoDir, repoVersion, kubeconfig string) (*DeployFramework, error)
New is the constructor function that creates and returns a new DeployFramework object
func (*DeployFramework) CreateCatalogSourceFromIndex ¶
func (df *DeployFramework) CreateCatalogSourceFromIndex(indexImage string) (string, string, error)
func (*DeployFramework) CreateRegistryResources ¶
func (df *DeployFramework) CreateRegistryResources(registryImage, meteringOperatorImage, reportingOperatorImage string) (string, string, error)
CreateRegistryResources is a deployframework method responsible for instantiating a new CatalogSource that can be used throughout individual Metering installations.
func (*DeployFramework) DeleteRegistryResources ¶
func (df *DeployFramework) DeleteRegistryResources(registryProvisioned bool, name, namespace string) error
DeleteRegistryResources is a deployframework method responsible for cleaning up any registry resources that were created during the execution of the testing suite. Note: we add a label to the registry service and deployment manifests to help distinguish between resources created by a particular developer, which is reflected in the label selector that we pass to the helper functions that do the heavy-lifting.
func (*DeployFramework) NewDeployerConfig ¶
func (df *DeployFramework) NewDeployerConfig( namespace, meteringOperatorImageRepo, meteringOperatorImageTag, reportingOperatorImageRepo, reportingOperatorImageTag, catalogSourceName, catalogSourceNamespace, subscriptionChannel string, deleteNamespace, deleteCRDs, deleteCRBs, deletePVCs bool, spec metering.MeteringConfigSpec, ) (*deploy.Config, error)
NewDeployerConfig handles the process of validating inputs before returning an initialized Deploy.Config object, or an error if there is any.
func (*DeployFramework) NewDeployerCtx ¶
func (df *DeployFramework) NewDeployerCtx( namespace, meteringOperatorImageRepo, meteringOperatorImageTag, reportingOperatorImageRepo, reportingOperatorImageTag, catalogSourceName, catalogSourceNamespace, subscriptionChannel, outputPath string, extraLocalEnvVars []string, deleteNamespace, deleteCRD, deleteCRB, deletePVC bool, spec metering.MeteringConfigSpec, ) (*DeployerCtx, error)
NewDeployerCtx constructs and returns a new DeployerCtx object
func (*DeployFramework) WaitForPackageManifest ¶
func (df *DeployFramework) WaitForPackageManifest(name, namespace, subscriptionChannel string) error
WaitForPackageManifest is a deployframework method responsible for ensuring the packagemanifest that gets created as a result of df.CreateRegistryResources. We can define "readiness" here by polling until the metering-ocp packagemanifest has the @subscriptionChannel present in one of the channels listed in the package. Note: in the case where an invalid subscription channel has been passed to the e2e suite, this would essentially act as a verification check as well.
type DeployerCtx ¶
type DeployerCtx struct { TargetPodsCount int Namespace string KubeConfigPath string TestCaseOutputPath string HackScriptPath string MeteringOperatorImageRepo string MeteringOperatorImageTag string RunTestLocal bool RunDevSetup bool ExtraLocalEnvVars []string LocalCtx *LocalCtx Deployer *deploy.Deployer Logger logrus.FieldLogger LoggerOutFile *os.File Config *rest.Config Client kubernetes.Interface APIExtClient apiextclientv1.CustomResourceDefinitionsGetter MeteringClient meteringclient.MeteringV1Interface OLMV1Client olmclientv1.OperatorsV1Interface OLMV1Alpha1Client olmclientv1alpha1.OperatorsV1alpha1Interface }
DeployerCtx contains all the information needed to manage the full lifecycle of a single metering deployment
func (*DeployerCtx) MustGatherMeteringResources ¶
func (ctx *DeployerCtx) MustGatherMeteringResources(scriptName string) error
MustGatherMeteringResources is a method that's responsible for running the @scriptName bash script to gather metering-related resources.
func (*DeployerCtx) NewLocalCtx ¶
func (ctx *DeployerCtx) NewLocalCtx() *LocalCtx
NewLocalCtx returns a new LocalCtx object
func (*DeployerCtx) Setup ¶
func (ctx *DeployerCtx) Setup(installFunc func() error) (*reportingframework.ReportingFramework, error)
Setup handles the process of deploying metering, and waiting for all the necessary resources to become ready in order to proceeed with running the reporting tests. This returns an initialized reportingframework object, or an error if there is any.
func (*DeployerCtx) Teardown ¶
func (ctx *DeployerCtx) Teardown(uninstallFunc func() error) error
Teardown is a method that creates the resource and container logging directories, then populates those directories by executing the cleanup bash script, while streaming the script output to stdout. Once the cleanup script has finished execution, we can uninstall the metering stack and return an error if there is any.
func (*DeployerCtx) Upgrade ¶
func (ctx *DeployerCtx) Upgrade(catalogSourceName, catalogSourceNamespace, upgradeChannel string, purgeReports, purgeReportDataSources bool) (*reportingframework.ReportingFramework, error)
Upgrade is a method that is responsible for creating the necessary resources to upgrade an existing Metering OLM install to use the most up-to-date manifest files (CRDs, CSV, package.yaml). We store these manifest files in a ConfigMap, which in turn a CatalogSource can reference. Once those resources are created, and we have verified their state, we can update the existing metering Subscription to reference this new CatalogSource which holds the newest payload. Once the Subscription has been updated, we need to verify that the metering-operator and it's operands (namely the reporting-operator) have reported a "Ready" status that we define, before we start constructing and returning a reportingframework object.
type LocalCtx ¶
type LocalCtx struct { Namespace string BasePath string KubeConfigPath string HackScriptPath string MeteringOperatorImage string ReportingAPIURL string RunReportingOperatorScriptPath string ExtraReportingOperatorEnvVars []string CmdArr []exec.Cmd Logger logrus.FieldLogger }
LocalCtx holds all the necessary information to run e2e tests locally
func (*LocalCtx) CleanupLocal ¶
CleanupLocal removes all resources that were created while running e2e locally
func (*LocalCtx) RunMeteringOperatorLocal ¶
RunMeteringOperatorLocal is a method that runs the metering-operator locally
type PodWaiter ¶
type PodWaiter struct { InitialDelay time.Duration TimeoutPeriod time.Duration Logger logrus.FieldLogger Client kubernetes.Interface OLMClient olmclientv1alpha1.OperatorsV1alpha1Interface }
func (*PodWaiter) WaitForPods ¶
WaitForPods periodically polls the list of pods in the namespace and ensures the metering pods created are considered ready. In order to exit the polling loop, the number of pods listed must match the expected number of targetPodsCount, and all pod containers listed must report a ready status.