Skip to content

Commit

Permalink
fix: TestCRDDeleteBeforeRemoveCustomResourceV1
Browse files Browse the repository at this point in the history
Wait for maagement conflict metric after manual change, with the
current sync labels.
  • Loading branch information
karlkfi committed Sep 12, 2023
1 parent 9810d28 commit 945403c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions e2e/testcases/custom_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ func TestCRDDeleteBeforeRemoveCustomResourceV1(t *testing.T) {
nt.T.Fatal(err)
}

rootSyncLabels, err := nomostest.MetricLabelsForRootSync(nt, rootSyncNN)
if err != nil {
nt.T.Fatal(err)
}

err = nomostest.ValidateMetrics(nt,
nomostest.ReconcilerErrorMetrics(nt, rootSyncLabels, firstCommitHash, metrics.ErrorSummary{
// Remediator conflict after the first commit, because the declared
// Anvil was deleted by another client after successful sync.
// TODO: distinguish between management conflict (spec/generation drift) and concurrent status update conflict (resource version change)
Conflicts: 1,
}))
if err != nil {
nt.T.Fatal(err)
}

// Reset discovery client to invalidate the cached Anvil CRD
nt.RenewClient()

Expand All @@ -230,17 +246,12 @@ func TestCRDDeleteBeforeRemoveCustomResourceV1(t *testing.T) {

nt.WaitForRootSyncSourceError(configsync.RootSyncName, status.UnknownKindErrorCode, "")

rootSyncLabels, err := nomostest.MetricLabelsForRootSync(nt, rootSyncNN)
rootSyncLabels, err = nomostest.MetricLabelsForRootSync(nt, rootSyncNN)
if err != nil {
nt.T.Fatal(err)
}

err = nomostest.ValidateMetrics(nt,
nomostest.ReconcilerErrorMetrics(nt, rootSyncLabels, firstCommitHash, metrics.ErrorSummary{
// Remediator conflict after the first commit, because the declared
// Anvil was deleted by another client after successful sync.
Conflicts: 1,
}),
nomostest.ReconcilerErrorMetrics(nt, rootSyncLabels, secondCommitHash, metrics.ErrorSummary{
// No remediator conflict after the second commit, because the
// reconciler hasn't been updated with the latest declared resources,
Expand Down

0 comments on commit 945403c

Please sign in to comment.