You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by im...@apache.org on 2025/10/06 21:46:03 UTC
(asterixdb) 14/15: [ASTERIXDB-3654][TEST]Use Azurite in testcontainers
This is an automated email from the ASF dual-hosted git repository.
imaxon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 698e45c1051d64dd4ae3636b040376f661bed652
Author: Ian Maxon <ia...@maxons.email>
AuthorDate: Wed Oct 1 13:56:56 2025 -0700
[ASTERIXDB-3654][TEST]Use Azurite in testcontainers
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Use Azurite in testcontainers instead of installing and
invoking it via npm through frontend-npm-plugin
- Use the normal storage credential path instead of the
anonymous auth test path for CloudStorageAzTest
Ext-ref: MB-68803
Change-Id: Iad1a6f9331fd844f3e3c04b8f56e811e4227f83e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20432
Reviewed-by: Michael Blow <mb...@apache.org>
Reviewed-by: Ian Maxon <im...@apache.org>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
---
asterixdb/asterix-app/pom.xml | 84 ++++++-------------
.../test/cloud_storage/CloudStorageAzTest.java | 48 ++++++++---
.../src/test/resources/cc-cloud-storage-azblob.ftl | 74 +++++++++++++++++
asterixdb/asterix-cloud/pom.xml | 96 +++++++---------------
.../asterix/cloud/azure/LSMAzBlobStorageTest.java | 84 +++++++++++++++----
asterixdb/pom.xml | 10 +++
6 files changed, 241 insertions(+), 155 deletions(-)
diff --git a/asterixdb/asterix-app/pom.xml b/asterixdb/asterix-app/pom.xml
index f1bbb375f9..41311d9d2d 100644
--- a/asterixdb/asterix-app/pom.xml
+++ b/asterixdb/asterix-app/pom.xml
@@ -292,29 +292,6 @@
</environmentVariables>
</configuration>
</execution>
- <execution>
- <id>azurite</id>
- <phase>${azurite.stage}</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <!--suppress UnresolvedMavenProperty -->
- <executable>${project.build.directory}/npm/node_modules/.bin/azurite-blob</executable>
- <workingDirectory>${project.build.directory}</workingDirectory>
- <environmentVariables>
- <PATH>${project.build.directory}/npm/node</PATH>
- </environmentVariables>
- <arguments>
- <argument>--blobPort</argument>
- <argument>15055</argument>
- <argument>--location</argument>
- <argument>${project.build.directory}/azurite</argument>
- </arguments>
- <async>true</async>
- <outputFile>${project.build.directory}/azurite/logs/azurite.log</outputFile>
- </configuration>
- </execution>
<execution>
<id>fake-gcs-server</id>
<phase>${gcs.stage}</phase>
@@ -697,43 +674,6 @@
<failIfNoTests>false</failIfNoTests>
</properties>
</profile>
- <profile>
- <id>azurite-tests</id>
- <build>
- <plugins>
- <plugin>
- <groupId>com.github.eirslett</groupId>
- <artifactId>frontend-maven-plugin</artifactId>
- <version>1.13.4</version>
- <configuration>
- <nodeVersion>v14.15.4</nodeVersion>
- <npmVersion>6.14.11</npmVersion>
- <workingDirectory>target/npm</workingDirectory>
- <installDirectory>target/npm</installDirectory>
- </configuration>
- <executions>
- <execution>
- <id>install node and yarn</id>
- <goals>
- <goal>install-node-and-npm</goal>
- </goals>
- <phase>${azurite.npm.install.stage}</phase>
- </execution>
- <execution>
- <id>azurite blob</id>
- <phase>${azurite.install.stage}</phase>
- <goals>
- <goal>npm</goal>
- </goals>
- <configuration>
- <arguments>install azurite@3.35.0</arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
<dependencies>
<dependency>
@@ -1060,6 +1000,18 @@
<artifactId>asterix-cloud</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.asterix</groupId>
+ <artifactId>asterix-cloud</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>azure</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
@@ -1201,5 +1153,17 @@
<version>2.3.31</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk18on</artifactId>
+ <version>1.78.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk18on</artifactId>
+ <version>1.78.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/cloud_storage/CloudStorageAzTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/cloud_storage/CloudStorageAzTest.java
index d3f766e9d1..659e8cf09a 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/cloud_storage/CloudStorageAzTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/cloud_storage/CloudStorageAzTest.java
@@ -19,8 +19,11 @@
package org.apache.asterix.test.cloud_storage;
import static org.apache.asterix.api.common.LocalCloudUtil.CLOUD_STORAGE_BUCKET;
+import static org.apache.asterix.api.common.LocalCloudUtilAdobeMock.fillConfigTemplate;
+import static org.apache.asterix.cloud.azure.LSMAzBlobStorageTest.AZURITE_CONTAINER_VER;
import static org.apache.asterix.test.cloud_storage.CloudStorageGCSTest.S3_ONLY;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -28,6 +31,7 @@ import java.util.Objects;
import java.util.Random;
import org.apache.asterix.api.common.LocalCloudUtilAdobeMock;
+import org.apache.asterix.cloud.azure.LSMAzBlobStorageTest;
import org.apache.asterix.common.config.GlobalConfig;
import org.apache.asterix.test.common.TestExecutor;
import org.apache.asterix.test.runtime.LangExecutionUtil;
@@ -45,10 +49,17 @@ import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+import org.testcontainers.azure.AzuriteContainer;
+import org.testcontainers.utility.MountableFile;
+import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
-import com.azure.storage.common.StorageSharedKeyCredential;
+
+import io.netty.handler.ssl.SslContext;
+import io.netty.handler.ssl.SslContextBuilder;
+import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
+import reactor.netty.http.client.HttpClient;
/**
* Run tests in cloud deployment environment
@@ -62,40 +73,51 @@ public class CloudStorageAzTest {
private final TestCaseContext tcCtx;
private static final String SUITE_TESTS = "testsuite_cloud_storage.xml";
private static final String ONLY_TESTS = "testsuite_cloud_storage_only.xml";
- private static final String CONFIG_FILE_NAME = "src/test/resources/cc-cloud-storage-azblob.conf";
+ private static final String CONFIG_FILE = "target/cc-cloud-storage-azblob.conf";
+ private static final String CONFIG_FILE_TEMPLATE = "src/test/resources/cc-cloud-storage-azblob.ftl";
private static final String DELTA_RESULT_PATH = "results_cloud";
private static final String EXCLUDED_TESTS = "MP";
+ private static AzuriteContainer azBlob;
+
public CloudStorageAzTest(TestCaseContext tcCtx) {
this.tcCtx = tcCtx;
}
@BeforeClass
public static void setUp() throws Exception {
- String endpointString = "http://127.0.0.1:15055/devstoreaccount1/" + CLOUD_STORAGE_BUCKET;
- final String accKey =
- "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
- final String accName = "devstoreaccount1";
-
- BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint(endpointString)
- .credential(new StorageSharedKeyCredential(accName, accKey)).buildClient();
+ LocalCloudUtilAdobeMock.startS3CloudEnvironment(true, true);
+ LSMAzBlobStorageTest.generateSelfSignedTLS();
+ MountableFile azureCert = MountableFile.forHostPath("target/azure_test.pfx");
+ azBlob = new AzuriteContainer(AZURITE_CONTAINER_VER).withSsl(azureCert, "password");
+ azBlob.start();
+ SslContext insecureSslContext =
+ SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
+ BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
+ .connectionString(azBlob.getConnectionString())
+ .httpClient(new NettyAsyncHttpClientBuilder(
+ HttpClient.create().secure(sslSpec -> sslSpec.sslContext(insecureSslContext).build())).build())
+ .buildClient();
+ URI blobStore = URI.create(blobServiceClient.getAccountUrl());
+ String endpoint = blobStore.getScheme() + "://" + blobStore.getAuthority();
+ fillConfigTemplate(endpoint, CONFIG_FILE_TEMPLATE, CONFIG_FILE);
cleanup(blobServiceClient);
initialize(blobServiceClient);
- //storage.close(); WHAT IS THIS FOR IN GCS
-
TestExecutor testExecutor = new TestExecutor(DELTA_RESULT_PATH);
testExecutor.executorId = "cloud";
testExecutor.stripSubstring = "//DB:";
- LangExecutionUtil.setUp(CONFIG_FILE_NAME, testExecutor);
- System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, CONFIG_FILE_NAME);
+ LangExecutionUtil.setUp(CONFIG_FILE, testExecutor);
+ System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, CONFIG_FILE);
}
@AfterClass
public static void tearDown() throws Exception {
LangExecutionUtil.tearDown();
LocalCloudUtilAdobeMock.shutdownSilently();
+ azBlob.close();
+ azBlob.stop();
}
@Parameters(name = "CloudStorageAzBlobTest {index}: {0}")
diff --git a/asterixdb/asterix-app/src/test/resources/cc-cloud-storage-azblob.ftl b/asterixdb/asterix-app/src/test/resources/cc-cloud-storage-azblob.ftl
new file mode 100644
index 0000000000..91d87cd342
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/cc-cloud-storage-azblob.ftl
@@ -0,0 +1,74 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements. See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership. The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied. See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[nc/asterix_nc1]
+txn.log.dir=target/tmp/asterix_nc1/txnlog
+core.dump.dir=target/tmp/asterix_nc1/coredump
+iodevices=target/tmp/asterix_nc1/iodevice1
+iodevices=../asterix-server/target/tmp/asterix_nc1/iodevice2
+nc.api.port=19004
+#jvm.args=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006
+
+[nc/asterix_nc2]
+ncservice.port=9091
+txn.log.dir=target/tmp/asterix_nc2/txnlog
+core.dump.dir=target/tmp/asterix_nc2/coredump
+iodevices=target/tmp/asterix_nc2/iodevice1,../asterix-server/target/tmp/asterix_nc2/iodevice2
+nc.api.port=19005
+#jvm.args=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5007
+
+[nc]
+credential.file=src/test/resources/security/passwd
+python.cmd.autolocate=true
+python.env=FOO=BAR=BAZ,BAR=BAZ
+address=127.0.0.1
+command=asterixnc
+app.class=org.apache.asterix.hyracks.bootstrap.NCApplication
+jvm.args=-Xmx4096m -Dnode.Resolver="org.apache.asterix.external.util.IdentitiyResolverFactory"
+storage.buffercache.size=128MB
+storage.memorycomponent.globalbudget=512MB
+storage.max.columns.in.zeroth.segment=800
+
+[cc]
+address = 127.0.0.1
+app.class=org.apache.asterix.hyracks.bootstrap.CCApplication
+heartbeat.period=2000
+heartbeat.max.misses=25
+credential.file=src/test/resources/security/passwd
+
+[common]
+log.dir = logs/
+log.level = INFO
+compiler.framesize=32KB
+compiler.sortmemory=320KB
+compiler.groupmemory=160KB
+compiler.joinmemory=256KB
+compiler.textsearchmemory=160KB
+compiler.windowmemory=192KB
+compiler.ordered.fields=false
+compiler.internal.sanitycheck=true
+messaging.frame.size=4096
+messaging.frame.count=512
+cloud.deployment=true
+storage.buffercache.pagesize=32KB
+storage.partitioning=static
+cloud.storage.scheme=azblob
+cloud.storage.bucket=cloud-storage-container
+cloud.storage.region=us-east-2
+cloud.storage.endpoint=${cloudUrl}/devstoreaccount1
+cloud.storage.disable.ssl.verify=true
+cloud.storage.cache.policy=lazy
\ No newline at end of file
diff --git a/asterixdb/asterix-cloud/pom.xml b/asterixdb/asterix-cloud/pom.xml
index bc4913574c..0d5b6586a0 100644
--- a/asterixdb/asterix-cloud/pom.xml
+++ b/asterixdb/asterix-cloud/pom.xml
@@ -62,6 +62,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
@@ -135,76 +146,10 @@
<async>true</async>
</configuration>
</execution>
- <execution>
- <id>azurite</id>
- <phase>${azurite.stage}</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <!--suppress UnresolvedMavenProperty -->
- <executable>${project.build.directory}/npm/node_modules/.bin/azurite-blob</executable>
- <workingDirectory>${project.build.directory}</workingDirectory>
- <environmentVariables>
- <PATH>${project.build.directory}/npm/node</PATH>
- </environmentVariables>
- <arguments>
- <argument>--blobPort</argument>
- <argument>15055</argument>
- <argument>--location</argument>
- <argument>${project.build.directory}/azurite</argument>
- <argument>--debug</argument>
- <argument>${project.build.directory}/azurite/logs/azurite-debug.log</argument>
- </arguments>
- <async>true</async>
- <outputFile>${project.build.directory}/azurite/logs/azurite.log</outputFile>
- </configuration>
- </execution>
</executions>
</plugin>
</plugins>
</build>
-
- <profiles>
- <profile>
- <id>azurite-tests</id>
- <build>
- <plugins>
- <plugin>
- <groupId>com.github.eirslett</groupId>
- <artifactId>frontend-maven-plugin</artifactId>
- <version>1.13.4</version>
- <configuration>
- <nodeVersion>v14.15.4</nodeVersion>
- <npmVersion>6.14.11</npmVersion>
- <workingDirectory>target/npm</workingDirectory>
- <installDirectory>target/npm</installDirectory>
- </configuration>
- <executions>
- <execution>
- <id>install node and yarn</id>
- <goals>
- <goal>install-node-and-npm</goal>
- </goals>
- <phase>${azurite.npm.install.stage}</phase>
- </execution>
- <execution>
- <id>azurite blob</id>
- <phase>${azurite.install.stage}</phase>
- <goals>
- <goal>npm</goal>
- </goals>
- <configuration>
- <arguments>install azurite@3.35.0</arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<dependencies>
<dependency>
<groupId>org.apache.hyracks</groupId>
@@ -271,12 +216,27 @@
<scope>test</scope>
</dependency>
<!-- aws s3 end -->
-
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob-batch</artifactId>
<version>12.23.0</version>
</dependency>
-
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk18on</artifactId>
+ <version>1.78.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk18on</artifactId>
+ <version>1.78.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>azure</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/asterixdb/asterix-cloud/src/test/java/org/apache/asterix/cloud/azure/LSMAzBlobStorageTest.java b/asterixdb/asterix-cloud/src/test/java/org/apache/asterix/cloud/azure/LSMAzBlobStorageTest.java
index 0d5a9ba518..44b4856a34 100644
--- a/asterixdb/asterix-cloud/src/test/java/org/apache/asterix/cloud/azure/LSMAzBlobStorageTest.java
+++ b/asterixdb/asterix-cloud/src/test/java/org/apache/asterix/cloud/azure/LSMAzBlobStorageTest.java
@@ -19,14 +19,34 @@
package org.apache.asterix.cloud.azure;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.math.BigInteger;
+import java.net.URI;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+
import org.apache.asterix.cloud.AbstractLSMTest;
import org.apache.asterix.cloud.clients.ICloudGuardian;
import org.apache.asterix.cloud.clients.azure.blobstorage.AzBlobStorageClientConfig;
import org.apache.asterix.cloud.clients.azure.blobstorage.AzBlobStorageCloudClient;
import org.apache.hyracks.util.StorageUtil;
+import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
+import org.bouncycastle.cert.X509v3CertificateBuilder;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.testcontainers.azure.AzuriteContainer;
+import org.testcontainers.utility.MountableFile;
+import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
import com.azure.core.http.rest.PagedIterable;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobContainerClient;
@@ -34,36 +54,70 @@ import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.models.BlobItem;
import com.azure.storage.blob.models.ListBlobsOptions;
-import com.azure.storage.common.StorageSharedKeyCredential;
+
+import io.netty.handler.ssl.SslContext;
+import io.netty.handler.ssl.SslContextBuilder;
+import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
+import reactor.netty.http.client.HttpClient;
public class LSMAzBlobStorageTest extends AbstractLSMTest {
private static BlobContainerClient client;
private static BlobServiceClient blobServiceClient;
- private static final int MOCK_SERVER_PORT = 15055;
- private static final String MOCK_SERVER_HOSTNAME = "http://127.0.0.1:" + MOCK_SERVER_PORT;
private static final String MOCK_SERVER_REGION = "us-west-2";
+ private static AzuriteContainer azBlob;
+ public static final String AZURITE_CONTAINER_VER = "mcr.microsoft.com/azure-storage/azurite:3.35.0";
+
+ public static void generateSelfSignedTLS() throws Exception {
+ java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
+ keyPairGenerator.initialize(2048);
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+ PublicKey publicKey = keyPair.getPublic();
+ PrivateKey privateKey = keyPair.getPrivate();
+ long now = System.currentTimeMillis();
+ Date startDate = new Date(now);
+ X500Name dnName = new X500Name("CN=asterixdb azure test");
+ BigInteger certSerialNumber = new BigInteger(Long.toString(now));
+ Date endDate = new Date(now + 24 * 60 * 60 * 1000L); // 1 day validity
+ SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(publicKey.getEncoded());
+ X509v3CertificateBuilder certificateBuilder = new X509v3CertificateBuilder(dnName, certSerialNumber, startDate,
+ endDate, dnName, subjectPublicKeyInfo);
+ JcaContentSignerBuilder contentSignerBuilder = new JcaContentSignerBuilder("SHA256WithRSA");
+ X509Certificate selfSignedCertificate = new JcaX509CertificateConverter().setProvider("BC")
+ .getCertificate(certificateBuilder.build(contentSignerBuilder.build(privateKey)));
+ KeyStore keyStore = KeyStore.getInstance("PKCS12");
+ keyStore.load(null, null);
+ keyStore.setKeyEntry("mytestcert", privateKey, "password".toCharArray(),
+ new java.security.cert.Certificate[] { selfSignedCertificate });
+ try (FileOutputStream fos = new FileOutputStream("target" + File.separator + "azure_test.pfx")) {
+ keyStore.store(fos, "password".toCharArray());
+ }
+ }
@BeforeClass
public static void setup() throws Exception {
LOGGER.info("LSMAzBlobStorageTest setup");
-
- String endpointString = "http://127.0.0.1:15055/devstoreaccount1/" + PLAYGROUND_CONTAINER;
- final String accKey =
- "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
- final String accName = "devstoreaccount1";
-
- blobServiceClient = new BlobServiceClientBuilder().endpoint(endpointString)
- .credential(new StorageSharedKeyCredential(accName, accKey)).buildClient();
-
+ generateSelfSignedTLS();
+ MountableFile azureCert = MountableFile.forHostPath("target/azure_test.pfx");
+ azBlob = new AzuriteContainer(AZURITE_CONTAINER_VER).withSsl(azureCert, "password");
+ azBlob.start();
+ SslContext insecureSslContext =
+ SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
+ blobServiceClient = new BlobServiceClientBuilder().connectionString(azBlob.getConnectionString())
+ .httpClient(new NettyAsyncHttpClientBuilder(
+ HttpClient.create().secure(sslSpec -> sslSpec.sslContext(insecureSslContext).build())).build())
+ .buildClient();
// Start the test clean by deleting any residual data from previous tests
blobServiceClient.deleteBlobContainerIfExists(PLAYGROUND_CONTAINER);
client = blobServiceClient.createBlobContainerIfNotExists(PLAYGROUND_CONTAINER);
LOGGER.info("Az Blob Client created successfully");
int writeBufferSize = StorageUtil.getIntSizeInBytes(5, StorageUtil.StorageUnit.MEGABYTE);
- AzBlobStorageClientConfig config = new AzBlobStorageClientConfig(MOCK_SERVER_REGION, MOCK_SERVER_HOSTNAME, "",
- true, 0, PLAYGROUND_CONTAINER, 1, 0, 0, writeBufferSize, false);
+ URI blobStore = URI.create(blobServiceClient.getAccountUrl());
+ String endpoint = blobStore.getScheme() + "://" + blobStore.getAuthority() + "/devstoreaccount1";
+ AzBlobStorageClientConfig config = new AzBlobStorageClientConfig(MOCK_SERVER_REGION, endpoint, "", false, 0,
+ PLAYGROUND_CONTAINER, 1, 0, 0, writeBufferSize, true);
CLOUD_CLIENT = new AzBlobStorageCloudClient(config, ICloudGuardian.NoOpCloudGuardian.INSTANCE);
}
@@ -87,5 +141,7 @@ public class LSMAzBlobStorageTest extends AbstractLSMTest {
LOGGER.info("Shutdown Azurite");
// Azure clients do not need explicit closure.
cleanup();
+ azBlob.stop();
+ azBlob.close();
}
}
diff --git a/asterixdb/pom.xml b/asterixdb/pom.xml
index 74f4271b70..d6b9fafaab 100644
--- a/asterixdb/pom.xml
+++ b/asterixdb/pom.xml
@@ -650,6 +650,11 @@
${coverageArgLine}
${extraSurefireArgLine}
</argLine>
+ <environmentVariables>
+ <!-->Public/dummy test credentials for Azurite tests<!-->
+ <AZURE_STORAGE_ACCOUNT>devstoreaccount1</AZURE_STORAGE_ACCOUNT>
+ <AZURE_STORAGE_KEY>Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==</AZURE_STORAGE_KEY>
+ </environmentVariables>
<includes>
<include>${test.includes}</include>
</includes>
@@ -1696,6 +1701,11 @@
<artifactId>postgresql</artifactId>
<version>42.2.24</version>
</dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>azure</artifactId>
+ <version>1.21.3</version>
+ </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>