-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adds e2e for arc reconciliation (#679)
* feat: adds e2e for arc reconciliation Signed-off-by: Nilekh Chaudhari <[email protected]> * test: removes focus test Signed-off-by: Nilekh Chaudhari <[email protected]> * chore: fixes template path Signed-off-by: Nilekh Chaudhari <[email protected]> * test: removes unused imports Signed-off-by: Nilekh Chaudhari <[email protected]> * chore: removes debug Signed-off-by: Nilekh Chaudhari <[email protected]> * chore: removes unused import Signed-off-by: Nilekh Chaudhari <[email protected]>
- Loading branch information
Showing
5 changed files
with
119 additions
and
4 deletions.
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
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,61 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/Azure/secrets-store-csi-driver-provider-azure/test/e2e/framework" | ||
"github.com/Azure/secrets-store-csi-driver-provider-azure/test/e2e/framework/daemonset" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
appsv1 "k8s.io/api/apps/v1" | ||
) | ||
|
||
var _ = Describe("When extension arguments are manually overridden", func() { | ||
var ( | ||
daemonSet *appsv1.DaemonSet | ||
newRotationPollIntervalValue = "--rotation-poll-interval=1m" | ||
secretStoreCSIDriverName = "secrets-store-csi-driver" | ||
) | ||
|
||
It("should reconcile them to original values", func() { | ||
if !config.IsArcTest { | ||
Skip("test case only runs while testing arc extension") | ||
} | ||
|
||
daemonSet = daemonset.Get(daemonset.GetInput{ | ||
Namespace: framework.NamespaceKubeSystem, | ||
Name: secretStoreCSIDriverName, | ||
Getter: kubeClient, | ||
}) | ||
Expect(daemonSet).NotTo(BeNil()) | ||
|
||
daemonSet.Spec.Template.Spec.Containers[1].Args = append(daemonSet.Spec.Template.Spec.Containers[1].Args, newRotationPollIntervalValue) | ||
daemonSet = daemonset.Update(daemonset.UpdateInput{ | ||
Updater: kubeClient, | ||
DaemonSet: daemonSet, | ||
}) | ||
Expect(daemonSet).NotTo(BeNil()) | ||
|
||
// waiting for 300 seconds since 'reconcilerIntervalInSeconds' is set to this value in extension configuration | ||
By("Waiting for arc extension to reconcile the arguments") | ||
time.Sleep(time.Second * 300) | ||
|
||
daemonSet = daemonset.Get(daemonset.GetInput{ | ||
Namespace: framework.NamespaceKubeSystem, | ||
Name: secretStoreCSIDriverName, | ||
Getter: kubeClient, | ||
}) | ||
Expect(daemonSet).NotTo(BeNil()) | ||
|
||
for _, arg := range daemonSet.Spec.Template.Spec.Containers[1].Args { | ||
if arg == newRotationPollIntervalValue { | ||
// Manually overridden value should be reverted by arc extension reconciliation | ||
Expect(arg).NotTo(Equal(newRotationPollIntervalValue)) | ||
} | ||
} | ||
}) | ||
}) |
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
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
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,53 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
package daemonset | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/secrets-store-csi-driver-provider-azure/test/e2e/framework" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
appsv1 "k8s.io/api/apps/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
// GetInput is the input for Get. | ||
type GetInput struct { | ||
Getter framework.Getter | ||
Name string | ||
Namespace string | ||
} | ||
|
||
// Get gets a DaemonSet resource. | ||
func Get(input GetInput) *appsv1.DaemonSet { | ||
Expect(input.Getter).NotTo(BeNil(), "input.Getter is required for DaemonSet.Get") | ||
Expect(input.Name).NotTo(BeEmpty(), "input.Name is required for DaemonSet.Get") | ||
Expect(input.Namespace).NotTo(BeEmpty(), "input.Namespace is required for DaemonSet.Get") | ||
|
||
By(fmt.Sprintf("Getting DaemonSet \"%s\"", input.Name)) | ||
|
||
daemonSet := &appsv1.DaemonSet{} | ||
Expect(input.Getter.Get(context.TODO(), types.NamespacedName{Name: input.Name, Namespace: input.Namespace}, daemonSet)).Should(Succeed()) | ||
return daemonSet | ||
} | ||
|
||
// UpdateInput is the input for Update. | ||
type UpdateInput struct { | ||
Updater framework.Updater | ||
DaemonSet *appsv1.DaemonSet | ||
} | ||
|
||
// Update updates a DaemonSet resource. | ||
func Update(input UpdateInput) *appsv1.DaemonSet { | ||
Expect(input.Updater).NotTo(BeNil(), "input.Updater is required for DaemonSet.Update") | ||
Expect(input.DaemonSet).NotTo(BeNil(), "input.DaemonSet is required for DaemonSet.Update") | ||
|
||
By(fmt.Sprintf("Updating DaemonSet \"%s/%s\"", input.DaemonSet.Namespace, input.DaemonSet.Name)) | ||
|
||
Expect(input.Updater.Update(context.TODO(), input.DaemonSet)).Should(Succeed()) | ||
return input.DaemonSet | ||
} |