-
Notifications
You must be signed in to change notification settings - Fork 80
SREP-1215: E2E delete primary cert bundle secret if exist #372
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
Open
karanjitsingh01
wants to merge
4
commits into
openshift:master
Choose a base branch
from
karanjitsingh01:SREP-1215_E2E_Delete_primary_cert_bundle_secret_if_exist
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ed7048a
SREP-1215: Initial commit for delete primary cert bundle if exists
karanjitsingh01 b468766
updated timestamp as 2 min as per test case
karanjitsingh01 cb8b529
Merge branch 'openshift:master' into SREP-1215_E2E_Delete_primary_cer…
karanjitsingh01 2baf287
Merge branch 'openshift:master' into SREP-1215_E2E_Delete_primary_cer…
karanjitsingh01 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
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,12 +6,14 @@ package osde2etests | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "time" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| configv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" | ||
| "github.com/openshift/osde2e-common/pkg/clients/openshift" | ||
| "k8s.io/apimachinery/pkg/api/errors" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/client-go/kubernetes" | ||
| "sigs.k8s.io/controller-runtime/pkg/log" | ||
|
|
@@ -24,8 +26,9 @@ var _ = Describe("Certman Operator", Ordered, func() { | |
| secretName string | ||
| ) | ||
| const ( | ||
| pollingDuration = 15 * time.Minute | ||
| namespace = "openshift-config" | ||
| pollingDuration = 15 * time.Minute | ||
| namespace = "openshift-config" | ||
| namespace_certman_operator = "certman-operator" | ||
| ) | ||
|
|
||
| BeforeAll(func(ctx context.Context) { | ||
|
|
@@ -62,4 +65,33 @@ var _ = Describe("Certman Operator", Ordered, func() { | |
| return apiserver.Spec.ServingCerts.NamedCertificates[0].ServingCertificate.Name == secretName | ||
| }, pollingDuration, 30*time.Second).Should(BeTrue(), "Certificate secret should be applied to apiserver object") | ||
| }) | ||
|
|
||
| It("delete secret, primary-cert-bundle-secret, if exists", func(ctx context.Context) { | ||
| secretNameToDelete := "primary-cert-bundle-secret" | ||
| pollingDuration := 2 * time.Minute | ||
| pollInterval := 30 * time.Second | ||
|
|
||
| originalSecret, err := clientset.CoreV1().Secrets(namespace_certman_operator).Get(ctx, secretNameToDelete, metav1.GetOptions{}) | ||
| if errors.IsNotFound(err) { | ||
| log.Log.Info("Secret does not exist, skipping deletion test.") | ||
| return | ||
| } | ||
| Expect(err).ShouldNot(HaveOccurred(), "Error retrieving the original secret") | ||
|
|
||
| originalTimestamp := originalSecret.CreationTimestamp.Time | ||
| log.Log.Info(fmt.Sprintf("Original secret creation timestamp: %v", originalTimestamp)) | ||
|
|
||
| err = clientset.CoreV1().Secrets(namespace_certman_operator).Delete(ctx, secretNameToDelete, metav1.DeleteOptions{}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think we should call the client and delete the |
||
| Expect(err).ShouldNot(HaveOccurred(), "Failed to delete the secret") | ||
|
|
||
| Eventually(func() bool { | ||
| newSecret, err := clientset.CoreV1().Secrets(namespace_certman_operator).Get(ctx, secretNameToDelete, metav1.GetOptions{}) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| return newSecret.CreationTimestamp.Time.After(originalTimestamp) | ||
| }, pollingDuration, pollInterval).Should(BeTrue(), | ||
| fmt.Sprintf("Secret %q was not re-created within %v or timestamp did not change", secretNameToDelete, pollingDuration)) | ||
| }) | ||
|
|
||
| }) | ||
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.