Skip to content

Commit

Permalink
Merge pull request #39 from pagopa/add-env-on-massive-notify-error-re…
Browse files Browse the repository at this point in the history
…cover-limit

feat: Add env to customize limit on io error to notify massive recover
  • Loading branch information
pasqualespica authored Dec 18, 2023
2 parents 4786fd4 + a01dc1c commit a6351cb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
1 change: 1 addition & 0 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ microservice-chart:
NOT_NOTIFIED_AUTORECOVER_ENABLED: "true"
RECOVER_FAILED_MASSIVE_MAX_DAYS: "0"
RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0"
IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES: "2"
envConfigMapExternals:
template-maps:
BRAND_LOGO_MAP: brand-logo-map
Expand Down
1 change: 1 addition & 0 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ microservice-chart:
NOT_NOTIFIED_AUTORECOVER_ENABLED: "true"
RECOVER_FAILED_MASSIVE_MAX_DAYS: "0"
RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0"
IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES: "2"
envConfigMapExternals:
template-maps:
BRAND_LOGO_MAP: brand-logo-map
Expand Down
1 change: 1 addition & 0 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ microservice-chart:
NOT_NOTIFIED_AUTORECOVER_ENABLED: "true"
RECOVER_FAILED_MASSIVE_MAX_DAYS: "0"
RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0"
IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES: "2"
envConfigMapExternals:
template-maps:
BRAND_LOGO_MAP: brand-logo-map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

public class RecoverNotNotifiedReceiptUtils {

private static final int IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES = Integer.parseInt(System.getenv().getOrDefault("IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES", "2"));

public static Receipt restoreReceipt(Receipt receipt) {
receipt.setStatus(ReceiptStatusType.GENERATED);
receipt.setNotificationNumRetry(0);
Expand Down Expand Up @@ -40,7 +42,7 @@ public static List<Receipt> receiptMassiveRestore(ReceiptStatusType statusType,
continuationToken = page.getContinuationToken();
}
totalPages++;
} while (continuationToken != null && totalPages < 10);
} while (continuationToken != null && totalPages < IO_ERROR_TO_NOTIFY_MASSIVE_RECOVER_MAX_PAGES);
return receiptList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -124,18 +123,9 @@ void recoverNotNotifiedReceiptMassiveForIOErrorToNotifySuccessWithMoreThan10Page
FeedResponse feedResponseMock = mock(FeedResponse.class);
when(feedResponseMock.getResults())
.thenReturn(Collections.singletonList(buildReceipt(ReceiptStatusType.IO_ERROR_TO_NOTIFY)));
when(feedResponseMock.getContinuationToken())
.thenReturn("token", "token", "token", "token", "token", "token", "token", "token", "token", "token");
when(feedResponseMock.getContinuationToken()).thenReturn("token", "token");
when(receiptCosmosServiceMock.getNotNotifiedReceiptByStatus(any(), any(), any()))
.thenReturn(Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock),
Collections.singletonList(feedResponseMock));
Expand All @@ -155,7 +145,7 @@ void recoverNotNotifiedReceiptMassiveForIOErrorToNotifySuccessWithMoreThan10Page

verify(documentReceipts).setValue(receiptCaptor.capture());

assertEquals(10, receiptCaptor.getValue().size());
assertEquals(2, receiptCaptor.getValue().size());
}

@Test
Expand Down

0 comments on commit a6351cb

Please sign in to comment.