Skip to content

Commit

Permalink
Update e2e operator test
Browse files Browse the repository at this point in the history
The e2e test was dependant on the operator flag being enabled by defualt.
Now the test will set the operator flag to true temporarily, run the test, and reset to it's original value.
  • Loading branch information
s-fairchild committed Jul 24, 2023
1 parent e395acd commit 5145721
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/e2e/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,21 @@ var _ = Describe("ARO Operator - dnsmasq", func() {
return names
}

// test regardless of the operator flag setting, then set back to original value after tests
enableOperatorFlag := func(g Gomega, ctx context.Context) func(context.Context) {
co, err := clients.AROClusters.AroV1alpha1().Clusters().Get(ctx, "cluster", metav1.GetOptions{})
if kerrors.IsNotFound(err) {
Skip("skipping tests as aro-operator is not deployed")
}

originalFlag := co.Spec.OperatorFlags["aro.dnsmasq.enabled"]
co.Spec.OperatorFlags["aro.dnsmasq.enabled"] = "true"

return func(ctx context.Context) {
co.Spec.OperatorFlags["aro.dnsmasq.enabled"] = originalFlag
}
}

BeforeEach(func(ctx context.Context) {
By("Create custom MachineConfigPool")
_, err := clients.MachineConfig.MachineconfigurationV1().MachineConfigPools().Create(ctx, &customMcp, metav1.CreateOptions{})
Expand All @@ -571,6 +586,8 @@ var _ = Describe("ARO Operator - dnsmasq", func() {
It("must handle the lifetime of the `99-${MCP}-custom-dns MachineConfig for every MachineConfigPool ${MCP}", func(ctx context.Context) {
By("creating an ARO DNS MachineConfig when creating a custom MachineConfigPool")
Eventually(func(g Gomega, ctx context.Context) {
resetFlag := enableOperatorFlag(g, ctx)
defer resetFlag(ctx)
machineConfigs := getMachineConfigNames(g, ctx)
g.Expect(machineConfigs).To(ContainElement(mcName))

Expand Down

0 comments on commit 5145721

Please sign in to comment.