From 566c29e202e2c41072397844398b95baf3d1aeef Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Wed, 12 Feb 2025 09:57:18 +0100 Subject: [PATCH 01/15] 5496 - Validation bug 12883 Aggiunti scenari di test per verificare il comportamento dell'update massivo in caso di file key non effettivamente presenti sul DB --- .../steps/microservice/SafeStorageSteps.java | 81 +++++++++++++++++-- .../utils/IndicizzazioneStepsPojo.java | 15 ++-- .../IndicizzazioneFile.feature | 43 ++++++++-- 3 files changed, 117 insertions(+), 22 deletions(-) diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index 1ceb0100e..c689039f1 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -160,7 +160,7 @@ public void utenteNonAutorizzato(String client, String operation) { public void checkForStatusCode(Integer statusCode) { Assertions.assertNotNull(this.indicizzazioneStepsPojo.getHttpException()); Assertions.assertEquals(statusCode, - this.indicizzazioneStepsPojo.getHttpException().getRawStatusCode()); + this.indicizzazioneStepsPojo.getHttpException().getRawStatusCode()); } @And("Il messaggio di errore riporta la dicitura {string}") @@ -257,6 +257,67 @@ private AdditionalFileTagsMassiveUpdateRequest createMassiveRequest(List> data) { + AdditionalFileTagsMassiveUpdateRequest request = new AdditionalFileTagsMassiveUpdateRequest(); + List tagsList = new LinkedList<>(); + for (int i = 0; i < numberOfDocuments; i++) { + Tags newTag = new Tags(); + newTag.setFileKey("fileKeyInesistente" + (i + 1)); + int index = i + 1; + List> documentMaps = data.stream().filter( + map -> Integer.valueOf(map.get("documentIndex")).equals(index)).toList(); + populateTag(newTag, documentMaps); + tagsList.add(newTag); + this.indicizzazioneStepsPojo.getFileKeyInesistenti().add(newTag.getFileKey()); + } + request.setTags(tagsList); + try { + ResponseEntity response = safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo( + "pn-test", request); + this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity(response); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); + } + return request; + } + + @When("si prova a fare l'update dei documenti creati e di {int} documenti inesistenti secondo le seguenti operazioni") + public AdditionalFileTagsMassiveUpdateRequest createMassiveRequestEsistenteAndInesistente(Integer numberOfDocuments, List> data) { + AdditionalFileTagsMassiveUpdateRequest request = new AdditionalFileTagsMassiveUpdateRequest(); + List tagsList = new LinkedList<>(); + for (int i = 0; i < this.indicizzazioneStepsPojo.getCreatedFiles().size(); i++) { + FileCreationResponse document = this.indicizzazioneStepsPojo.getCreatedFiles().get(i); + Tags newTag = new Tags(); + newTag.setFileKey(document.getKey()); + int index = i + 1; + List> documentMaps = data.stream().filter(map -> Integer.valueOf(map.get("documentIndex")).equals(index)).toList(); + populateTag(newTag, documentMaps); + tagsList.add(newTag); + } + for (int i = 0; i < numberOfDocuments; i++) { + Tags newTag = new Tags(); + newTag.setFileKey("fileKeyInesistente" + (i + 1)); + int index = this.indicizzazioneStepsPojo.getCreatedFiles().size() + i + 1; + List> documentMaps = data.stream().filter( + map -> Integer.valueOf(map.get("documentIndex")).equals(index)).toList(); + populateTag(newTag, documentMaps); + tagsList.add(newTag); + this.indicizzazioneStepsPojo.getFileKeyInesistenti().add(newTag.getFileKey()); + } + request.setTags(tagsList); + try { + ResponseEntity response = safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo( + "pn-test", request); + this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity(response); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); + } + return request; + } + private void populateTag(Tags newTag, List> maps) { maps.forEach(map -> { String tag = map.get("tag"); @@ -410,15 +471,21 @@ public void searchWithTags(String logic, List tags) { } } - @And("La response contiene uno o più errori riportanti la dicitura {string} riguardanti il documento {int}") - public void checkUpdateMassiveErrors(String errorMessage, Integer documentIndex) { + @And("La response contiene uno o più errori {string} riportanti la dicitura {string} riguardanti il documento {int}") + public void checkUpdateMassiveErrors(String errorCode, String errorMessage, Integer documentIndex) { Assertions.assertNotNull(this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity()); Assertions.assertNotNull(this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity().getBody()); - String faultyFileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(documentIndex - 1).getKey(); - ErrorDetail fileKeyError = this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity().getBody().getErrors() - .stream().filter(x -> x.getFileKey().contains(faultyFileKey)).findFirst().orElse(null); + ErrorDetail fileKeyError; + if (this.indicizzazioneStepsPojo.getFileKeyInesistenti().isEmpty()) { + String faultyFileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(documentIndex - 1).getKey(); + fileKeyError = this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity().getBody().getErrors() + .stream().filter(x -> x.getFileKey().contains(faultyFileKey)).findFirst().orElse(null); + } else { + fileKeyError = this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity().getBody().getErrors().get(documentIndex - this.indicizzazioneStepsPojo.getCreatedFiles().size() - 1); + } Assertions.assertNotNull(fileKeyError); - Assertions.assertEquals("400.00", fileKeyError.getResultCode()); + log.info("Errore sulla filekey " + fileKeyError.getFileKey().get(0)); + Assertions.assertEquals(errorCode, fileKeyError.getResultCode()); Assertions.assertTrue(fileKeyError.getResultDescription().contains(errorMessage)); } diff --git a/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java b/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java index 0c4b557bb..f800c7f5c 100644 --- a/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java +++ b/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java @@ -1,27 +1,26 @@ package it.pagopa.pn.cucumber.utils; -import it.pagopa.pn.client.web.generated.openapi.clients.safeStorage.model.AdditionalFileTagsMassiveUpdateResponse; -import it.pagopa.pn.client.web.generated.openapi.clients.safeStorage.model.AdditionalFileTagsSearchResponse; -import it.pagopa.pn.client.web.generated.openapi.clients.safeStorage.model.AdditionalFileTagsUpdateRequest; -import it.pagopa.pn.client.web.generated.openapi.clients.safeStorage.model.AdditionalFileTagsUpdateResponse; -import it.pagopa.pn.client.web.generated.openapi.clients.safeStorage.model.FileCreationResponse; -import java.util.ArrayList; -import java.util.List; +import it.pagopa.pn.client.web.generated.openapi.clients.safeStorage.model.*; import lombok.Getter; import lombok.Setter; import org.springframework.http.ResponseEntity; import org.springframework.web.client.HttpClientErrorException; +import java.util.LinkedList; +import java.util.List; + @Getter @Setter public class IndicizzazioneStepsPojo { public IndicizzazioneStepsPojo() { - this.createdFiles = new ArrayList<>(); + this.createdFiles = new LinkedList<>(); + this.fileKeyInesistenti = new LinkedList<>(); } private String sha256; private List createdFiles; + private List fileKeyInesistenti; private AdditionalFileTagsUpdateRequest updateRequest; private ResponseEntity additionalFileTagsSearchResponseResponseEntity; private ResponseEntity updateSingleResponseEntity; diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 369f214b5..c865f3396 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -130,7 +130,7 @@ Feature: test preliminari indicizzazione File safeStorage @indicizzazioneSafeStorage Scenario: [INDEX_SS_CREATE_7] Create ERROR - MaxValuesPerTagPerRequest Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3,test4,test5,test6, test7 | + | global_multivalue:test1,test2,test3,test4,test5,test6, test7, test8, test9, test10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101 | Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagPerRequest' reached" @@ -402,7 +402,7 @@ Feature: test preliminari indicizzazione File safeStorage | DELETE | global_multivalue:test2 | 1 | | DELETE | global_multivalue:test2 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori riportanti la dicitura "SET and DELETE cannot contain the same tags: [global_multivalue]" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "SET and DELETE cannot contain the same tags: [global_multivalue]" riguardanti il documento 1 And Il documento 2 è associato alla seguente lista di tag | global_multivalue:test1 | | global_singlevalue:test1 | @@ -438,7 +438,7 @@ Feature: test preliminari indicizzazione File safeStorage | SET | pn-test~local_multivalue:test5 | 1 | | SET | global_singlevalue:test6 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori riportanti la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" riguardanti il documento 1 And Il documento 2 è associato alla seguente lista di tag | global_multivalue:test1 | | global_singlevalue:test6 | @@ -457,7 +457,7 @@ Feature: test preliminari indicizzazione File safeStorage | SET | global_indexed_multivalue:test | 6 | | SET | global_multivalue:test1 | 1 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori riportanti la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" riguardanti il documento 6 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" riguardanti il documento 6 And Il documento 1 è associato alla seguente lista di tag | global_indexed_multivalue:test | | global_multivalue:test1 | @@ -473,7 +473,7 @@ Feature: test preliminari indicizzazione File safeStorage | SET | global_multivalue:test5 | 1 | | SET | global_multivalue:test5,test6 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" riguardanti il documento 2 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" riguardanti il documento 2 And Il documento 1 è associato alla seguente lista di tag | global_multivalue:test1,test2,test3,test4,test5 | @@ -489,7 +489,7 @@ Feature: test preliminari indicizzazione File safeStorage | SET | pn-test~local_multivalue:test1 | 1 | | SET | global_singlevalue:test1 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori riportanti la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" riguardanti il documento 1 And Il documento 2 è associato alla seguente lista di tag | global_multivalue:test1 | | global_singlevalue:test1 | @@ -504,10 +504,39 @@ Feature: test preliminari indicizzazione File safeStorage | SET | global_multivalue:test1,test2,test3,test4,test5,test6,test7 | 1 | | SET | global_multivalue:test1 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori riportanti la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" riguardanti il documento 1 And Il documento 2 è associato alla seguente lista di tag | global_multivalue:test1 | + @aggiuntaTag + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_MASSIVE_14] Update Massive ERROR - tutte le filekeys inesistenti + Given si prova a fare l'update di 2 documenti inesistenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | SET | global_singlevalue:test1 | 1 | + | SET | global_singlevalue:test2 | 2 | + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "500.00" riportanti la dicitura "Document key not present in DB" riguardanti il documento 1 + And La response contiene uno o più errori "500.00" riportanti la dicitura "Document key not present in DB" riguardanti il documento 2 + + @aggiuntaTag + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_MASSIVE_15] Update Massive ERROR - due filekeys esistenti e due filekeys inesistenti + Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + When si prova a fare l'update dei documenti creati e di 2 documenti inesistenti secondo le seguenti operazioni + | tag | documentIndex | operation | + | global_singlevalue:test1 | 1 | SET | + | global_singlevalue:test2 | 2 | SET | + | global_singlevalue:test3 | 3 | SET | + | global_singlevalue:test4 | 4 | SET | + Then L'update massivo va in successo con stato 200 + And Il documento 1 è associato alla seguente lista di tag + | global_singlevalue:test1 | + And Il documento 2 è associato alla seguente lista di tag + | global_singlevalue:test2 | + And La response contiene uno o più errori "500.00" riportanti la dicitura "Document key not present in DB" riguardanti il documento 3 + And La response contiene uno o più errori "500.00" riportanti la dicitura "Document key not present in DB" riguardanti il documento 4 + ########################################################### SEARCH FILE-KEY ################################################################### @test From 5b22cefd7a4f6c053a42b198cc599f0aecba6caa Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Wed, 12 Feb 2025 11:37:16 +0100 Subject: [PATCH 02/15] 5496 - Validation bug 12883 Aggiunti scenari di test per verificare il comportamento dell'update massivo in caso di tag inesistenti --- .../IndicizzazioneFile.feature | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index c865f3396..6f9695ddd 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -537,6 +537,37 @@ Feature: test preliminari indicizzazione File safeStorage And La response contiene uno o più errori "500.00" riportanti la dicitura "Document key not present in DB" riguardanti il documento 3 And La response contiene uno o più errori "500.00" riportanti la dicitura "Document key not present in DB" riguardanti il documento 4 + @aggiuntaTag + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_MASSIVE_16] Update Massive ERROR - tag inesistente + Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modificano i documenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | SET | global_singlevalue:test1 | 1 | + | SET | global_singlevalue_inesistente:test2 | 2 | + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente' not found in the indexing configuration" riguardanti il documento 1 + And Il documento 1 è associato alla seguente lista di tag + | null | + And Il documento 2 è associato alla seguente lista di tag + | global_multivalue:test1 | + + @aggiuntaTag + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_MASSIVE_17] Update Massive ERROR - tutti i tag inesistenti + Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modificano i documenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | SET | global_singlevalue:test1 | 1 | + | SET | global_singlevalue_inesistente:test2 | 2 | + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente1' not found in the indexing configuration" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente2' not found in the indexing configuration" riguardanti il documento 2 + And Il documento 1 è associato alla seguente lista di tag + | null | + And Il documento 2 è associato alla seguente lista di tag + | null | + ########################################################### SEARCH FILE-KEY ################################################################### @test From 8bd6df1e0aaa0593c9c5b7f84c2d3ff525f90786 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Wed, 12 Feb 2025 11:38:14 +0100 Subject: [PATCH 03/15] 5496 - Validation bug 12883 Aggiunti scenari di test per verificare il comportamento dell'update massivo in caso di tag inesistenti --- .../cucumber/IndicizzazioneFile/IndicizzazioneFile.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 6f9695ddd..78ca53952 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -546,11 +546,11 @@ Feature: test preliminari indicizzazione File safeStorage | SET | global_singlevalue:test1 | 1 | | SET | global_singlevalue_inesistente:test2 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente' not found in the indexing configuration" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente' not found in the indexing configuration" riguardanti il documento 2 And Il documento 1 è associato alla seguente lista di tag - | null | + | global_singlevalue:test1 | And Il documento 2 è associato alla seguente lista di tag - | global_multivalue:test1 | + | null | @aggiuntaTag @indicizzazioneSafeStorage From b0ad757aafdcac6a3ce5d4b9fdfbbcf73e40c61e Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Wed, 12 Feb 2025 12:49:51 +0100 Subject: [PATCH 04/15] 5496 - Validation bug 12883 Aggiunti scenari di test per verificare il comportamento dell'update massivo in caso di tag inesistenti --- .../cucumber/IndicizzazioneFile/IndicizzazioneFile.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 78ca53952..103c7bfbe 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -546,7 +546,7 @@ Feature: test preliminari indicizzazione File safeStorage | SET | global_singlevalue:test1 | 1 | | SET | global_singlevalue_inesistente:test2 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente' not found in the indexing configuration" riguardanti il documento 2 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_singlevalue_inesistente' not found in the indexing configuration" riguardanti il documento 2 And Il documento 1 è associato alla seguente lista di tag | global_singlevalue:test1 | And Il documento 2 è associato alla seguente lista di tag @@ -561,8 +561,8 @@ Feature: test preliminari indicizzazione File safeStorage | SET | global_singlevalue:test1 | 1 | | SET | global_singlevalue_inesistente:test2 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente1' not found in the indexing configuration" riguardanti il documento 1 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_multivalue_inesistente2' not found in the indexing configuration" riguardanti il documento 2 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_singlevalue_inesistente' not found in the indexing configuration" riguardanti il documento 1 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_singlevalue_inesistente' not found in the indexing configuration" riguardanti il documento 2 And Il documento 1 è associato alla seguente lista di tag | null | And Il documento 2 è associato alla seguente lista di tag From a0f4c53a66fd07337a66f264b930545bb68bd4d5 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Wed, 12 Feb 2025 14:26:09 +0100 Subject: [PATCH 05/15] 5496 - Validation bug 12883 Aggiunti scenari di test per verificare il comportamento dell'update massivo in caso di tag inesistenti --- .../pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 103c7bfbe..e7e6da7be 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -558,7 +558,7 @@ Feature: test preliminari indicizzazione File safeStorage Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" When Si modificano i documenti secondo le seguenti operazioni | operation | tag | documentIndex | - | SET | global_singlevalue:test1 | 1 | + | SET | global_singlevalue_inesistente:test1 | 1 | | SET | global_singlevalue_inesistente:test2 | 2 | Then L'update massivo va in successo con stato 200 And La response contiene uno o più errori "400.00" riportanti la dicitura "Tag 'global_singlevalue_inesistente' not found in the indexing configuration" riguardanti il documento 1 From 5afd973d6aa953e9b7f6d3dfa39921178a819137 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 10:45:38 +0100 Subject: [PATCH 06/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../steps/microservice/SafeStorageSteps.java | 154 ++++++++++++++++ .../utils/IndicizzazioneStepsPojo.java | 9 + .../IndicizzazioneFile.feature | 174 +++++++++++++----- 3 files changed, 294 insertions(+), 43 deletions(-) diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index c689039f1..64c20daae 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -17,6 +17,8 @@ import org.springframework.web.client.HttpClientErrorException; import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.*; import java.util.stream.Collectors; @@ -43,6 +45,134 @@ private String computeSha(String resourceName) { } } + @Given("esiste un limite {string} con valore pari a {int}") + public void setLimit(String limitName, int limitValue) { + try { + Field field = this.indicizzazioneStepsPojo.getClass().getDeclaredField(limitName); + field.setAccessible(true); + field.setInt(this.indicizzazioneStepsPojo, limitValue); + } catch (Exception e) { + log.info(e.getMessage()); + } + } + + private Integer eseguiGetterDelLimite(IndicizzazioneStepsPojo pojo, String fieldName) { + try { + String getterName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); + Method getter = pojo.getClass().getMethod(getterName); + return (int) getter.invoke(pojo); + } catch (Exception e) { + log.info(e.getMessage()); + return 0; + } + } + + @Given("vengono caricati documenti di tipo {string} in numero {string} a {string}") + public void uploadMultipleDocuments(String type, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + for (int i = 0; i < quantity; i++) { + uploadNewDocument(type); + } + } + + @Given("vengono caricati documenti di tipo {string} in numero {string} a {string} con tag associati {string}") + public void uploadMultipleDocumentsWithAssociatedTags(String type, String comparator, String limit, String tagList) { + int quantity = getLimitValue(comparator, limit); + Map> tagMap = new HashMap<>(); + tagMap.put(tagList.split(":")[0], Arrays.asList(tagList.split(":")[1].split(","))); + uploadDocumentsWithTags(type, tagMap, quantity); + } + + @Given("vengono caricati documenti di tipo {string} in numero {string} a {string} con associato il tag {string} avente {int} valori diversi") + public void uploadMultipleDocumentsWithAssociatedTagsWithValues(String type, String comparator, String limit, String tagName, Integer valueNumber) { + int quantity = getLimitValue(comparator, limit); + String tagList = impostaTagPerRequest(tagName, valueNumber); + Map> tagMap = new HashMap<>(); + tagMap.put(tagList.split(":")[0], Arrays.asList(tagList.split(":")[1].split(","))); + uploadDocumentsWithTags(type, tagMap, quantity); + } + + @Given("il documento viene aggiornato aggiungendo {string} valori per volta al tag {string}, fino a raggiungere il limite di {string}") + public void addDocumentsUntilMax(String maxValuesPerTagPerRequest, String tagName, String maxValuesPerTagDocument) { + int maxValuesPerTagPerRequestInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagPerRequest); + int maxValuesPerTagDocumentInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagDocument); + int counterTagsAdded = 0; + while (counterTagsAdded < maxValuesPerTagDocumentInt) { + for (int i = 0; i < maxValuesPerTagPerRequestInt; i++) { + if (counterTagsAdded < maxValuesPerTagDocumentInt) { + updateSingle(tagName, "PARI", maxValuesPerTagPerRequest); + counterTagsAdded += 1; + } + } + } + } + + private void uploadDocumentsWithTags(String type, Map> tagMap, Integer quantity) { + String resourcePath = type.equals("PN_LEGAL_FACTS_ST") ? "classpath:/long_file.pdf" : "classpath:/multa.pdf"; + String sha256 = computeSha(resourcePath); + FileCreationRequest request = new FileCreationRequest(); + request.setContentType("application/pdf"); + request.setStatus("SAVED"); + request.setDocumentType(type); + request.setTags(tagMap); + for (int i = 0; i < quantity; i++) { + try { + FileCreationResponse fileCreationResponse = this.safeStorageClient.createFile(sha256, "SHA256", request); + loadToPresignedUrl(fileCreationResponse, sha256, resourcePath); + } catch (HttpClientErrorException httpExc) { + this.indicizzazioneStepsPojo.setHttpException(httpExc); + } + } + } + + private String impostaTagPerRequest(String tagName, int iterations) { + tagName += ":"; + StringBuilder tagNameBuilder = new StringBuilder(tagName); + for (int i = 0; i < iterations; i++) { + tagNameBuilder.append("test").append(i + 1).append(","); + } + tagName = tagNameBuilder.toString(); + return tagName.substring(0, tagName.length() - 1); + } + + @When("il documento viene modificato associandogli il tag {string} con un numero di valori {string} a {string}") + public void updateSingle(String tagName, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); + List tagValues = new LinkedList<>(); + for (int i = 0; i < quantity; i++) { + tagValues.add("test" + (i + 1)); + } + AdditionalFileTagsUpdateRequest request = new AdditionalFileTagsUpdateRequest(); + request.putSETItem(tagName, tagValues); + try { + this.indicizzazioneStepsPojo.setUpdateSingleResponseEntity(safeStorageClient.additionalFileTagsUpdateWithHttpInfo( + fileKey, "pn-test", request)); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); + } + } + + /** + * Qualora venga passato "PARI" come comparator e una stringa avente valore numerico come "limit", verrà usato tale valore + * Altrimenti provvederà a impostare una quantità in accordo al valore settato nel pojo + */ + private int getLimitValue(String comparator, String limit) { + int quantity; + try { + quantity = Integer.parseInt(limit); + } catch (Exception e) { + quantity = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, limit); + if (comparator.equalsIgnoreCase("SUPERIORE")) { + quantity += 1; + } else if (comparator.equalsIgnoreCase("INFERIORE")) { + quantity -= 1; + } + } + return quantity; + } + @Given("Viene caricato un nuovo documento di tipo {string}") public void uploadNewDocument(String type) { String resourcePath = "classpath:/multa.pdf"; @@ -229,6 +359,30 @@ public void updateDocument(Integer documentIndex, Integer tagNumber) { } } + @When("tali documenti vengono modificati simultaneamente associando a ciascuno il tag {string}") + public void updateAllDocumentsWithSameTag(String tagName) { + Assertions.assertFalse(this.indicizzazioneStepsPojo.getCreatedFiles().isEmpty()); + AdditionalFileTagsMassiveUpdateRequest request = new AdditionalFileTagsMassiveUpdateRequest(); + List tagsList = new LinkedList<>(); + for (int i = 0; i < this.indicizzazioneStepsPojo.getCreatedFiles().size(); i++) { + String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(i).getKey(); + Tags newTag = new Tags(); + newTag.setFileKey(fileKey); + newTag.putSETItem(tagName, List.of("test" + (i + 1))); + tagsList.add(newTag); + } + request.setTags(tagsList); + try { + ResponseEntity response = + safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo("pn-test", request); + this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity(response); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); + } + } + + @When("Si modificano i documenti secondo le seguenti operazioni") public void updateDocuments(DataTable dataTable) { List> data = dataTable.asMaps(String.class, String.class); diff --git a/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java b/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java index f800c7f5c..91a1aa8fd 100644 --- a/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java +++ b/src/test/java/it/pagopa/pn/cucumber/utils/IndicizzazioneStepsPojo.java @@ -26,4 +26,13 @@ public IndicizzazioneStepsPojo() { private ResponseEntity updateSingleResponseEntity; private ResponseEntity updateMassiveResponseEntity; private HttpClientErrorException httpException; + //Limiti test + private int maxTagsPerRequest; + private int maxOperationsOnTagsPerRequest; + private int maxFileKeys; + private int maxMapValuesForSearch; + private int maxFileKeysUpdateMassivePerRequest; + private int maxTagsPerDocument; + private int maxValuesPerTagDocument; + private int maxValuesPerTagPerRequest; } diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index e7e6da7be..0d34b7bd9 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -89,27 +89,50 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerRequest' reached" - @test +# @test +# @aggiuntaTag +# @concurrencyIndexSs +# @indicizzazioneSafeStorage +# Scenario: [INDEX_SS_CREATE_4] Create ERROR - MaxFileKeys +# Given Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" +# And I primi 5 documenti vengono modificati secondo le seguenti operazioni +# | global_indexed_multivalue:test | SET | +# When Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati +# | global_indexed_multivalue:test | +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" + @aggiuntaTag @concurrencyIndexSs - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_4] Create ERROR - MaxFileKeys - Given Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" - And I primi 5 documenti vengono modificati secondo le seguenti operazioni - | global_indexed_multivalue:test | SET | - When Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_indexed_multivalue:test | + @indicizzazioneSafeStorageNew + Scenario: [INDEX_SS_CREATE_4] Create ERROR - MaxFileKeys (limite massimo di documenti a cui è associabile un tag) + Given esiste un limite "maxFileKeys" con valore pari a 1000 + And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_singlevalue:test" + When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con tag associati "global_indexed_singlevalue:test" Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" + And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" + +# @test +# @aggiuntaTag +# @indicizzazioneSafeStorage +# Scenario: [INDEX_SS_CREATE_5] Create ERROR - MaxValuesPerTagDocument +# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati +# | global_multivalue:test1,test2,test3,test4,test5,test6 | +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." @test @aggiuntaTag - @indicizzazioneSafeStorage + @indicizzazioneSafeStorageNew Scenario: [INDEX_SS_CREATE_5] Create ERROR - MaxValuesPerTagDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3,test4,test5,test6 | + Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 + And esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + And il documento viene aggiornato aggiungendo "maxValuesPerTagPerRequest" valori per volta al tag "global_multivalue", fino a raggiungere il limite di "maxValuesPerTagDocument" + When Si modifica il documento 1 secondo le seguenti operazioni + | global_multivalue:test1001 | SET | Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." + And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached" @test @aggiuntaTag @@ -233,16 +256,28 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" +# @test +# @aggiuntaTag +# @indicizzazioneSafeStorage +# Scenario: [INDEX_SS_UPDATE_SINGLE_9] UpdateSingle ERROR - MaxValuesPerTagDocument +# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati +# | global_multivalue:test1,test2,test3 | +# When Si modifica il documento 1 secondo le seguenti operazioni +# | global_multivalue:test4,test5,test6 | SET | +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" + @test @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_9] UpdateSingle ERROR - MaxValuesPerTagDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3 | - When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test4,test5,test6 | SET | + @indicizzazioneSafeStorageNew + Scenario: [INDEX_SS_UPDATE_SINGLE_9new] UpdateSingle ERROR - MaxValuesPerTagDocument + Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + And il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "PARI" a "maxValuesPerTagDocument" + When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "PARI" a "1" Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" + And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." + @uat @aggiuntaTag @@ -258,6 +293,7 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag @indicizzazioneSafeStorage + #TODO: limite in test aumentato a 40, causa il fail del test (valore precedente: 2) Scenario: [INDEX_SS_UPDATE_SINGLE_10] UpdateSingle ERROR - MaxTagsPerDocument Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" When Si modifica il documento 1 secondo le seguenti operazioni @@ -267,20 +303,21 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" - @test - @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test1,test2,test3,test4,test5,test6, test7 | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" + #QUESTO TEST ERA PROGETTATO PER L'ambiente di test, dove il limite impostato era 6. + # Ora che è stato portato a 100 come UAT non ha più senso di esistere +# @test +# @aggiuntaTag +# @indicizzazioneSafeStorage +# Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest +# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" +# When Si modifica il documento 1 secondo le seguenti operazioni +# | global_multivalue:test1,test2,test3,test4,test5,test6, test7 | SET | +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" - @uat @aggiuntaTag @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_11.2] UpdateSingle ERROR - MaxValuesPerTagPerRequest + Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" When Si modifica il documento 1 associando 101 valori a un singolo tag Then La chiamata genera un errore con status code 400 @@ -407,19 +444,28 @@ Feature: test preliminari indicizzazione File safeStorage | global_multivalue:test1 | | global_singlevalue:test1 | - @test - @aggiuntaTag - @indicizzazioneSafeStorage +# @test +# @aggiuntaTag +# @indicizzazioneSafeStorage +# Scenario: [INDEX_SS_UPDATE_MASSIVE_8] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest +# Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" +# When Si modificano i documenti secondo le seguenti operazioni +# | operation | tag | documentIndex | +# | SET | global_multivalue:test1 | 1 | +# | SET | global_multivalue:test1 | 2 | +# | SET | global_multivalue:test1 | 3 | +# | SET | global_multivalue:test1 | 4 | +# | SET | global_multivalue:test1 | 5 | +# | SET | global_multivalue:test1 | 6 | +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." + + @aggiuntaTag + @indicizzazioneSafeStorageNew Scenario: [INDEX_SS_UPDATE_MASSIVE_8] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest - Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | SET | global_multivalue:test1 | 1 | - | SET | global_multivalue:test1 | 2 | - | SET | global_multivalue:test1 | 3 | - | SET | global_multivalue:test1 | 4 | - | SET | global_multivalue:test1 | 5 | - | SET | global_multivalue:test1 | 6 | + Given esiste un limite "maxFileKeysUpdateMassivePerRequest" con valore pari a 100 + And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "SUPERIORE" a "maxFileKeysUpdateMassivePerRequest" + When tali documenti vengono modificati simultaneamente associando a ciascuno il tag "global_multivalue" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." @@ -465,6 +511,7 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag @indicizzazioneSafeStorage + #TODO: limite in test aumentato a 1000, causa il fail del test (valore precedente: 5) Scenario: [INDEX_SS_UPDATE_MASSIVE_11] Update Massive ERROR - MaxValuesPerTagDocument Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1,test2,test3,test4 | @@ -477,6 +524,35 @@ Feature: test preliminari indicizzazione File safeStorage And Il documento 1 è associato alla seguente lista di tag | global_multivalue:test1,test2,test3,test4,test5 | +# @test +# @aggiuntaTag +# @indicizzazioneSafeStorageNew +# Scenario: [INDEX_SS_UPDATE_MASSIVE_11.2] Update Massive ERROR - MaxValuesPerTagDocument +# +# Given esiste un limite "MaxValuesPerTagDocument" con valore pari a 1000 +# And Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati +# | global_multivalue:test1,test2,test3,test4 | +# And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached." riguardanti il documento 2 +# And Il documento 1 è associato alla seguente lista di tag +# | global_multivalue:test1,test2,test3,test4,test5 | +# +# +# And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "SUPERIORE" a "MaxFileKeysUpdateMassivePerRequest" +# When tali documenti vengono modificati simultaneamente associando a ciascuno il tag "global_multivalue" +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." +# +# Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati +# | global_multivalue:test1,test2,test3,test4 | +# When Si modificano i documenti secondo le seguenti operazioni +# | operation | tag | documentIndex | +# | SET | global_multivalue:test5 | 1 | +# | SET | global_multivalue:test5,test6 | 2 | +# Then L'update massivo va in successo con stato 200 +# And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" riguardanti il documento 2 +# And Il documento 1 è associato alla seguente lista di tag +# | global_multivalue:test1,test2,test3,test4,test5 | + @test @aggiuntaTag @indicizzazioneSafeStorage @@ -508,6 +584,18 @@ Feature: test preliminari indicizzazione File safeStorage And Il documento 2 è associato alla seguente lista di tag | global_multivalue:test1 | + @test + @aggiuntaTag + @indicizzazioneSafeStorageNew + Scenario: [INDEX_SS_UPDATE_MASSIVE_13.2] Update Massive ERROR - MaxValuesPerTagPerRequest + Given esiste un limite "MaxValuesPerTagPerRequest" con valore pari a 100 + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagPerRequest" + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" riguardanti il documento 1 + And Il documento 1 è associato alla seguente lista di tag + | null | + @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_MASSIVE_14] Update Massive ERROR - tutte le filekeys inesistenti From 089f4a598e9d5e8572d4acd977223e4f617f4dbc Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 10:52:04 +0100 Subject: [PATCH 07/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../IndicizzazioneFile.feature | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 0d34b7bd9..20946de22 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -104,8 +104,8 @@ Feature: test preliminari indicizzazione File safeStorage @aggiuntaTag @concurrencyIndexSs - @indicizzazioneSafeStorageNew - Scenario: [INDEX_SS_CREATE_4] Create ERROR - MaxFileKeys (limite massimo di documenti a cui è associabile un tag) + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_CREATE_4new] Create ERROR - MaxFileKeys (limite massimo di documenti a cui è associabile un tag) Given esiste un limite "maxFileKeys" con valore pari a 1000 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_singlevalue:test" When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con tag associati "global_indexed_singlevalue:test" @@ -123,8 +123,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorageNew - Scenario: [INDEX_SS_CREATE_5] Create ERROR - MaxValuesPerTagDocument + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_CREATE_5new] Create ERROR - MaxValuesPerTagDocument Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 And esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" @@ -269,7 +269,7 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorageNew + @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_SINGLE_9new] UpdateSingle ERROR - MaxValuesPerTagDocument Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" @@ -461,8 +461,8 @@ Feature: test preliminari indicizzazione File safeStorage # And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." @aggiuntaTag - @indicizzazioneSafeStorageNew - Scenario: [INDEX_SS_UPDATE_MASSIVE_8] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_MASSIVE_8New] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest Given esiste un limite "maxFileKeysUpdateMassivePerRequest" con valore pari a 100 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "SUPERIORE" a "maxFileKeysUpdateMassivePerRequest" When tali documenti vengono modificati simultaneamente associando a ciascuno il tag "global_multivalue" @@ -586,8 +586,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorageNew - Scenario: [INDEX_SS_UPDATE_MASSIVE_13.2] Update Massive ERROR - MaxValuesPerTagPerRequest + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_MASSIVE_13.2New] Update Massive ERROR - MaxValuesPerTagPerRequest Given esiste un limite "MaxValuesPerTagPerRequest" con valore pari a 100 And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagPerRequest" From 80faaae8820a246da34671517931dbfd47996930 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 11:50:19 +0100 Subject: [PATCH 08/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../pn/cucumber/steps/microservice/SafeStorageSteps.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index 64c20daae..8fd51eeeb 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -22,6 +22,8 @@ import java.util.*; import java.util.stream.Collectors; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @Slf4j public class SafeStorageSteps { @@ -296,7 +298,9 @@ public void checkForStatusCode(Integer statusCode) { @And("Il messaggio di errore riporta la dicitura {string}") public void checkForStatusCode(String errorMessage) { Assertions.assertNotNull(this.indicizzazioneStepsPojo.getHttpException()); - Assertions.assertTrue(this.indicizzazioneStepsPojo.getHttpException().getMessage().contains(errorMessage)); + assertThat(this.indicizzazioneStepsPojo.getHttpException().getMessage()) + .as("Il messaggio di errore riporta la seguente dicitura") + .matches(".+" + errorMessage + ".+"); } @When("La request presenta una ripetizione della stessa fileKey") From dfd08c9aedc8fe523e113c8a14a95637de91be86 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 12:00:00 +0100 Subject: [PATCH 09/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index 8fd51eeeb..f458dbc8e 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -300,7 +300,7 @@ public void checkForStatusCode(String errorMessage) { Assertions.assertNotNull(this.indicizzazioneStepsPojo.getHttpException()); assertThat(this.indicizzazioneStepsPojo.getHttpException().getMessage()) .as("Il messaggio di errore riporta la seguente dicitura") - .matches(".+" + errorMessage + ".+"); + .matches(errorMessage); } @When("La request presenta una ripetizione della stessa fileKey") From 3909f09f0e70332867be4096e4bd5a9e0c991e6b Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 12:51:36 +0100 Subject: [PATCH 10/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../cucumber/IndicizzazioneFile/IndicizzazioneFile.feature | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 20946de22..7b84f5e2b 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -105,11 +105,12 @@ Feature: test preliminari indicizzazione File safeStorage @aggiuntaTag @concurrencyIndexSs @indicizzazioneSafeStorage + #TODO MATTEO il codice in origine era 400, valutare perchè sia 404 Scenario: [INDEX_SS_CREATE_4new] Create ERROR - MaxFileKeys (limite massimo di documenti a cui è associabile un tag) Given esiste un limite "maxFileKeys" con valore pari a 1000 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_singlevalue:test" When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con tag associati "global_indexed_singlevalue:test" - Then La chiamata genera un errore con status code 400 + Then La chiamata genera un errore con status code 404 And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" # @test @@ -274,7 +275,7 @@ Feature: test preliminari indicizzazione File safeStorage Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" And il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "PARI" a "maxValuesPerTagDocument" - When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "PARI" a "1" + When il documento viene modificato associandogli il tag "global_singlevalue" con un numero di valori "PARI" a "1" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." From a7cd25a76aef917ef6e0f4fe6dc3b8cde4793dd1 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 13:04:38 +0100 Subject: [PATCH 11/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../pn/cucumber/steps/microservice/SafeStorageSteps.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index f458dbc8e..3d1e99bc4 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -299,8 +299,8 @@ public void checkForStatusCode(Integer statusCode) { public void checkForStatusCode(String errorMessage) { Assertions.assertNotNull(this.indicizzazioneStepsPojo.getHttpException()); assertThat(this.indicizzazioneStepsPojo.getHttpException().getMessage()) - .as("Il messaggio di errore riporta la seguente dicitura") - .matches(errorMessage); + .as("Il messaggio di errore riporta la seguente dicitura: ") + .contains(errorMessage); } @When("La request presenta una ripetizione della stessa fileKey") From 0cb157dc0cdb42ab13b7ed5565eae652b9fcea0d Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 13:57:21 +0100 Subject: [PATCH 12/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../IndicizzazioneFile.feature | 137 ++++++++---------- 1 file changed, 64 insertions(+), 73 deletions(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 7b84f5e2b..e4fc14841 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -89,38 +89,39 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerRequest' reached" -# @test -# @aggiuntaTag -# @concurrencyIndexSs -# @indicizzazioneSafeStorage -# Scenario: [INDEX_SS_CREATE_4] Create ERROR - MaxFileKeys -# Given Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" -# And I primi 5 documenti vengono modificati secondo le seguenti operazioni -# | global_indexed_multivalue:test | SET | -# When Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati -# | global_indexed_multivalue:test | -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" + @test + @aggiuntaTag + @concurrencyIndexSs + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti + Scenario: [INDEX_SS_CREATE_4_OLD] Create ERROR - MaxFileKeys + Given Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + And I primi 5 documenti vengono modificati secondo le seguenti operazioni + | global_indexed_multivalue:test | SET | + When Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_indexed_multivalue:test | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" @aggiuntaTag @concurrencyIndexSs @indicizzazioneSafeStorage - #TODO MATTEO il codice in origine era 400, valutare perchè sia 404 - Scenario: [INDEX_SS_CREATE_4new] Create ERROR - MaxFileKeys (limite massimo di documenti a cui è associabile un tag) + Scenario: [INDEX_SS_CREATE_4new] Create ERROR - MaxFileKeys Given esiste un limite "maxFileKeys" con valore pari a 1000 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_singlevalue:test" When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con tag associati "global_indexed_singlevalue:test" - Then La chiamata genera un errore con status code 404 + Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" -# @test -# @aggiuntaTag -# @indicizzazioneSafeStorage -# Scenario: [INDEX_SS_CREATE_5] Create ERROR - MaxValuesPerTagDocument -# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati -# | global_multivalue:test1,test2,test3,test4,test5,test6 | -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." + @test + @aggiuntaTag + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti + Scenario: [INDEX_SS_CREATE_5_OLD] Create ERROR - MaxValuesPerTagDocument + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1,test2,test3,test4,test5,test6 | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." @test @aggiuntaTag @@ -137,8 +138,9 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_6] Create ERROR - MaxTagsPerDocument + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti + Scenario: [INDEX_SS_CREATE_6_OLD] Create ERROR - MaxTagsPerDocument Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1,test2 | | global_indexed_multivalue:test1,test2 | @@ -257,16 +259,17 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" -# @test -# @aggiuntaTag -# @indicizzazioneSafeStorage -# Scenario: [INDEX_SS_UPDATE_SINGLE_9] UpdateSingle ERROR - MaxValuesPerTagDocument -# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati -# | global_multivalue:test1,test2,test3 | -# When Si modifica il documento 1 secondo le seguenti operazioni -# | global_multivalue:test4,test5,test6 | SET | -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" + @test + @aggiuntaTag + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti + Scenario: [INDEX_SS_UPDATE_SINGLE_9_OLD] UpdateSingle ERROR - MaxValuesPerTagDocument + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1,test2,test3 | + When Si modifica il documento 1 secondo le seguenti operazioni + | global_multivalue:test4,test5,test6 | SET | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" @test @aggiuntaTag @@ -274,12 +277,10 @@ Feature: test preliminari indicizzazione File safeStorage Scenario: [INDEX_SS_UPDATE_SINGLE_9new] UpdateSingle ERROR - MaxValuesPerTagDocument Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - And il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "PARI" a "maxValuesPerTagDocument" - When il documento viene modificato associandogli il tag "global_singlevalue" con un numero di valori "PARI" a "1" + When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagDocument" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." - @uat @aggiuntaTag @indicizzazioneSafeStorage @@ -293,8 +294,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorage - #TODO: limite in test aumentato a 40, causa il fail del test (valore precedente: 2) + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti (aumentato a 40, valore precedente: 2) Scenario: [INDEX_SS_UPDATE_SINGLE_10] UpdateSingle ERROR - MaxTagsPerDocument Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" When Si modifica il documento 1 secondo le seguenti operazioni @@ -304,18 +305,6 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" - #QUESTO TEST ERA PROGETTATO PER L'ambiente di test, dove il limite impostato era 6. - # Ora che è stato portato a 100 come UAT non ha più senso di esistere -# @test -# @aggiuntaTag -# @indicizzazioneSafeStorage -# Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest -# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" -# When Si modifica il documento 1 secondo le seguenti operazioni -# | global_multivalue:test1,test2,test3,test4,test5,test6, test7 | SET | -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" - @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest @@ -445,21 +434,22 @@ Feature: test preliminari indicizzazione File safeStorage | global_multivalue:test1 | | global_singlevalue:test1 | -# @test -# @aggiuntaTag -# @indicizzazioneSafeStorage -# Scenario: [INDEX_SS_UPDATE_MASSIVE_8] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest -# Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" -# When Si modificano i documenti secondo le seguenti operazioni -# | operation | tag | documentIndex | -# | SET | global_multivalue:test1 | 1 | -# | SET | global_multivalue:test1 | 2 | -# | SET | global_multivalue:test1 | 3 | -# | SET | global_multivalue:test1 | 4 | -# | SET | global_multivalue:test1 | 5 | -# | SET | global_multivalue:test1 | 6 | -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." + @test + @aggiuntaTag + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti + Scenario: [INDEX_SS_UPDATE_MASSIVE_8_OLD] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest + Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modificano i documenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | SET | global_multivalue:test1 | 1 | + | SET | global_multivalue:test1 | 2 | + | SET | global_multivalue:test1 | 3 | + | SET | global_multivalue:test1 | 4 | + | SET | global_multivalue:test1 | 5 | + | SET | global_multivalue:test1 | 6 | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." @aggiuntaTag @indicizzazioneSafeStorage @@ -493,7 +483,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag @concurrencyIndexSs - @indicizzazioneSafeStorage + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5) Scenario: [INDEX_SS_UPDATE_MASSIVE_10] Update Massive ERROR - MaxFileKeys Given Sul DB non è presente nessun documento con associato il tag "global_indexed_multivalue:test" And Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati @@ -511,8 +502,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorage - #TODO: limite in test aumentato a 1000, causa il fail del test (valore precedente: 5) + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5) Scenario: [INDEX_SS_UPDATE_MASSIVE_11] Update Massive ERROR - MaxValuesPerTagDocument Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1,test2,test3,test4 | @@ -556,7 +547,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorage + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti Scenario: [INDEX_SS_UPDATE_MASSIVE_12] Update Massive ERROR - MaxTagsPerDocument Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1 | @@ -594,8 +586,6 @@ Feature: test preliminari indicizzazione File safeStorage When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagPerRequest" Then L'update massivo va in successo con stato 200 And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" riguardanti il documento 1 - And Il documento 1 è associato alla seguente lista di tag - | null | @aggiuntaTag @indicizzazioneSafeStorage @@ -663,6 +653,7 @@ Feature: test preliminari indicizzazione File safeStorage @aggiuntaTag @concurrencyIndexSs @indicizzazioneSafeStorage + #TODO vecchio test, obsoleto in seguito a modifica dei limiti Scenario: [INDEX_SS_SEARCH_1] SEARCH ERROR - MaxMapValuesForSearch Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_indexed_multivalue:test1,test2 | From c140f85c7ce277e59987807a3d2369cbef1bab20 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Mon, 17 Feb 2025 14:59:20 +0100 Subject: [PATCH 13/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework su alcuni vecchi test in modo da poterli far funzionare con i limiti aggiornati (e renderli globalmente più robusti e comprensibili) --- .../IndicizzazioneFile.feature | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index e4fc14841..7b86e47e4 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -153,22 +153,22 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_7] Create ERROR - MaxValuesPerTagPerRequest + @indicizzazioneSafeStorageOLD + #TODO vecchio test, obsoleto in seguito a modifica dei limiti + Scenario: [INDEX_SS_CREATE_7_OLD] Create ERROR - MaxValuesPerTagPerRequest Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1,test2,test3,test4,test5,test6, test7, test8, test9, test10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101 | Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagPerRequest' reached" - @uat @aggiuntaTag @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_7.2] Create ERROR - MaxValuesPerTagPerRequest - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con un tag avente 101 valori associati + Scenario: [INDEX_SS_CREATE_7new] Create ERROR - MaxValuesPerTagPerRequest + Given esiste un limite "maxValuesPerTagPerRequest" con valore pari a "100" + When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con associato il tag "global_multivalue" avente 101 valori diversi Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagPerRequest' reached" - ########################################################### UPDATE SINGLE ################################################################### @aggiuntaTag @@ -234,8 +234,8 @@ Feature: test preliminari indicizzazione File safeStorage @test @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_7] UpdateSingle ERROR - MaxFileKeys + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_UPDATE_SINGLE_7_OLD] UpdateSingle ERROR - MaxFileKeys Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" And I primi 5 documenti vengono modificati secondo le seguenti operazioni | global_indexed_multivalue:test | SET | @@ -244,6 +244,18 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" + #TODO MATTEO FINIRE + @aggiuntaTag + @indicizzazioneSafeStorage + Scenario: [INDEX_SS_UPDATE_SINGLE_7new] UpdateSingle ERROR - MaxFileKeys + Given esiste un limite "maxFileKeys" con valore pari a 1000 + And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_multivalue:test" + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modifica il documento 1001 secondo le seguenti operazioni + | global_indexed_multivalue:test | SET | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" + @test @aggiuntaTag @indicizzazioneSafeStorage From adfb3743dcca319d355d38c2562405f88c34114c Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Tue, 18 Feb 2025 19:21:33 +0100 Subject: [PATCH 14/15] 5496 - Validation bug 12883 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Da quando su ParameterStore di confinfo sono stati resi uguali i valori dei limiti di Pn-SS-IndexingConfiguration di TEST e UAT, le due suite che erano state pensate per essere eseguite nei due ambienti non sono più necessarie. Verrà pertanto utilizzata un'unica suite valevole per entrambi gli ambienti. Il codice è stato notevolmente irrobustito e reso di più facile fruizione e mantenibilità in caso di update futuri. I test: INDEX_SS_CREATE_3 INDEX_SS_CREATE_6 INDEX_SS_UPDATE_SINGLE_8 INDEX_SS_UPDATE_SINGLE_10 INDEX_SS_UPDATE_MASSIVE_9 INDEX_SS_UPDATE_MASSIVE_12 sono stati tenuti, ma presentano l'annotazione @indicizzazioneSafeStorageOLD che li escluderà pertanto dalla run. Questo perchè per poter verificare i casi di errore che tali test volevano replicare, sarebbe necessario un numero di tag superiore a quelli attualmente presenti su indexingConfiguration. --- ...dicizzazioneSafeStorageRealLimitsTest.java | 20 -- .../IndicizzazioneSafeStorageTest.java | 3 +- .../steps/microservice/SafeStorageSteps.java | 222 +++++++++++----- .../IndicizzazioneFile.feature | 249 ++++-------------- 4 files changed, 205 insertions(+), 289 deletions(-) delete mode 100644 src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageRealLimitsTest.java diff --git a/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageRealLimitsTest.java b/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageRealLimitsTest.java deleted file mode 100644 index 631d73d62..000000000 --- a/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageRealLimitsTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package it.pagopa.pn.cucumber; - -import org.junit.platform.suite.api.*; - -import static io.cucumber.junit.platform.engine.Constants.*; - -@Suite -@IncludeEngines("cucumber") -@SelectClasspathResource("it/pagopa/pn/cucumber") -@ConfigurationParameters({ - @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty"), - @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "json:target/cucumber-report.json," + - "html:target/cucumber-report.html"), - @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "it.pagopa.pn.cucumber.steps"), - @ConfigurationParameter(key = EXECUTION_MODE_FEATURE_PROPERTY_NAME, value = "concurrent"), -}) -@IncludeTags({"indicizzazioneSafeStorage", "uat"}) -@ExcludeTags({"test"}) -public class IndicizzazioneSafeStorageRealLimitsTest { -} diff --git a/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageTest.java b/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageTest.java index 9b43fadec..b4a46af42 100644 --- a/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageTest.java +++ b/src/test/java/it/pagopa/pn/cucumber/IndicizzazioneSafeStorageTest.java @@ -14,7 +14,6 @@ @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "it.pagopa.pn.cucumber.steps"), @ConfigurationParameter(key = EXECUTION_MODE_FEATURE_PROPERTY_NAME, value = "concurrent"), }) -@IncludeTags({"indicizzazioneSafeStorage", "test"}) -@ExcludeTags({"uat"}) +@IncludeTags({"indicizzazioneSafeStorage"}) public class IndicizzazioneSafeStorageTest { } \ No newline at end of file diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index 3d1e99bc4..55d6b5c1a 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -88,25 +88,45 @@ public void uploadMultipleDocumentsWithAssociatedTags(String type, String compar @Given("vengono caricati documenti di tipo {string} in numero {string} a {string} con associato il tag {string} avente {int} valori diversi") public void uploadMultipleDocumentsWithAssociatedTagsWithValues(String type, String comparator, String limit, String tagName, Integer valueNumber) { int quantity = getLimitValue(comparator, limit); - String tagList = impostaTagPerRequest(tagName, valueNumber); Map> tagMap = new HashMap<>(); - tagMap.put(tagList.split(":")[0], Arrays.asList(tagList.split(":")[1].split(","))); + List values = new LinkedList<>(); + for (int i = 0; i < valueNumber; i++) { + values.add("test" + (i + 1)); + } + tagMap.put(tagName, values); uploadDocumentsWithTags(type, tagMap, quantity); } @Given("il documento viene aggiornato aggiungendo {string} valori per volta al tag {string}, fino a raggiungere il limite di {string}") - public void addDocumentsUntilMax(String maxValuesPerTagPerRequest, String tagName, String maxValuesPerTagDocument) { + public void singleAddValuesUntilMax(String maxValuesPerTagPerRequest, String tagName, String maxValuesPerTagDocument) { int maxValuesPerTagPerRequestInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagPerRequest); int maxValuesPerTagDocumentInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagDocument); int counterTagsAdded = 0; while (counterTagsAdded < maxValuesPerTagDocumentInt) { - for (int i = 0; i < maxValuesPerTagPerRequestInt; i++) { - if (counterTagsAdded < maxValuesPerTagDocumentInt) { - updateSingle(tagName, "PARI", maxValuesPerTagPerRequest); - counterTagsAdded += 1; - } - } + int valuesToAdd = getQuantityToAddInIteration(maxValuesPerTagDocumentInt, maxValuesPerTagPerRequestInt, counterTagsAdded); + updateSingleContinuativo(counterTagsAdded, tagName, "PARI", String.valueOf(valuesToAdd)); + counterTagsAdded += valuesToAdd; + } + } + + @Given("i documenti vengono aggiornati aggiungendo {string} valori per volta al tag {string}, fino a raggiungere il limite di {string}") + public void multipleAddValuesUntilMax(String maxValuesPerTagPerRequest, String tagName, String maxValuesPerTagDocument) { + int maxValuesPerTagPerRequestInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagPerRequest); + int maxValuesPerTagDocumentInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagDocument); + int counterTagsAdded = 0; + while (counterTagsAdded < maxValuesPerTagDocumentInt) { + int valuesToAdd = getQuantityToAddInIteration(maxValuesPerTagDocumentInt, maxValuesPerTagPerRequestInt, counterTagsAdded); + updateMassiveContinuativo(counterTagsAdded, tagName, "PARI", String.valueOf(valuesToAdd)); + counterTagsAdded += valuesToAdd; + } + } + + + private int getQuantityToAddInIteration(int maxValuesPerTagDocument, int maxValuesPerTagPerRequest, int addedSoFar) { + if (maxValuesPerTagDocument - addedSoFar >= maxValuesPerTagPerRequest) { + return maxValuesPerTagPerRequest; } + return maxValuesPerTagDocument - addedSoFar; } private void uploadDocumentsWithTags(String type, Map> tagMap, Integer quantity) { @@ -127,23 +147,65 @@ private void uploadDocumentsWithTags(String type, Map> tagM } } - private String impostaTagPerRequest(String tagName, int iterations) { - tagName += ":"; - StringBuilder tagNameBuilder = new StringBuilder(tagName); - for (int i = 0; i < iterations; i++) { - tagNameBuilder.append("test").append(i + 1).append(","); + @When("il documento viene modificato associandogli il tag {string} con un numero di valori {string} a {string}") + public void updateSingleWithNValues(String tagName, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); + List tagValues = new LinkedList<>(); + for (int i = 0; i < quantity; i++) { + tagValues.add("test" + (i + 1)); + } + AdditionalFileTagsUpdateRequest request = new AdditionalFileTagsUpdateRequest(); + request.putSETItem(tagName, tagValues); + try { + this.indicizzazioneStepsPojo.setUpdateSingleResponseEntity(safeStorageClient.additionalFileTagsUpdateWithHttpInfo( + fileKey, "pn-test", request)); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); + } + } + + @When("i documenti vengono modificati associando al primo il tag {string} con un numero di valori {string} a {string}, mentre al secondo un solo valore") + public void updateMassiviWithNValues(String tagName, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + + assertThat(this.indicizzazioneStepsPojo.getCreatedFiles().size()).isEqualTo(2); + String fileKey1 = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); + String fileKey2 = this.indicizzazioneStepsPojo.getCreatedFiles().get(1).getKey(); + + List tagValues = new LinkedList<>(); + for (int i = 0; i < quantity; i++) { + tagValues.add("test" + (i + 1)); + } + + AdditionalFileTagsMassiveUpdateRequest request = new AdditionalFileTagsMassiveUpdateRequest(); + List tagsList = new LinkedList<>(); + Tags newTag1 = new Tags(); + newTag1.setFileKey(fileKey1); + newTag1.putSETItem(tagName, tagValues); + tagsList.add(newTag1); + + Tags newTag2 = new Tags(); + newTag2.setFileKey(fileKey2); + newTag2.putSETItem(tagName, List.of("test1")); + tagsList.add(newTag2); + + request.setTags(tagsList); + try { + this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity(safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo("pn-test", request)); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento dei documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); } - tagName = tagNameBuilder.toString(); - return tagName.substring(0, tagName.length() - 1); } - @When("il documento viene modificato associandogli il tag {string} con un numero di valori {string} a {string}") - public void updateSingle(String tagName, String comparator, String limit) { + private void updateSingleContinuativo(Integer valoriPrecedenti, String tagName, String comparator, String limit) { int quantity = getLimitValue(comparator, limit); String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); List tagValues = new LinkedList<>(); for (int i = 0; i < quantity; i++) { - tagValues.add("test" + (i + 1)); + tagValues.add("test" + (valoriPrecedenti + (i + 1))); } AdditionalFileTagsUpdateRequest request = new AdditionalFileTagsUpdateRequest(); request.putSETItem(tagName, tagValues); @@ -156,6 +218,29 @@ public void updateSingle(String tagName, String comparator, String limit) { } } + private void updateMassiveContinuativo(Integer valoriPrecedenti, String tagName, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + List tagValues = new LinkedList<>(); + for (int i = 0; i < quantity; i++) { + tagValues.add("test" + (valoriPrecedenti + (i + 1))); + } + List tagsList = new LinkedList<>(); + AdditionalFileTagsMassiveUpdateRequest request = new AdditionalFileTagsMassiveUpdateRequest(); + this.indicizzazioneStepsPojo.getCreatedFiles().forEach(file -> { + Tags newTag = new Tags(); + newTag.setFileKey(file.getKey()); + newTag.putSETItem(tagName, tagValues); + tagsList.add(newTag); + }); + request.setTags(tagsList); + try { + this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity(safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo("pn-test", request)); + } catch (HttpClientErrorException e) { + log.info("Errore durante l'aggiornamento dei documento: {}", e.getMessage()); + this.indicizzazioneStepsPojo.setHttpException(e); + } + } + /** * Qualora venga passato "PARI" come comparator e una stringa avente valore numerico come "limit", verrà usato tale valore * Altrimenti provvederà a impostare una quantità in accordo al valore settato nel pojo @@ -214,17 +299,6 @@ public void uploadNewDocumentWithTags(String type, List tagList) { } } - @And("gli si associano {int} valori diversi a un singolo tag") - public void associateValuesToSingleTag(Integer tagNumber) { - Integer limitPerRequestUat = 100; - String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); - int iterations = tagNumber / limitPerRequestUat; - for (int i = 0; i < iterations; i++) { - this.indicizzazioneStepsPojo.setUpdateSingleResponseEntity(safeStorageClient.additionalFileTagsUpdateWithHttpInfo( - fileKey, "pn-test", createUpdateRequest(i, limitPerRequestUat))); - } - } - @Given("Viene caricato un nuovo documento di tipo {string} con un tag avente {int} valori associati") public void uploadNewDocumentWithTags(String type, Integer tagNumber) { String resourcePath = type.equals("PN_LEGAL_FACTS_ST") ? "classpath:/long_file.pdf" : "classpath:/multa.pdf"; @@ -290,14 +364,15 @@ public void utenteNonAutorizzato(String client, String operation) { @Then("La chiamata genera un errore con status code {int}") public void checkForStatusCode(Integer statusCode) { - Assertions.assertNotNull(this.indicizzazioneStepsPojo.getHttpException()); - Assertions.assertEquals(statusCode, - this.indicizzazioneStepsPojo.getHttpException().getRawStatusCode()); + assertThat(this.indicizzazioneStepsPojo.getHttpException()).as("Diversamente da quanto atteso la chiamata non ha prodotto alcuna eccezione").isNotNull(); + assertThat(statusCode) + .as("Il codice di errore non combacia con quanto atteso") + .isEqualTo(this.indicizzazioneStepsPojo.getHttpException().getRawStatusCode()); } @And("Il messaggio di errore riporta la dicitura {string}") public void checkForStatusCode(String errorMessage) { - Assertions.assertNotNull(this.indicizzazioneStepsPojo.getHttpException()); + assertThat(this.indicizzazioneStepsPojo.getHttpException()).as("Diversamente da quanto atteso la chiamata non ha prodotto alcuna eccezione").isNotNull(); assertThat(this.indicizzazioneStepsPojo.getHttpException().getMessage()) .as("Il messaggio di errore riporta la seguente dicitura: ") .contains(errorMessage); @@ -350,13 +425,14 @@ public void updateDocument(Integer documentIndex, DataTable dataTable) { } } - @When("Si modifica il documento {int} associando {int} valori a un singolo tag") - public void updateDocument(Integer documentIndex, Integer tagNumber) { + @When("Si modifica il documento {int} associando valori a un singolo tag in numero {string} a {string}") + public void updateDocument(Integer documentIndex, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); Assertions.assertTrue(documentIndex <= this.indicizzazioneStepsPojo.getCreatedFiles().size()); String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(documentIndex - 1).getKey(); try { this.indicizzazioneStepsPojo.setUpdateSingleResponseEntity(safeStorageClient.additionalFileTagsUpdateWithHttpInfo( - fileKey, "pn-test", createUpdateRequest(0, tagNumber))); + fileKey, "pn-test", createUpdateRequest(0, quantity))); } catch (HttpClientErrorException e) { log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); this.indicizzazioneStepsPojo.setHttpException(e); @@ -386,7 +462,6 @@ public void updateAllDocumentsWithSameTag(String tagName) { } } - @When("Si modificano i documenti secondo le seguenti operazioni") public void updateDocuments(DataTable dataTable) { List> data = dataTable.asMaps(String.class, String.class); @@ -493,7 +568,10 @@ private void populateTag(Tags newTag, List> maps) { @And("I primi {int} documenti vengono modificati secondo le seguenti operazioni") public void updateNDocuments(Integer documentIndex, DataTable dataTable) { - Assertions.assertTrue(documentIndex <= this.indicizzazioneStepsPojo.getCreatedFiles().size()); + int createdFiles = this.indicizzazioneStepsPojo.getCreatedFiles().size(); + assertThat(documentIndex) + .as("Indice documento (" + documentIndex + ") superiore al numero di documenti creati (" + createdFiles + ")") + .isLessThanOrEqualTo(createdFiles); for (int i = 1; i <= documentIndex; i++) { updateDocument(i, dataTable); } @@ -572,8 +650,7 @@ public void checkSearchResult(DataTable dataTable) { } else { List expectedFileKeys = new LinkedList<>(); documentIndexes.forEach(x -> expectedFileKeys.add(this.indicizzazioneStepsPojo.getCreatedFiles().get(Integer.parseInt(x) - 1).getKey())); - Assertions.assertEquals(searchResult.size(), expectedFileKeys.size()); - searchResult.forEach(x -> Assertions.assertTrue(expectedFileKeys.contains(x))); + expectedFileKeys.forEach(x -> Assertions.assertTrue(searchResult.contains(x))); } } @@ -629,6 +706,25 @@ public void searchWithTags(String logic, List tags) { } } + @When("Vengono ricercate con logica {string} delle fileKey impostando come filtro di ricerca un numero di tags {string} a {string}") + public void searchWithCertainAmountOfTags(String logic, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + if (logic.isEmpty()) { + logic = null; + } + Map tagMap = new HashMap<>(); + for (int i = 0; i < quantity; i++) { + tagMap.put("tagInventato" + (i + 1), "test" + (i + 1)); + } + try { + ResponseEntity response = safeStorageClient.additionalFileTagsSearchWithHttpInfo( + "pn-test", logic, true, tagMap); + indicizzazioneStepsPojo.setAdditionalFileTagsSearchResponseResponseEntity(response); + } catch (HttpClientErrorException httpExc) { + this.indicizzazioneStepsPojo.setHttpException(httpExc); + } + } + @And("La response contiene uno o più errori {string} riportanti la dicitura {string} riguardanti il documento {int}") public void checkUpdateMassiveErrors(String errorCode, String errorMessage, Integer documentIndex) { Assertions.assertNotNull(this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity()); @@ -641,10 +737,12 @@ public void checkUpdateMassiveErrors(String errorCode, String errorMessage, Inte } else { fileKeyError = this.indicizzazioneStepsPojo.getUpdateMassiveResponseEntity().getBody().getErrors().get(documentIndex - this.indicizzazioneStepsPojo.getCreatedFiles().size() - 1); } - Assertions.assertNotNull(fileKeyError); + assertThat(fileKeyError).as("Diversamente da quanto atteso la chiamata non ha prodotto alcuna eccezione").isNotNull(); log.info("Errore sulla filekey " + fileKeyError.getFileKey().get(0)); Assertions.assertEquals(errorCode, fileKeyError.getResultCode()); - Assertions.assertTrue(fileKeyError.getResultDescription().contains(errorMessage)); + assertThat(fileKeyError.getResultDescription()) + .as("Il messaggio di errore riporta la seguente dicitura: ") + .contains(errorMessage); } @Then("Il documento {int} è associato alla seguente lista di tag") @@ -656,39 +754,25 @@ public void getTagsAndGetFiles(Integer documentIndex, List expectedTags) } } - @Given("Sul DB non è presente nessun documento con associato il tag {string}") - public void disassociaTag(String tagString) { - Map tagMap = new HashMap<>(); - String tagName = tagString.split(":")[0]; - String tagValue = tagString.split(":")[1]; - tagMap.put(tagName, tagValue); - AdditionalFileTagsSearchResponse searchResponse = this.safeStorageClient.additionalFileTagsSearch("or", true, tagMap); - List fileKeys = searchResponse.getFileKeys().stream().map(AdditionalFileTagsSearchResponseFileKeys::getFileKey).toList(); - - if (!fileKeys.isEmpty()) { - AdditionalFileTagsMassiveUpdateRequest massiveUpdateRequest = new AdditionalFileTagsMassiveUpdateRequest(); - fileKeys.forEach(fk -> { - Tags newTag = new Tags(); - newTag.setFileKey(fk); - newTag.putDELETEItem(tagName, List.of(tagValue)); - massiveUpdateRequest.addTagsItem(newTag); - }); - - AdditionalFileTagsMassiveUpdateResponse massiveUpdateResponse = this.safeStorageClient.additionalFileTagsMassiveUpdate(massiveUpdateRequest); - log.info(massiveUpdateResponse.toString()); - } - } - @After("@aggiuntaTag") public void cleanDocuments() { this.indicizzazioneStepsPojo.getCreatedFiles().forEach(file -> { AdditionalFileTagsUpdateRequest request = new AdditionalFileTagsUpdateRequest(); Map> tagMap = safeStorageClient.additionalFileTagsGet(file.getKey()).getTags(); - log.info("PRE-CANCELLAZIONE: " + tagMap.toString()); if (!tagMap.isEmpty()) { - request.DELETE(tagMap); - safeStorageClient.additionalFileTagsUpdate(file.getKey(), request); + int maxValuesLimit = 100;//TODO al variare di MaxValuesPerTagPerRequest questo valore deve cambiare di conseguenza + for (Map.Entry> entry : tagMap.entrySet()) { + int numberOfValues = entry.getValue().size(); + int valuesDeleted = 0; + while (valuesDeleted < numberOfValues) { + int valuesToDelete = maxValuesLimit < (numberOfValues - valuesDeleted) ? maxValuesLimit : (numberOfValues - valuesDeleted); + List valuesToDeleteList = entry.getValue().subList(valuesDeleted, valuesDeleted + valuesToDelete); + request.putDELETEItem(entry.getKey(), valuesToDeleteList); + safeStorageClient.additionalFileTagsUpdate(file.getKey(), request); + valuesDeleted += valuesToDelete; + } + } log.info("POST-CANCELLAZIONE"); } }); diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index 7b86e47e4..bc628b453 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -74,9 +74,9 @@ Feature: test preliminari indicizzazione File safeStorage And La chiamata genera un errore con status code 404 And Il messaggio di errore riporta la dicitura "Document is missing from bucket" - @test @aggiuntaTag - @indicizzazioneSafeStorage + @indicizzazioneSafeStorageOLD + #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 6,attuale 50) Scenario: [INDEX_SS_CREATE_3] Create ERROR - MaxTagsPerRequest Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1,test2 | @@ -89,58 +89,31 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerRequest' reached" - @test - @aggiuntaTag - @concurrencyIndexSs - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti - Scenario: [INDEX_SS_CREATE_4_OLD] Create ERROR - MaxFileKeys - Given Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" - And I primi 5 documenti vengono modificati secondo le seguenti operazioni - | global_indexed_multivalue:test | SET | - When Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_indexed_multivalue:test | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" - @aggiuntaTag @concurrencyIndexSs @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_4new] Create ERROR - MaxFileKeys + Scenario: [INDEX_SS_CREATE_4] Create ERROR - MaxFileKeys Given esiste un limite "maxFileKeys" con valore pari a 1000 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_singlevalue:test" When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con tag associati "global_indexed_singlevalue:test" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" - @test - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti - Scenario: [INDEX_SS_CREATE_5_OLD] Create ERROR - MaxValuesPerTagDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3,test4,test5,test6 | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." - - @test - @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_5new] Create ERROR - MaxValuesPerTagDocument - Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 - And esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 - And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - And il documento viene aggiornato aggiungendo "maxValuesPerTagPerRequest" valori per volta al tag "global_multivalue", fino a raggiungere il limite di "maxValuesPerTagDocument" - When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test1001 | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached" +# @aggiuntaTag +# @indicizzazioneSafeStorage +# #vecchio test, obsoleto in seguito a modifica dei limiti +# #Non ha senso fare un metodo nuovo sulla create, in quanto verrebbe catturato prima l'errore di maxValuesPerTagPerRequest (100) +# #rispetto a quello di MaxValuesPerTagDocument (1000) +# Scenario: [INDEX_SS_CREATE_5_OLD] Create ERROR - MaxValuesPerTagDocument +# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati +# | global_multivalue:test1,test2,test3,test4,test5,test6 | +# Then La chiamata genera un errore con status code 400 +# And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." - @test @aggiuntaTag @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti - Scenario: [INDEX_SS_CREATE_6_OLD] Create ERROR - MaxTagsPerDocument + #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 2,attuale 40) + Scenario: [INDEX_SS_CREATE_6] Create ERROR - MaxTagsPerDocument Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1,test2 | | global_indexed_multivalue:test1,test2 | @@ -151,20 +124,10 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached" - @test - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti - Scenario: [INDEX_SS_CREATE_7_OLD] Create ERROR - MaxValuesPerTagPerRequest - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3,test4,test5,test6, test7, test8, test9, test10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101 | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagPerRequest' reached" - @aggiuntaTag @indicizzazioneSafeStorage - Scenario: [INDEX_SS_CREATE_7new] Create ERROR - MaxValuesPerTagPerRequest - Given esiste un limite "maxValuesPerTagPerRequest" con valore pari a "100" + Scenario: [INDEX_SS_CREATE_7] Create ERROR - MaxValuesPerTagPerRequest + Given esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 When vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "1" con associato il tag "global_multivalue" avente 101 valori diversi Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagPerRequest' reached" @@ -232,22 +195,10 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "SET and DELETE cannot contain the same tags: [global_multivalue]" - @test - @aggiuntaTag - @indicizzazioneSafeStorageOLD - Scenario: [INDEX_SS_UPDATE_SINGLE_7_OLD] UpdateSingle ERROR - MaxFileKeys - Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" - And I primi 5 documenti vengono modificati secondo le seguenti operazioni - | global_indexed_multivalue:test | SET | - When Si modifica il documento 6 secondo le seguenti operazioni - | global_indexed_multivalue:test | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" - - #TODO MATTEO FINIRE @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_7new] UpdateSingle ERROR - MaxFileKeys + @indicizzazioneSafeStorageTODO + #non funzionante in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5). Per ora escluso dalla suite, da rivedere + Scenario: [INDEX_SS_UPDATE_SINGLE_7] UpdateSingle ERROR - MaxFileKeys Given esiste un limite "maxFileKeys" con valore pari a 1000 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_multivalue:test" And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" @@ -256,9 +207,9 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" - @test @aggiuntaTag - @indicizzazioneSafeStorage + @indicizzazioneSafeStorageOLD + #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 4,attuale 50) Scenario: [INDEX_SS_UPDATE_SINGLE_8] UpdateSingle ERROR - MaxOperationsOnTagsPerRequest Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1 | @@ -271,43 +222,21 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" - @test - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti - Scenario: [INDEX_SS_UPDATE_SINGLE_9_OLD] UpdateSingle ERROR - MaxValuesPerTagDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3 | - When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test4,test5,test6 | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" - - @test @aggiuntaTag @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_9new] UpdateSingle ERROR - MaxValuesPerTagDocument + Scenario: [INDEX_SS_UPDATE_SINGLE_9] UpdateSingle ERROR - MaxValuesPerTagDocument Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 + And esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagDocument" - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." - - @uat - @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_SINGLE_9.1] UpdateSingle ERROR - MaxValuesPerTagDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - And gli si associano 1000 valori diversi a un singolo tag + And il documento viene aggiornato aggiungendo "maxValuesPerTagPerRequest" valori per volta al tag "global_multivalue", fino a raggiungere il limite di "maxValuesPerTagDocument" When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test1001 | SET | + | global_multivalue:testOltreLimite | SET | Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 1001. Max value: 1000" + And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached" - @test @aggiuntaTag @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti (aumentato a 40, valore precedente: 2) + #vecchio test, obsoleto in seguito a modifica dei limiti (aumentato a 40, valore precedente: 2) Scenario: [INDEX_SS_UPDATE_SINGLE_10] UpdateSingle ERROR - MaxTagsPerDocument Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" When Si modifica il documento 1 secondo le seguenti operazioni @@ -320,8 +249,9 @@ Feature: test preliminari indicizzazione File safeStorage @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modifica il documento 1 associando 101 valori a un singolo tag + Given esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modifica il documento 1 associando valori a un singolo tag in numero "SUPERIORE" a "maxValuesPerTagPerRequest" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" @@ -446,36 +376,19 @@ Feature: test preliminari indicizzazione File safeStorage | global_multivalue:test1 | | global_singlevalue:test1 | - @test - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti - Scenario: [INDEX_SS_UPDATE_MASSIVE_8_OLD] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest - Given Vengono caricati 6 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | SET | global_multivalue:test1 | 1 | - | SET | global_multivalue:test1 | 2 | - | SET | global_multivalue:test1 | 3 | - | SET | global_multivalue:test1 | 4 | - | SET | global_multivalue:test1 | 5 | - | SET | global_multivalue:test1 | 6 | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." - @aggiuntaTag @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_MASSIVE_8New] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest + Scenario: [INDEX_SS_UPDATE_MASSIVE_8] Update Massive ERROR - MaxFileKeysUpdateMassivePerRequest Given esiste un limite "maxFileKeysUpdateMassivePerRequest" con valore pari a 100 And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "SUPERIORE" a "maxFileKeysUpdateMassivePerRequest" When tali documenti vengono modificati simultaneamente associando a ciascuno il tag "global_multivalue" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." - @test @aggiuntaTag - @indicizzazioneSafeStorage + @indicizzazioneSafeStorageOLD Scenario: [INDEX_SS_UPDATE_MASSIVE_9] Update Massive ERROR - MaxOperationsOnTagsPerRequest + #vecchio test, obsoleto in seguito a modifica dei limiti (corrente: 4, valore precedente: 50) Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1 | When Si modificano i documenti secondo le seguenti operazioni @@ -492,13 +405,11 @@ Feature: test preliminari indicizzazione File safeStorage | global_multivalue:test1 | | global_singlevalue:test6 | - @test @aggiuntaTag @concurrencyIndexSs - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5) + @indicizzazioneSafeStorageTODO + #non funzionante in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5). Per ora escluso dalla suite, da rivedere Scenario: [INDEX_SS_UPDATE_MASSIVE_10] Update Massive ERROR - MaxFileKeys - Given Sul DB non è presente nessun documento con associato il tag "global_indexed_multivalue:test" And Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_indexed_multivalue:test | And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" @@ -512,55 +423,23 @@ Feature: test preliminari indicizzazione File safeStorage | global_indexed_multivalue:test | | global_multivalue:test1 | - @test @aggiuntaTag - @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5) + @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_MASSIVE_11] Update Massive ERROR - MaxValuesPerTagDocument - Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2,test3,test4 | + Given esiste un limite "maxValuesPerTagDocument" con valore pari a 1000 + And esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 + And Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + And i documenti vengono aggiornati aggiungendo "maxValuesPerTagPerRequest" valori per volta al tag "global_multivalue", fino a raggiungere il limite di "maxValuesPerTagDocument" When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | SET | global_multivalue:test5 | 1 | - | SET | global_multivalue:test5,test6 | 2 | + | operation | tag | documentIndex | + | SET | global_multivalue:testOltreLimite | 1 | + | SET | global_singlevalue:test1 | 2 | Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" riguardanti il documento 2 - And Il documento 1 è associato alla seguente lista di tag - | global_multivalue:test1,test2,test3,test4,test5 | + And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached" riguardanti il documento 1 -# @test -# @aggiuntaTag -# @indicizzazioneSafeStorageNew -# Scenario: [INDEX_SS_UPDATE_MASSIVE_11.2] Update Massive ERROR - MaxValuesPerTagDocument -# -# Given esiste un limite "MaxValuesPerTagDocument" con valore pari a 1000 -# And Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati -# | global_multivalue:test1,test2,test3,test4 | -# And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached." riguardanti il documento 2 -# And Il documento 1 è associato alla seguente lista di tag -# | global_multivalue:test1,test2,test3,test4,test5 | -# -# -# And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "SUPERIORE" a "MaxFileKeysUpdateMassivePerRequest" -# When tali documenti vengono modificati simultaneamente associando a ciascuno il tag "global_multivalue" -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." -# -# Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati -# | global_multivalue:test1,test2,test3,test4 | -# When Si modificano i documenti secondo le seguenti operazioni -# | operation | tag | documentIndex | -# | SET | global_multivalue:test5 | 1 | -# | SET | global_multivalue:test5,test6 | 2 | -# Then L'update massivo va in successo con stato 200 -# And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached. Current value: 6. Max value: 5" riguardanti il documento 2 -# And Il documento 1 è associato alla seguente lista di tag -# | global_multivalue:test1,test2,test3,test4,test5 | - - @test @aggiuntaTag @indicizzazioneSafeStorageOLD - #TODO vecchio test, obsoleto in seguito a modifica dei limiti + #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 2,attuale 40) Scenario: [INDEX_SS_UPDATE_MASSIVE_12] Update Massive ERROR - MaxTagsPerDocument Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati | global_multivalue:test1 | @@ -575,27 +454,12 @@ Feature: test preliminari indicizzazione File safeStorage | global_multivalue:test1 | | global_singlevalue:test1 | - @test @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_MASSIVE_13] Update Massive ERROR - MaxValuesPerTagPerRequest - Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | SET | global_multivalue:test1,test2,test3,test4,test5,test6,test7 | 1 | - | SET | global_multivalue:test1 | 2 | - Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" riguardanti il documento 1 - And Il documento 2 è associato alla seguente lista di tag - | global_multivalue:test1 | - - @test - @aggiuntaTag - @indicizzazioneSafeStorage - Scenario: [INDEX_SS_UPDATE_MASSIVE_13.2New] Update Massive ERROR - MaxValuesPerTagPerRequest - Given esiste un limite "MaxValuesPerTagPerRequest" con valore pari a 100 - And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When il documento viene modificato associandogli il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagPerRequest" + Given esiste un limite "maxValuesPerTagPerRequest" con valore pari a 100 + And Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" + When i documenti vengono modificati associando al primo il tag "global_multivalue" con un numero di valori "SUPERIORE" a "maxValuesPerTagPerRequest", mentre al secondo un solo valore Then L'update massivo va in successo con stato 200 And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of values for tag global_multivalue exceeds maxValues limit" riguardanti il documento 1 @@ -661,22 +525,11 @@ Feature: test preliminari indicizzazione File safeStorage ########################################################### SEARCH FILE-KEY ################################################################### - @test - @aggiuntaTag @concurrencyIndexSs @indicizzazioneSafeStorage - #TODO vecchio test, obsoleto in seguito a modifica dei limiti Scenario: [INDEX_SS_SEARCH_1] SEARCH ERROR - MaxMapValuesForSearch - Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_indexed_multivalue:test1,test2 | - | global_indexed_singlevalue:test1 | - When Vengono ricercate con logica "" le fileKey aventi i seguenti tag - | global_indexed_multivalue:testEmpty | - | global_multivalue:testEmpty | - | global_indexed_singlevalue:testEmpty | - | global_singlevalue:testEmpty | - | pn-test~local_indexed_multivalue:testEmpty | - | pn-test~local_indexed_singlevalue:testEmpty | + Given esiste un limite "maxMapValuesForSearch" con valore pari a 10 + When Vengono ricercate con logica "" delle fileKey impostando come filtro di ricerca un numero di tags "SUPERIORE" a "maxMapValuesForSearch" Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxMapValuesForSearch' reached" From 21d259e65607ffd16f106614c2cf289560622345 Mon Sep 17 00:00:00 2001 From: Matteo Sperati Date: Thu, 20 Feb 2025 16:09:40 +0100 Subject: [PATCH 15/15] 5496 - Validation bug 12883 Modifiche in seguito a review di Matteo Mancini. - Codice duplicato rimosso - Evitato uso del ParseInt con cattura dell'eccezione. - Vecchi test spostati in un file feature a parte --- .../steps/microservice/SafeStorageSteps.java | 87 +++++------ .../IndicizzazioneFile.feature | 132 ---------------- .../indicizzazioneFileOLD.feature | 142 ++++++++++++++++++ 3 files changed, 178 insertions(+), 183 deletions(-) create mode 100644 src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/indicizzazioneFileOLD.feature diff --git a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java index 55d6b5c1a..01fec4bdd 100644 --- a/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java +++ b/src/test/java/it/pagopa/pn/cucumber/steps/microservice/SafeStorageSteps.java @@ -58,7 +58,7 @@ public void setLimit(String limitName, int limitValue) { } } - private Integer eseguiGetterDelLimite(IndicizzazioneStepsPojo pojo, String fieldName) { + private Integer retriveLimitFromPojo(IndicizzazioneStepsPojo pojo, String fieldName) { try { String getterName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); Method getter = pojo.getClass().getMethod(getterName); @@ -97,36 +97,25 @@ public void uploadMultipleDocumentsWithAssociatedTagsWithValues(String type, Str uploadDocumentsWithTags(type, tagMap, quantity); } - @Given("il documento viene aggiornato aggiungendo {string} valori per volta al tag {string}, fino a raggiungere il limite di {string}") + @Given("(il documento viene aggiornato)(i documenti vengono aggiornati) aggiungendo {string} valori per volta al tag {string}, fino a raggiungere il limite di {string}") public void singleAddValuesUntilMax(String maxValuesPerTagPerRequest, String tagName, String maxValuesPerTagDocument) { - int maxValuesPerTagPerRequestInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagPerRequest); - int maxValuesPerTagDocumentInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagDocument); + int maxValuesPerTagPerRequestInt = retriveLimitFromPojo(this.indicizzazioneStepsPojo, maxValuesPerTagPerRequest); + int maxValuesPerTagDocumentInt = retriveLimitFromPojo(this.indicizzazioneStepsPojo, maxValuesPerTagDocument); int counterTagsAdded = 0; while (counterTagsAdded < maxValuesPerTagDocumentInt) { int valuesToAdd = getQuantityToAddInIteration(maxValuesPerTagDocumentInt, maxValuesPerTagPerRequestInt, counterTagsAdded); - updateSingleContinuativo(counterTagsAdded, tagName, "PARI", String.valueOf(valuesToAdd)); - counterTagsAdded += valuesToAdd; - } - } - - @Given("i documenti vengono aggiornati aggiungendo {string} valori per volta al tag {string}, fino a raggiungere il limite di {string}") - public void multipleAddValuesUntilMax(String maxValuesPerTagPerRequest, String tagName, String maxValuesPerTagDocument) { - int maxValuesPerTagPerRequestInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagPerRequest); - int maxValuesPerTagDocumentInt = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, maxValuesPerTagDocument); - int counterTagsAdded = 0; - while (counterTagsAdded < maxValuesPerTagDocumentInt) { - int valuesToAdd = getQuantityToAddInIteration(maxValuesPerTagDocumentInt, maxValuesPerTagPerRequestInt, counterTagsAdded); - updateMassiveContinuativo(counterTagsAdded, tagName, "PARI", String.valueOf(valuesToAdd)); + List tagValues = createTagValues(counterTagsAdded, "PARI", String.valueOf(valuesToAdd)); + if (this.indicizzazioneStepsPojo.getCreatedFiles().size() == 1) { + updateSingleContinuativo(tagName, tagValues); + } else { + updateMassiveContinuativo(tagName, tagValues); + } counterTagsAdded += valuesToAdd; } } - private int getQuantityToAddInIteration(int maxValuesPerTagDocument, int maxValuesPerTagPerRequest, int addedSoFar) { - if (maxValuesPerTagDocument - addedSoFar >= maxValuesPerTagPerRequest) { - return maxValuesPerTagPerRequest; - } - return maxValuesPerTagDocument - addedSoFar; + return Math.min(maxValuesPerTagDocument - addedSoFar, maxValuesPerTagPerRequest); } private void uploadDocumentsWithTags(String type, Map> tagMap, Integer quantity) { @@ -200,30 +189,20 @@ public void updateMassiviWithNValues(String tagName, String comparator, String l } } - private void updateSingleContinuativo(Integer valoriPrecedenti, String tagName, String comparator, String limit) { - int quantity = getLimitValue(comparator, limit); - String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); - List tagValues = new LinkedList<>(); - for (int i = 0; i < quantity; i++) { - tagValues.add("test" + (valoriPrecedenti + (i + 1))); - } + private void updateSingleContinuativo(String tagName, List tagValues) { AdditionalFileTagsUpdateRequest request = new AdditionalFileTagsUpdateRequest(); request.putSETItem(tagName, tagValues); + String fileKey = this.indicizzazioneStepsPojo.getCreatedFiles().get(0).getKey(); try { - this.indicizzazioneStepsPojo.setUpdateSingleResponseEntity(safeStorageClient.additionalFileTagsUpdateWithHttpInfo( - fileKey, "pn-test", request)); + this.indicizzazioneStepsPojo.setUpdateSingleResponseEntity( + safeStorageClient.additionalFileTagsUpdateWithHttpInfo(fileKey, "pn-test", request)); } catch (HttpClientErrorException e) { log.info("Errore durante l'aggiornamento del documento: {}", e.getMessage()); this.indicizzazioneStepsPojo.setHttpException(e); } } - private void updateMassiveContinuativo(Integer valoriPrecedenti, String tagName, String comparator, String limit) { - int quantity = getLimitValue(comparator, limit); - List tagValues = new LinkedList<>(); - for (int i = 0; i < quantity; i++) { - tagValues.add("test" + (valoriPrecedenti + (i + 1))); - } + private void updateMassiveContinuativo(String tagName, List tagValues) { List tagsList = new LinkedList<>(); AdditionalFileTagsMassiveUpdateRequest request = new AdditionalFileTagsMassiveUpdateRequest(); this.indicizzazioneStepsPojo.getCreatedFiles().forEach(file -> { @@ -234,28 +213,34 @@ private void updateMassiveContinuativo(Integer valoriPrecedenti, String tagName, }); request.setTags(tagsList); try { - this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity(safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo("pn-test", request)); + this.indicizzazioneStepsPojo.setUpdateMassiveResponseEntity( + safeStorageClient.additionalFileTagsMassiveUpdateWithHttpInfo("pn-test", request)); } catch (HttpClientErrorException e) { log.info("Errore durante l'aggiornamento dei documento: {}", e.getMessage()); this.indicizzazioneStepsPojo.setHttpException(e); } } + private List createTagValues(Integer valoriPrecedenti, String comparator, String limit) { + int quantity = getLimitValue(comparator, limit); + List tagValues = new LinkedList<>(); + for (int i = 0; i < quantity; i++) { + tagValues.add("test" + (valoriPrecedenti + (i + 1))); + } + return tagValues; + } + /** - * Qualora venga passato "PARI" come comparator e una stringa avente valore numerico come "limit", verrà usato tale valore - * Altrimenti provvederà a impostare una quantità in accordo al valore settato nel pojo + * Se limit ha valore numerico viene usato il suo valore, se è una stringa viene usato il valore del campo corrispondente settato nel Pojo. + * Tale valore viene poi aumentato o decrementato di uno a seconda del valore di comparator ("PARI" lo tiene immutato) */ private int getLimitValue(String comparator, String limit) { - int quantity; - try { - quantity = Integer.parseInt(limit); - } catch (Exception e) { - quantity = eseguiGetterDelLimite(this.indicizzazioneStepsPojo, limit); - if (comparator.equalsIgnoreCase("SUPERIORE")) { - quantity += 1; - } else if (comparator.equalsIgnoreCase("INFERIORE")) { - quantity -= 1; - } + int quantity = limit.matches("[0-9]+") ? + Integer.parseInt(limit) : retriveLimitFromPojo(this.indicizzazioneStepsPojo, limit); + if (comparator.equalsIgnoreCase("SUPERIORE")) { + quantity += 1; + } else if (comparator.equalsIgnoreCase("INFERIORE")) { + quantity -= 1; } return quantity; } @@ -766,7 +751,7 @@ public void cleanDocuments() { int numberOfValues = entry.getValue().size(); int valuesDeleted = 0; while (valuesDeleted < numberOfValues) { - int valuesToDelete = maxValuesLimit < (numberOfValues - valuesDeleted) ? maxValuesLimit : (numberOfValues - valuesDeleted); + int valuesToDelete = Math.min(maxValuesLimit, (numberOfValues - valuesDeleted)); List valuesToDeleteList = entry.getValue().subList(valuesDeleted, valuesDeleted + valuesToDelete); request.putDELETEItem(entry.getKey(), valuesToDeleteList); safeStorageClient.additionalFileTagsUpdate(file.getKey(), request); diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature index bc628b453..f56787927 100644 --- a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/IndicizzazioneFile.feature @@ -74,20 +74,6 @@ Feature: test preliminari indicizzazione File safeStorage And La chiamata genera un errore con status code 404 And Il messaggio di errore riporta la dicitura "Document is missing from bucket" - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 6,attuale 50) - Scenario: [INDEX_SS_CREATE_3] Create ERROR - MaxTagsPerRequest - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2 | - | global_indexed_multivalue:test1,test2 | - | global_singlevalue:test1 | - | global_indexed_singlevalue:test1 | - | pn-test~local_multivalue:test1,test2 | - | pn-test~local_singlevalue:test1 | - | pn-test~local_indexed_singlevalue:test1 | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerRequest' reached" @aggiuntaTag @concurrencyIndexSs @@ -99,30 +85,6 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" -# @aggiuntaTag -# @indicizzazioneSafeStorage -# #vecchio test, obsoleto in seguito a modifica dei limiti -# #Non ha senso fare un metodo nuovo sulla create, in quanto verrebbe catturato prima l'errore di maxValuesPerTagPerRequest (100) -# #rispetto a quello di MaxValuesPerTagDocument (1000) -# Scenario: [INDEX_SS_CREATE_5_OLD] Create ERROR - MaxValuesPerTagDocument -# Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati -# | global_multivalue:test1,test2,test3,test4,test5,test6 | -# Then La chiamata genera un errore con status code 400 -# And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." - - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 2,attuale 40) - Scenario: [INDEX_SS_CREATE_6] Create ERROR - MaxTagsPerDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1,test2 | - | global_indexed_multivalue:test1,test2 | - | global_singlevalue:test1 | - | global_indexed_singlevalue:test1 | - | pn-test~local_multivalue:test1,test2 | - | pn-test~local_singlevalue:test1 | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached" @aggiuntaTag @indicizzazioneSafeStorage @@ -195,33 +157,6 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "SET and DELETE cannot contain the same tags: [global_multivalue]" - @aggiuntaTag - @indicizzazioneSafeStorageTODO - #non funzionante in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5). Per ora escluso dalla suite, da rivedere - Scenario: [INDEX_SS_UPDATE_SINGLE_7] UpdateSingle ERROR - MaxFileKeys - Given esiste un limite "maxFileKeys" con valore pari a 1000 - And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_multivalue:test" - And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modifica il documento 1001 secondo le seguenti operazioni - | global_indexed_multivalue:test | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" - - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 4,attuale 50) - Scenario: [INDEX_SS_UPDATE_SINGLE_8] UpdateSingle ERROR - MaxOperationsOnTagsPerRequest - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1 | - When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test1 | DELETE | - | global_indexed_multivalue:test2 | SET | - | global_singlevalue:test3 | SET | - | global_indexed_singlevalue:test4 | SET | - | pn-test~local_multivalue:test5 | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" - @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_SINGLE_9] UpdateSingle ERROR - MaxValuesPerTagDocument @@ -234,18 +169,6 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached" - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #vecchio test, obsoleto in seguito a modifica dei limiti (aumentato a 40, valore precedente: 2) - Scenario: [INDEX_SS_UPDATE_SINGLE_10] UpdateSingle ERROR - MaxTagsPerDocument - Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modifica il documento 1 secondo le seguenti operazioni - | global_multivalue:test1 | SET | - | global_singlevalue:test1 | SET | - | pn-test~local_multivalue:test1 | SET | - Then La chiamata genera un errore con status code 400 - And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" - @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_SINGLE_11] UpdateSingle ERROR - MaxValuesPerTagPerRequest @@ -385,44 +308,6 @@ Feature: test preliminari indicizzazione File safeStorage Then La chiamata genera un errore con status code 400 And Il messaggio di errore riporta la dicitura "Number of documents to update exceeds MaxFileKeysUpdateMassivePerRequest limit." - @aggiuntaTag - @indicizzazioneSafeStorageOLD - Scenario: [INDEX_SS_UPDATE_MASSIVE_9] Update Massive ERROR - MaxOperationsOnTagsPerRequest - #vecchio test, obsoleto in seguito a modifica dei limiti (corrente: 4, valore precedente: 50) - Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1 | - When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | DELETE | global_multivalue:test1 | 1 | - | SET | global_indexed_multivalue:test2 | 1 | - | SET | global_singlevalue:test3 | 1 | - | SET | global_indexed_singlevalue:test4 | 1 | - | SET | pn-test~local_multivalue:test5 | 1 | - | SET | global_singlevalue:test6 | 2 | - Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" riguardanti il documento 1 - And Il documento 2 è associato alla seguente lista di tag - | global_multivalue:test1 | - | global_singlevalue:test6 | - - @aggiuntaTag - @concurrencyIndexSs - @indicizzazioneSafeStorageTODO - #non funzionante in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5). Per ora escluso dalla suite, da rivedere - Scenario: [INDEX_SS_UPDATE_MASSIVE_10] Update Massive ERROR - MaxFileKeys - And Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_indexed_multivalue:test | - And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" - When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | SET | global_indexed_multivalue:test | 6 | - | SET | global_multivalue:test1 | 1 | - Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" riguardanti il documento 6 - And Il documento 1 è associato alla seguente lista di tag - | global_indexed_multivalue:test | - | global_multivalue:test1 | - @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_MASSIVE_11] Update Massive ERROR - MaxValuesPerTagDocument @@ -437,23 +322,6 @@ Feature: test preliminari indicizzazione File safeStorage Then L'update massivo va in successo con stato 200 And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxValuesPerTagDocument' reached" riguardanti il documento 1 - @aggiuntaTag - @indicizzazioneSafeStorageOLD - #Non replicabile per mancanza di sufficienti tag per riprodurre l'errore in seguito a modifica del limite(valore precedente 2,attuale 40) - Scenario: [INDEX_SS_UPDATE_MASSIVE_12] Update Massive ERROR - MaxTagsPerDocument - Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati - | global_multivalue:test1 | - When Si modificano i documenti secondo le seguenti operazioni - | operation | tag | documentIndex | - | SET | global_singlevalue:test1 | 1 | - | SET | pn-test~local_multivalue:test1 | 1 | - | SET | global_singlevalue:test1 | 2 | - Then L'update massivo va in successo con stato 200 - And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" riguardanti il documento 1 - And Il documento 2 è associato alla seguente lista di tag - | global_multivalue:test1 | - | global_singlevalue:test1 | - @aggiuntaTag @indicizzazioneSafeStorage Scenario: [INDEX_SS_UPDATE_MASSIVE_13] Update Massive ERROR - MaxValuesPerTagPerRequest diff --git a/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/indicizzazioneFileOLD.feature b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/indicizzazioneFileOLD.feature new file mode 100644 index 000000000..9f0c897b2 --- /dev/null +++ b/src/test/resources/it/pagopa/pn/cucumber/IndicizzazioneFile/indicizzazioneFileOLD.feature @@ -0,0 +1,142 @@ +# I seguenti casi di test per indicizzazione file di safe storage sono stati rimossi in seguito all'aggiornamento +# dei limiti su Parameter Store (specificati sopra ogni test). Per molti di questi casi, non è più riproducibile l'errore che +# ci si proponeva di testare, in quanto il numero di tag disponibili è inferiore a quello necessario per testare gli scenari. + +Feature: Scenari per indicizzazione File safeStorage che sono stati rimossi dalla suite principale + + #MaxTagsPerRequest - valore corrente: 50, precedente: 6 + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_CREATE_3] Create ERROR - MaxTagsPerRequest + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1,test2 | + | global_indexed_multivalue:test1,test2 | + | global_singlevalue:test1 | + | global_indexed_singlevalue:test1 | + | pn-test~local_multivalue:test1,test2 | + | pn-test~local_singlevalue:test1 | + | pn-test~local_indexed_singlevalue:test1 | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerRequest' reached" + + # Con l'aggiornamento dei limiti questo test non ha più senso: non si può ottenere questo errore sulla create in quanto + # verrebbe catturato prima l'errore di maxValuesPerTagPerRequest (100) rispetto a quello di MaxValuesPerTagDocument (1000) + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_CREATE_5_OLD] Create ERROR - MaxValuesPerTagDocument + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1,test2,test3,test4,test5,test6 | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxValuesPerTagDocument' reached." + + #MaxTagsPerDocument - valore corrente: 40, precedente: 2 + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_CREATE_6] Create ERROR - MaxTagsPerDocument + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1,test2 | + | global_indexed_multivalue:test1,test2 | + | global_singlevalue:test1 | + | global_indexed_singlevalue:test1 | + | pn-test~local_multivalue:test1,test2 | + | pn-test~local_singlevalue:test1 | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached" + + #MaxOperationsOnTagsPerRequest - valore corrente: 50, precedente: 4 + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_UPDATE_SINGLE_8] UpdateSingle ERROR - MaxOperationsOnTagsPerRequest + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1 | + When Si modifica il documento 1 secondo le seguenti operazioni + | global_multivalue:test1 | DELETE | + | global_indexed_multivalue:test2 | SET | + | global_singlevalue:test3 | SET | + | global_indexed_singlevalue:test4 | SET | + | pn-test~local_multivalue:test5 | SET | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" + + #MaxTagsPerDocument - valore corrente: 40, precedente: 2 + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_UPDATE_SINGLE_10] UpdateSingle ERROR - MaxTagsPerDocument + Given Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modifica il documento 1 secondo le seguenti operazioni + | global_multivalue:test1 | SET | + | global_singlevalue:test1 | SET | + | pn-test~local_multivalue:test1 | SET | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" + + #MaxOperationsOnTagsPerRequest - valore corrente: 50, precedente: 4 + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_UPDATE_MASSIVE_9] Update Massive ERROR - MaxOperationsOnTagsPerRequest + Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1 | + When Si modificano i documenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | DELETE | global_multivalue:test1 | 1 | + | SET | global_indexed_multivalue:test2 | 1 | + | SET | global_singlevalue:test3 | 1 | + | SET | global_indexed_singlevalue:test4 | 1 | + | SET | pn-test~local_multivalue:test5 | 1 | + | SET | global_singlevalue:test6 | 2 | + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Number of tags to update exceeds maxOperationsOnTags limit" riguardanti il documento 1 + And Il documento 2 è associato alla seguente lista di tag + | global_multivalue:test1 | + | global_singlevalue:test6 | + + #MaxTagsPerDocument - valore corrente: 40, precedente: 2 + @aggiuntaTag + @indicizzazioneSafeStorageOLD + Scenario: [INDEX_SS_UPDATE_MASSIVE_12] Update Massive ERROR - MaxTagsPerDocument + Given Vengono caricati 2 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_multivalue:test1 | + When Si modificano i documenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | SET | global_singlevalue:test1 | 1 | + | SET | pn-test~local_multivalue:test1 | 1 | + | SET | global_singlevalue:test1 | 2 | + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxTagsPerDocument' reached. Current value: 3. Max value: 2" riguardanti il documento 1 + And Il documento 2 è associato alla seguente lista di tag + | global_multivalue:test1 | + | global_singlevalue:test1 | + +#################################################################### TODO ##################################################################### + + # I seguenti due test necessiterebbero di un rework per funzionare col nuovo valore limite di MaxFileKeys (corrente: 1000, precedente: 5). + # Tuttavia, richiedendo l'upload di 1001 documenti ad ogni run, andrebbe valutato se tenerli o se invece sono troppo onerosi. + + @aggiuntaTag + @indicizzazioneSafeStorageTODO + #non funzionante in seguito a modifica dei limiti (corrente: 1000, valore precedente: 5). + Scenario: [INDEX_SS_UPDATE_SINGLE_7] UpdateSingle ERROR - MaxFileKeys + Given esiste un limite "maxFileKeys" con valore pari a 1000 + And vengono caricati documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" in numero "PARI" a "maxFileKeys" con tag associati "global_indexed_multivalue:test" + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modifica il documento 1001 secondo le seguenti operazioni + | global_indexed_multivalue:test | SET | + Then La chiamata genera un errore con status code 400 + And Il messaggio di errore riporta la dicitura "Limit 'MaxFileKeys' reached" + + @aggiuntaTag + @concurrencyIndexSs + @indicizzazioneSafeStorageTODO + Scenario: [INDEX_SS_UPDATE_MASSIVE_10] Update Massive ERROR - MaxFileKeys + And Vengono caricati 5 nuovi documenti di tipo "PN_NOTIFICATION_ATTACHMENTS" con tag associati + | global_indexed_multivalue:test | + And Viene caricato un nuovo documento di tipo "PN_NOTIFICATION_ATTACHMENTS" + When Si modificano i documenti secondo le seguenti operazioni + | operation | tag | documentIndex | + | SET | global_indexed_multivalue:test | 6 | + | SET | global_multivalue:test1 | 1 | + Then L'update massivo va in successo con stato 200 + And La response contiene uno o più errori "400.00" riportanti la dicitura "Limit 'MaxFileKeys' reached. Current value: 6. Max value: 5" riguardanti il documento 6 + And Il documento 1 è associato alla seguente lista di tag + | global_indexed_multivalue:test | + | global_multivalue:test1 | \ No newline at end of file