Skip to content

Commit

Permalink
test of the stripped version of controller
Browse files Browse the repository at this point in the history
  • Loading branch information
koala7659 committed Nov 18, 2024
1 parent 986c9a1 commit b64a906
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ func sFnWaitForShootReconcile(_ context.Context, m *fsm, s *systemState) (stateF
return updateStatusAndStop()

case gardener.LastOperationStateSucceeded:
m.log.Info(fmt.Sprintf("Shoot %s successfully updated, moving to processing", s.shoot.Name))
return ensureStatusConditionIsSetAndContinue(
&s.instance,
imv1.ConditionTypeRuntimeProvisioned,
imv1.ConditionReasonConfigurationCompleted,
"Runtime processing completed successfully",
sFnConfigureOidc)
//m.log.Info(fmt.Sprintf("Shoot %s successfully updated, moving to processing", s.shoot.Name))
//return ensureStatusConditionIsSetAndContinue(
// &s.instance,
// imv1.ConditionTypeRuntimeProvisioned,
// imv1.ConditionReasonConfigurationCompleted,
// "Runtime processing completed successfully",
// sFnConfigureOidc)

s.instance.UpdateStateReady(
imv1.ConditionTypeRuntimeConfigured,
imv1.ConditionReasonAdministratorsConfigured,
"Cluster admin configuration complete",
)

return updateStatusAndStop()
}

m.log.Info("sFnWaitForShootReconcile - unknown shoot operation state, stopping state machine", "RuntimeCR", s.instance.Name, "shoot", s.shoot.Name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ func sFnWaitForShootCreation(_ context.Context, m *fsm, s *systemState) (stateFn

case gardener.LastOperationStateSucceeded:
m.log.Info(fmt.Sprintf("Shoot %s successfully created", s.shoot.Name))
return ensureStatusConditionIsSetAndContinue(
&s.instance,
imv1.ConditionTypeRuntimeProvisioned,
imv1.ConditionReasonShootCreationCompleted,
"Shoot creation completed",
sFnCreateKubeconfig)
//return ensureStatusConditionIsSetAndContinue(
// &s.instance,
// imv1.ConditionTypeRuntimeProvisioned,
// imv1.ConditionReasonShootCreationCompleted,
// "Shoot creation completed",
// sFnCreateKubeconfig)

s.instance.UpdateStateReady(
imv1.ConditionTypeRuntimeConfigured,
imv1.ConditionReasonAdministratorsConfigured,
"Cluster admin configuration complete",
)

return updateStatusAndStop()

default:
m.log.Info("WaitForShootCreation - unknown shoot operation state, stopping state machine", "RuntimeCR", s.instance.Name, "shoot", s.shoot.Name)
Expand Down
44 changes: 24 additions & 20 deletions internal/controller/runtime/runtime_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ var _ = Describe("Runtime Controller", func() {
}

// check state
if runtime.Status.State != imv1.RuntimeStatePending {
if runtime.Status.State != imv1.RuntimeStateReady {
return false
}

if !runtime.IsConditionSetWithStatus(imv1.ConditionTypeRuntimeProvisioned, imv1.ConditionReasonShootCreationPending, "Unknown") {
if !runtime.IsConditionSetWithStatus(imv1.ConditionTypeRuntimeConfigured, imv1.ConditionReasonAdministratorsConfigured, "True") {
return false
}

return true
}, time.Second*300, time.Second*3).Should(BeTrue())

// and end as Ready state with ConfigurationCompleted condition == True
Eventually(func() bool {
/*Eventually(func() bool {
runtime := imv1.Runtime{}
if err := k8sClient.Get(ctx, typeNamespacedName, &runtime); err != nil {
return false
Expand Down Expand Up @@ -123,9 +123,9 @@ var _ = Describe("Runtime Controller", func() {
return true
}, time.Second*600, time.Second*3).Should(BeTrue())
Expect(customTracker.IsSequenceFullyUsed()).To(BeTrue())
Expect(customTracker.IsSequenceFullyUsed()).To(BeTrue()) */

By("Wait for Runtime to process shoot update process and finish processing in Ready State")
/*By("Wait for Runtime to process shoot update process and finish processing in Ready State")
setupGardenerTestClientForUpdate()
runtime := imv1.Runtime{}
Expand Down Expand Up @@ -174,9 +174,13 @@ var _ = Describe("Runtime Controller", func() {
return true
}, time.Second*300, time.Second*3).Should(BeTrue())
Expect(customTracker.IsSequenceFullyUsed()).To(BeTrue())
Expect(customTracker.IsSequenceFullyUsed()).To(BeTrue()) */

// next test will be for runtime deletion
runtime := imv1.Runtime{}
err := k8sClient.Get(ctx, typeNamespacedName, &runtime)

Expect(err).To(BeNil())
By("Process deleting of Runtime CR and delete GardenerCluster CR and Shoot")
setupGardenerTestClientForDelete()

Expand All @@ -201,25 +205,25 @@ var _ = Describe("Runtime Controller", func() {
return false
}

if !runtime.IsConditionSet(imv1.ConditionTypeRuntimeDeprovisioned, imv1.ConditionReasonGardenerCRDeleted) {
return false
}
//if !runtime.IsConditionSet(imv1.ConditionTypeRuntimeDeprovisioned, imv1.ConditionReasonGardenerCRDeleted) {
// return false
//}

return true
}, time.Second*300, time.Second*3).Should(BeTrue())

// should delete Shoot and go into RuntimeStateTerminating state with condition GardenerClusterCRDeleted
Eventually(func() bool {
runtime := imv1.Runtime{}
if err := k8sClient.Get(ctx, typeNamespacedName, &runtime); err != nil {
return false
}

if !runtime.IsConditionSet(imv1.ConditionTypeRuntimeDeprovisioned, imv1.ConditionReasonGardenerShootDeleted) {
return false
}
return true
}, time.Second*300, time.Second*3).Should(BeTrue())
//Eventually(func() bool {
// runtime := imv1.Runtime{}
// if err := k8sClient.Get(ctx, typeNamespacedName, &runtime); err != nil {
// return false
// }
//
// if !runtime.IsConditionSet(imv1.ConditionTypeRuntimeDeprovisioned, imv1.ConditionReasonGardenerShootDeleted) {
// return false
// }
// return true
//}, time.Second*300, time.Second*3).Should(BeTrue())

// Make sure the instance is finally deleted
Eventually(func() bool {
Expand Down

0 comments on commit b64a906

Please sign in to comment.