diff --git a/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java b/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java index 935f3ecb..706b0b06 100644 --- a/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java +++ b/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java @@ -172,7 +172,7 @@ private void refreshPackage(CatalogWrapper cw, Pkg pkg) } } - private void extractDataFromTgz(InputStream in, Chart chart) throws IOException { + public void extractDataFromTgz(InputStream in, Chart chart) throws IOException { GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(in); // HelmConfig config = null; try (TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn)) { diff --git a/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java b/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java index 4739faed..3026d676 100644 --- a/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java +++ b/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java @@ -9,6 +9,8 @@ import fr.insee.onyxia.api.configuration.CustomObjectMapper; import fr.insee.onyxia.api.util.TestUtils; import fr.insee.onyxia.model.helm.Chart; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.DisplayName; @@ -144,4 +146,36 @@ void packageOnClassPathNotFound() { + "Exception occurred during loading resource: class path resource " + "[catalog-loader-test/keepeme1.gz]")); } + + @Test + /** + * This test is for a regression on commons compress 1.26 + * https://commons.apache.org/proper/commons-compress/changes-report.html#a1.26.0 that made it + * non parallelable + */ + void shouldExtractPackageInParallel() throws IOException { + List charts = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + Chart chart = new Chart(); + chart.setName("vscode-python-darkmode"); + charts.add(chart); + } + charts.parallelStream() + .forEach( + chart -> { + try { + catalogLoader.extractDataFromTgz( + resourceLoader + .getResource( + "classpath:/catalog-loader-test/vscode-python-darkmode-1.11.11.tgz") + .getInputStream(), + chart); + assertEquals( + 19, + chart.getConfig().getProperties().getProperties().size()); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } } diff --git a/onyxia-api/src/test/resources/catalog-loader-test/vscode-python-darkmode-1.11.11.tgz b/onyxia-api/src/test/resources/catalog-loader-test/vscode-python-darkmode-1.11.11.tgz new file mode 100644 index 00000000..8384ffa8 Binary files /dev/null and b/onyxia-api/src/test/resources/catalog-loader-test/vscode-python-darkmode-1.11.11.tgz differ