forked from rh-ecosystem-edge/eco-gotests
-
Notifications
You must be signed in to change notification settings - Fork 11
Add 6 standalone FAR destructive tests and improve test resiliency #49
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
Merged
openshift-merge-bot
merged 4 commits into
medik8s:main
from
ugreener:feat/far-standalone-tests
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
729f700
far-operator: add standalone FAR destructive tests
ugreener a1afcab
far-operator: fix racy pod-running smoke test (OCP-66026)
ugreener c15a7dc
helpers: add randomized node selection and oc debug namespace fix
ugreener c6b2b8f
test-runner: add --randomize-all to ginkgo command
ugreener 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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
|
|
||
| coordinationv1 "k8s.io/api/coordination/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
|
|
||
| "github.com/rh-ecosystem-edge/eco-goinfra/pkg/deployment" | ||
| "github.com/rh-ecosystem-edge/eco-goinfra/pkg/reportxml" | ||
|
|
||
| "github.com/medik8s/system-tests/tests/far-operator/internal/farparams" | ||
| "github.com/medik8s/system-tests/tests/far-operator/internal/farutils" | ||
| "github.com/medik8s/system-tests/tests/internal/labels" | ||
| . "github.com/medik8s/system-tests/tests/internal/medik8sinittools" | ||
| "github.com/medik8s/system-tests/tests/internal/medik8sparams" | ||
| ) | ||
|
|
||
| var _ = Describe("FAR Controller Lifecycle Tests", | ||
| Serial, | ||
| Label(labels.OperatorFAR, farparams.Label, | ||
| labels.DisruptionNonDestructive), | ||
| func() { | ||
| var ctx context.Context | ||
|
|
||
| BeforeEach(func() { | ||
| ctx = context.Background() | ||
|
|
||
| By("Verifying FAR controller deployment is Ready") | ||
|
|
||
| farDeployment, err := deployment.Pull( | ||
| APIClient, farparams.OperatorDeploymentName, medik8sparams.OperatorNs) | ||
| Expect(err).ToNot(HaveOccurred(), "Failed to get FAR deployment") | ||
| Expect(farDeployment.IsReady(medik8sparams.DefaultTimeout)).To(BeTrue(), | ||
| "FAR deployment is not Ready") | ||
| }) | ||
|
|
||
| It("should transfer controller leadership when the active pod is deleted", | ||
| Label(labels.TierAcceptance, labels.ComponentController), | ||
| reportxml.ID("OCP-70636"), | ||
| func() { | ||
| By("Getting the current active FAR controller pod") | ||
|
|
||
| pods, err := farutils.GetFARControllerPods(ctx, APIClient) | ||
| Expect(err).ToNot(HaveOccurred()) | ||
| Expect(pods).ToNot(BeEmpty(), "No running FAR controller pods found") | ||
|
|
||
| oldLeaderNode, err := farutils.GetActiveFARControllerNode(ctx, APIClient) | ||
| Expect(err).ToNot(HaveOccurred()) | ||
|
|
||
| var oldLeaderPod *corev1.Pod | ||
|
|
||
| for i := range pods { | ||
| if pods[i].Spec.NodeName == oldLeaderNode { | ||
| oldLeaderPod = &pods[i] | ||
|
|
||
| break | ||
| } | ||
| } | ||
|
|
||
| Expect(oldLeaderPod).ToNot(BeNil(), | ||
| "Could not find controller pod on leader node %s", oldLeaderNode) | ||
|
|
||
| oldPodName := oldLeaderPod.Name | ||
| GinkgoWriter.Printf("Active controller pod: %s on node %s\n", | ||
| oldPodName, oldLeaderNode) | ||
|
|
||
| By("Deleting the active controller pod " + oldPodName) | ||
|
|
||
| Expect(APIClient.Delete(ctx, oldLeaderPod)).To(Succeed()) | ||
|
|
||
| By("Waiting for FAR controller deployment to become ready") | ||
|
|
||
| farDeployment, err := deployment.Pull( | ||
| APIClient, farparams.OperatorDeploymentName, medik8sparams.OperatorNs) | ||
| Expect(err).ToNot(HaveOccurred(), "Failed to pull FAR controller deployment") | ||
| Expect(farDeployment.IsReady(farparams.ControllerHandoverTimeout)).To(BeTrue(), | ||
| "FAR deployment did not become ready after pod deletion") | ||
|
|
||
| By("Verifying controller lease transferred to a different pod") | ||
|
|
||
| Eventually(func(assertion Gomega) { | ||
| lease := &coordinationv1.Lease{} | ||
| assertion.Expect(APIClient.Get(ctx, client.ObjectKey{ | ||
| Name: farparams.ControllerLeaseName, | ||
| Namespace: medik8sparams.OperatorNs, | ||
| }, lease)).To(Succeed()) | ||
| assertion.Expect(lease.Spec.HolderIdentity).ToNot(BeNil(), | ||
| "Lease has no holder after pod deletion") | ||
|
|
||
| if lease.Spec.HolderIdentity != nil { | ||
| assertion.Expect(*lease.Spec.HolderIdentity).ToNot(Equal(oldPodName), | ||
| "Lease is still held by deleted pod %s", oldPodName) | ||
| } | ||
|
|
||
| newPods, err := farutils.GetFARControllerPods(ctx, APIClient) | ||
| assertion.Expect(err).ToNot(HaveOccurred()) | ||
|
|
||
| hasNewRunningPod := false | ||
|
|
||
| for _, p := range newPods { | ||
| if p.Name != oldPodName && p.Status.Phase == corev1.PodRunning { | ||
| hasNewRunningPod = true | ||
|
|
||
| break | ||
| } | ||
| } | ||
|
|
||
| assertion.Expect(hasNewRunningPod).To(BeTrue(), | ||
| "No new Running controller pod found after deleting %s", oldPodName) | ||
| }, farparams.ControllerHandoverTimeout, farparams.DefaultPollInterval).Should(Succeed(), | ||
| "Controller leadership did not transfer after pod deletion") | ||
| }) | ||
| }) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.