Skip to content

Commit

Permalink
Perform full chart install in e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
  • Loading branch information
Danil-Grigorev committed Dec 20, 2024
1 parent d03c162 commit 5eddc0d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ var (

// helmChart is the helm chart helper to be used for the e2e tests.
helmChart *HelmChart

// fullHelmChart is the helm chart wrapper to install operator in e2e tests.
fullHelmChart *HelmChart
)

func init() {
Expand Down Expand Up @@ -366,6 +369,16 @@ func initHelmChart() {
DryRun: true,
Output: Hooks,
}

fullHelmChart = &HelmChart{
BinaryPath: helmBinaryPath,
Path: chartPath,
Name: "capi-operator",
Kubeconfig: helmClusterProxy.GetKubeconfigPath(),
Wait: true,
Output: Full,
AdditionalFlags: Flags("--create-namespace", "--namespace", operatorNamespace),
}
}

// Using a SynchronizedAfterSuite for controlling how to delete resources shared across ParallelNodes (~ginkgo threads).
Expand Down
69 changes: 69 additions & 0 deletions test/e2e/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,79 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
. "sigs.k8s.io/cluster-api-operator/test/framework"
"sigs.k8s.io/cluster-api/test/framework"
)

var _ = Describe("Create a proper set of manifests when using helm charts", func() {
It("should deploy a quick-start cluster-api-operator chart", func() {
_, err := fullHelmChart.Run(nil)
Expect(err).ToNot(HaveOccurred())

clusterProxy := helmClusterProxy.GetClient()
coreProvider := &operatorv1.CoreProvider{
ObjectMeta: metav1.ObjectMeta{
Name: coreProviderName,
Namespace: operatorNamespace,
},
}
Expect(clusterProxy.Create(ctx, coreProvider)).To(Succeed())

By("Waiting for the core provider deployment to be ready")
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: clusterProxy,
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: coreProviderDeploymentName, Namespace: operatorNamespace}},
}, e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for core provider to be ready")
WaitFor(ctx, For(coreProvider).In(clusterProxy).ToSatisfy(
HaveStatusCondition(&coreProvider.Status.Conditions, operatorv1.ProviderInstalledCondition),
), e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
WaitFor(ctx, For(coreProvider).In(clusterProxy).ToSatisfy(func() bool {
return ptr.Equal(coreProvider.Status.InstalledVersion, ptr.To(coreProvider.Spec.Version))
}), e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)

bootstrapProvider := &operatorv1.BootstrapProvider{ObjectMeta: metav1.ObjectMeta{
Name: bootstrapProviderName,
Namespace: operatorNamespace,
}}
deployment := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: bootstrapProviderDeploymentName,
Namespace: operatorNamespace,
}}

Expect(clusterProxy.Create(ctx, bootstrapProvider)).To(Succeed())

By("Waiting for the bootstrap provider deployment to be ready")
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: clusterProxy,
Deployment: deployment,
}, e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for bootstrap provider to be ready")
WaitFor(ctx, For(bootstrapProvider).In(clusterProxy).ToSatisfy(
HaveStatusCondition(&bootstrapProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
WaitFor(ctx, For(bootstrapProvider).In(clusterProxy).ToSatisfy(func() bool {
return ptr.Equal(bootstrapProvider.Status.InstalledVersion, &bootstrapProvider.Spec.Version)
}), e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)
Expect(clusterProxy.Delete(ctx, bootstrapProvider)).To(Succeed())

By("Waiting for the bootstrap provider deployment to be deleted")
WaitForDelete(ctx, For(deployment).In(clusterProxy),
e2eConfig.GetIntervals(helmClusterProxy.GetName(), "wait-controllers")...)

Expect(clusterProxy.Delete(ctx, coreProvider)).To(Succeed())
})

It("should deploy default manifest set for quick-start process", func() {
fullRun := &HelmChart{
BinaryPath: helmChart.BinaryPath,
Expand Down

0 comments on commit 5eddc0d

Please sign in to comment.