From 16544b1e91070f15ce80ad2f9ab28c8281c3d520 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 16 Dec 2021 10:50:29 -0500 Subject: [PATCH] Added tests cases and TODO items, addressing code review comments Signed-off-by: Andriy Redko --- plugins/repository-azure/build.gradle | 21 ++++++++++++++++++- .../repositories/azure/AzureBlobStore.java | 7 +++++++ .../java/fixture/azure/AzureHttpHandler.java | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/repository-azure/build.gradle b/plugins/repository-azure/build.gradle index 71356129845e5..e87d231a9e5ea 100644 --- a/plugins/repository-azure/build.gradle +++ b/plugins/repository-azure/build.gradle @@ -283,4 +283,23 @@ task azureThirdPartyTest(type: Test) { nonInputProperties.systemProperty 'test.azure.endpoint_suffix', "${-> azureAddress.call() }" } } -check.dependsOn(azureThirdPartyTest) + +task azureThirdPartyDefaultXmlTest(type: Test) { + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); + SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME) + setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs()) + setClasspath(internalTestSourceSet.getRuntimeClasspath()) + dependsOn tasks.internalClusterTest + include '**/AzureStorageCleanupThirdPartyTests.class' + systemProperty 'javax.xml.stream.XMLInputFactory', "com.sun.xml.internal.stream.XMLInputFactoryImpl" + systemProperty 'test.azure.account', azureAccount ? azureAccount : "" + systemProperty 'test.azure.key', azureKey ? azureKey : "" + systemProperty 'test.azure.sas_token', azureSasToken ? azureSasToken : "" + systemProperty 'test.azure.container', azureContainer ? azureContainer : "" + systemProperty 'test.azure.base', (azureBasePath ? azureBasePath : "") + "_third_party_tests_" + BuildParams.testSeed + if (useFixture) { + nonInputProperties.systemProperty 'test.azure.endpoint_suffix', "${-> azureAddress.call() }" + } +} + +check.dependsOn(azureThirdPartyTest, azureThirdPartyDefaultXmlTest) diff --git a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java index 022b81b990e04..6345103c6ecc6 100644 --- a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java +++ b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java @@ -224,6 +224,8 @@ public DeleteResult deleteBlobDirectory(String path, Executor executor) throws U do { // Fetch one page at a time, others are going to be fetched by continuation token + // TODO: reconsider reverting to simplified approach once https://github.com/Azure/azure-sdk-for-java/issues/26064 + // gets addressed. final Optional> pageOpt = blobContainer.listBlobs(listBlobsOptions, timeout()) .streamByPage(continuationToken) .findFirst(); @@ -327,6 +329,8 @@ public Map listBlobsByPrefix(String keyPath, String prefix do { // Fetch one page at a time, others are going to be fetched by continuation token + // TODO: reconsider reverting to simplified approach once https://github.com/Azure/azure-sdk-for-java/issues/26064 + // gets addressed final Optional> pageOpt = blobContainer.listBlobsByHierarchy("/", listBlobsOptions, timeout()) .streamByPage(continuationToken) .findFirst(); @@ -372,6 +376,9 @@ public Map children(BlobPath path) throws URISyntaxExcept String continuationToken = null; do { + // Fetch one page at a time, others are going to be fetched by continuation token + // TODO: reconsider reverting to simplified approach once https://github.com/Azure/azure-sdk-for-java/issues/26064 + // gets addressed final Optional> pageOpt = blobContainer.listBlobsByHierarchy("/", listBlobsOptions, timeout()) .streamByPage(continuationToken) .findFirst(); diff --git a/test/fixtures/azure-fixture/src/main/java/fixture/azure/AzureHttpHandler.java b/test/fixtures/azure-fixture/src/main/java/fixture/azure/AzureHttpHandler.java index 68ebeb5265fd0..f12a4579a2d0c 100644 --- a/test/fixtures/azure-fixture/src/main/java/fixture/azure/AzureHttpHandler.java +++ b/test/fixtures/azure-fixture/src/main/java/fixture/azure/AzureHttpHandler.java @@ -208,6 +208,7 @@ public void handle(final HttpExchange exchange) throws IOException { } list.append(""); + list.append(""); list.append(""); byte[] response = list.toString().getBytes(StandardCharsets.UTF_8);