Skip to content

Commit

Permalink
Automated Config Connector import.
Browse files Browse the repository at this point in the history
  - 2b1397a6b784b696adb3a28341965aed1d2680db Fix testDriftCorrection test. by Config Connector Team <[email protected]>

GitOrigin-RevId: 2b1397a6b784b696adb3a28341965aed1d2680db
  • Loading branch information
Config Connector Team authored and copybara-github committed Feb 16, 2023
1 parent a7ad0fe commit a49b7a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/controller/dynamic/dynamic_controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,25 +395,25 @@ func testDriftCorrection(t *testing.T, testContext testrunner.TestContext, syste
return
}
kubeClient := systemContext.Manager.GetClient()
u := testContext.CreateUnstruct.DeepCopy()
if err := kubeClient.Get(context.TODO(), testContext.NamespacedName, u); err != nil {
testUnstruct := testContext.CreateUnstruct.DeepCopy()
if err := kubeClient.Get(context.TODO(), testContext.NamespacedName, testUnstruct); err != nil {
t.Fatalf("unexpected error getting k8s resource: %v", err)
}

// Delete all events for the resource so that we can check later at the end
// of this test that the right events are recorded.
testcontroller.DeleteAllEventsForUnstruct(t, kubeClient, u)
testcontroller.DeleteAllEventsForUnstruct(t, kubeClient, testUnstruct)

if err := resourceContext.Delete(t, u, systemContext.TFProvider, systemContext.Manager.GetClient(), systemContext.SMLoader, systemContext.DCLConfig, systemContext.DCLConverter); err != nil {
if err := resourceContext.Delete(t, testUnstruct, systemContext.TFProvider, systemContext.Manager.GetClient(), systemContext.SMLoader, systemContext.DCLConfig, systemContext.DCLConverter); err != nil {
t.Fatalf("error deleting: %v", err)
}
// Underlying APIs may not have strongly-consistent reads due to caching. Sleep before attempting a re-reconcile, to
// give the underlying system some time to propagate the deletion info.
time.Sleep(time.Second * 10)

// get the current state
systemContext.Reconciler.Reconcile(testContext.CreateUnstruct, testreconciler.ExpectedSuccessfulReconcileResultFor(systemContext.Reconciler, testContext.CreateUnstruct.GroupVersionKind()), nil)
validateCreate(t, testContext, systemContext, resourceContext, u.GetGeneration())
systemContext.Reconciler.Reconcile(testUnstruct, testreconciler.ExpectedSuccessfulReconcileResultFor(systemContext.Reconciler, testUnstruct.GroupVersionKind()), nil)
validateCreate(t, testContext, systemContext, resourceContext, testUnstruct.GetGeneration())
}

func shouldSkipDriftDetection(t *testing.T, resourceContext contexts.ResourceContext, smLoader *servicemappingloader.ServiceMappingLoader,
Expand Down

0 comments on commit a49b7a0

Please sign in to comment.