generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Compress components manifests if they don't fit in the configmap #192
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: add e2e test for compressed manifests
- Loading branch information
commit 9d0196699b0d1398424d4ecc564be798e355737d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
const ( | ||
ociInfrastructureProviderName = "oci" | ||
ociInfrastructureProviderVersion = "v0.12.0" | ||
ociInfrastructureProviderDeploymentName = "capoci-controller-manager" | ||
compressedAnnotation = "provider.cluster.x-k8s.io/compressed" | ||
componentsConfigMapKey = "components" | ||
) | ||
|
||
var _ = Describe("Create and delete a provider with manifests that don't fit the configmap", func() { | ||
It("should successfully create a CoreProvider", func() { | ||
k8sclient := bootstrapClusterProxy.GetClient() | ||
coreProvider := &operatorv1.CoreProvider{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: coreProviderName, | ||
Namespace: operatorNamespace, | ||
}, | ||
Spec: operatorv1.CoreProviderSpec{ | ||
ProviderSpec: operatorv1.ProviderSpec{}, | ||
}, | ||
} | ||
|
||
Expect(k8sclient.Create(ctx, coreProvider)).To(Succeed()) | ||
|
||
By("Waiting for the core provider deployment to be ready") | ||
Eventually(func() bool { | ||
isReady, err := waitForDeployment(k8sclient, ctx, coreProviderDeploymentName) | ||
if err != nil { | ||
return false | ||
} | ||
return isReady | ||
}, timeout).Should(Equal(true)) | ||
|
||
By("Waiting for core provider to be ready") | ||
Eventually(func() bool { | ||
coreProvider := &operatorv1.CoreProvider{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: coreProviderName} | ||
if err := k8sclient.Get(ctx, key, coreProvider); err != nil { | ||
return false | ||
} | ||
|
||
for _, c := range coreProvider.Status.Conditions { | ||
if c.Type == operatorv1.ProviderInstalledCondition && c.Status == corev1.ConditionTrue { | ||
return true | ||
} | ||
} | ||
return false | ||
}, timeout).Should(Equal(true)) | ||
|
||
By("Waiting for status.IntalledVersion to be set") | ||
Eventually(func() bool { | ||
coreProvider := &operatorv1.CoreProvider{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: coreProviderName} | ||
if err := k8sclient.Get(ctx, key, coreProvider); err != nil { | ||
return false | ||
} | ||
|
||
if coreProvider.Status.InstalledVersion != nil && *coreProvider.Status.InstalledVersion == coreProvider.Spec.Version { | ||
return true | ||
} | ||
return false | ||
}, timeout).Should(Equal(true)) | ||
}) | ||
|
||
It("should successfully create and delete an InfrastructureProvider for OCI", func() { | ||
k8sclient := bootstrapClusterProxy.GetClient() | ||
infraProvider := &operatorv1.InfrastructureProvider{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: ociInfrastructureProviderName, | ||
Namespace: operatorNamespace, | ||
}, | ||
Spec: operatorv1.InfrastructureProviderSpec{ | ||
ProviderSpec: operatorv1.ProviderSpec{ | ||
Version: ociInfrastructureProviderVersion, | ||
}, | ||
}, | ||
} | ||
|
||
Expect(k8sclient.Create(ctx, infraProvider)).To(Succeed()) | ||
|
||
By("Waiting for the infrastructure provider to be ready") | ||
Eventually(func() bool { | ||
infraProvider := &operatorv1.InfrastructureProvider{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: ociInfrastructureProviderName} | ||
if err := k8sclient.Get(ctx, key, infraProvider); err != nil { | ||
return false | ||
} | ||
|
||
for _, c := range infraProvider.Status.Conditions { | ||
if c.Type == operatorv1.ProviderInstalledCondition && c.Status == corev1.ConditionTrue { | ||
return true | ||
} | ||
} | ||
return false | ||
}, timeout).Should(Equal(true)) | ||
|
||
By("Waiting for status.IntalledVersion to be set") | ||
Eventually(func() bool { | ||
infraProvider := &operatorv1.InfrastructureProvider{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: ociInfrastructureProviderName} | ||
if err := k8sclient.Get(ctx, key, infraProvider); err != nil { | ||
return false | ||
} | ||
|
||
if infraProvider.Status.InstalledVersion != nil && *infraProvider.Status.InstalledVersion == infraProvider.Spec.Version { | ||
return true | ||
} | ||
return false | ||
}, timeout).Should(Equal(true)) | ||
|
||
By("Ensure that the created config map has correct annotation") | ||
cm := &corev1.ConfigMap{} | ||
cmName := fmt.Sprintf("infrastructure-%s-%s", ociInfrastructureProviderName, ociInfrastructureProviderVersion) | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: cmName} | ||
Expect(k8sclient.Get(ctx, key, cm)).To(Succeed()) | ||
|
||
Expect(cm.GetAnnotations()[compressedAnnotation]).To(Equal("true")) | ||
|
||
Expect(cm.BinaryData[componentsConfigMapKey]).ToNot(BeEmpty()) | ||
|
||
Expect(k8sclient.Delete(ctx, infraProvider)).To(Succeed()) | ||
|
||
By("Waiting for the infrastructure provider deployment to be created") | ||
Eventually(func() bool { | ||
deployment := &appsv1.Deployment{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: ociInfrastructureProviderDeploymentName} | ||
|
||
return k8sclient.Get(ctx, key, deployment) == nil | ||
}, timeout).Should(Equal(true)) | ||
|
||
By("Waiting for the infrastructure provider deployment to be deleted") | ||
Eventually(func() bool { | ||
deployment := &appsv1.Deployment{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: ociInfrastructureProviderDeploymentName} | ||
isInfraProviderDeleted, err := waitForObjectToBeDeleted(k8sclient, ctx, key, deployment) | ||
if err != nil { | ||
return false | ||
} | ||
return isInfraProviderDeleted | ||
}, timeout).Should(Equal(true)) | ||
}) | ||
|
||
It("should successfully delete a CoreProvider", func() { | ||
k8sclient := bootstrapClusterProxy.GetClient() | ||
coreProvider := &operatorv1.CoreProvider{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: coreProviderName, | ||
Namespace: operatorNamespace, | ||
}, | ||
Spec: operatorv1.CoreProviderSpec{ | ||
ProviderSpec: operatorv1.ProviderSpec{}, | ||
}, | ||
} | ||
|
||
Expect(k8sclient.Delete(ctx, coreProvider)).To(Succeed()) | ||
|
||
By("Waiting for the core provider deployment to be deleted") | ||
Eventually(func() bool { | ||
deployment := &appsv1.Deployment{} | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: coreProviderDeploymentName} | ||
isReady, err := waitForObjectToBeDeleted(k8sclient, ctx, key, deployment) | ||
if err != nil { | ||
return false | ||
} | ||
return isReady | ||
}, timeout).Should(Equal(true)) | ||
|
||
By("Waiting for the core provider object to be deleted") | ||
Eventually(func() bool { | ||
key := client.ObjectKey{Namespace: operatorNamespace, Name: coreProviderName} | ||
isReady, err := waitForObjectToBeDeleted(k8sclient, ctx, key, coreProvider) | ||
if err != nil { | ||
return false | ||
} | ||
return isReady | ||
}, timeout).Should(Equal(true)) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also have a test where we supply an already compressed configmap? Can be done in a follow-up PR