From 535456b203fdae69b588f9e924db57c06ded8096 Mon Sep 17 00:00:00 2001 From: samvaity Date: Mon, 6 Dec 2021 15:34:14 -0800 Subject: [PATCH] add getBlobProperties perf test --- .../main/java/com/azure/core/perf/App.java | 3 +- .../azure/core/perf/GetBlobProperties.java | 56 +++++++++++++++++++ .../azure/core/perf/UploadFromFileTest.java | 10 ++-- 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/GetBlobProperties.java diff --git a/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/App.java b/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/App.java index 07a8574bf5a23..098edf1b5d0ff 100644 --- a/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/App.java +++ b/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/App.java @@ -18,7 +18,8 @@ public class App { public static void main(String[] args) { PerfStressProgram.run(new Class[]{ - UploadFromFileTest.class + UploadFromFileTest.class, + GetBlobProperties.class }, args); } } diff --git a/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/GetBlobProperties.java b/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/GetBlobProperties.java new file mode 100644 index 0000000000000..d8210d76ef204 --- /dev/null +++ b/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/GetBlobProperties.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.perf; + +import com.azure.core.perf.core.ServiceTest; +import com.azure.perf.test.core.PerfStressOptions; +import com.azure.storage.blob.BlobContainerAsyncClient; +import com.azure.storage.blob.BlobContainerClient; +import com.azure.storage.blob.BlobServiceAsyncClient; +import com.azure.storage.blob.BlobServiceClient; +import com.azure.storage.blob.models.BlobProperties; +import reactor.core.publisher.Mono; + +import java.util.UUID; + +public class GetBlobProperties extends ServiceTest { + public GetBlobProperties(PerfStressOptions options) { + super(options); + } + + @Override + public Mono globalSetupAsync() { + return super.globalSetupAsync(); + } + + @Override + public Mono globalCleanupAsync() { + return super.globalCleanupAsync(); + } + + @Override + public void run() { + String blobName = "perfblobtest-" + UUID.randomUUID(); + + BlobServiceClient storageClient = blobServiceClientBuilder.buildClient(); + + BlobContainerClient blobContainerClient = storageClient.createBlobContainer("perfupload" + UUID.randomUUID()); + BlobProperties blobProperties = blobContainerClient.getBlobClient(blobName).getProperties(); + assert blobProperties.getCreationTime() != null; + assert blobProperties.getExpiresOn() != null; + } + + @Override + public Mono runAsync() { + String blobName = "perfblobtest-" + UUID.randomUUID(); + + BlobServiceAsyncClient storageAsyncClient = blobServiceClientBuilder.buildAsyncClient(); + + BlobContainerAsyncClient + blobContainerAsyncClient = storageAsyncClient.createBlobContainer("perfupload" + UUID.randomUUID()).block(); + return blobContainerAsyncClient.getBlobAsyncClient(blobName) + .getProperties() + .then(); + } +} diff --git a/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/UploadFromFileTest.java b/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/UploadFromFileTest.java index c5c68ca908fed..13c2ca5254233 100644 --- a/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/UploadFromFileTest.java +++ b/sdk/core/azure-core-perf/src/main/java/com/azure/core/perf/UploadFromFileTest.java @@ -5,9 +5,7 @@ import com.azure.core.perf.core.ServiceTest; import com.azure.perf.test.core.PerfStressOptions; -import com.azure.storage.blob.BlobAsyncClient; import com.azure.storage.blob.BlobClient; -import com.azure.storage.blob.BlobContainerAsyncClient; import com.azure.storage.blob.BlobContainerClient; import com.azure.storage.blob.BlobServiceAsyncClient; import com.azure.storage.blob.BlobServiceClient; @@ -48,9 +46,9 @@ public Mono runAsync() { BlobServiceAsyncClient storageAsyncClient = blobServiceClientBuilder.buildAsyncClient(); - BlobContainerAsyncClient - blobContainerAsyncClient = storageAsyncClient.createBlobContainer("perfupload" + UUID.randomUUID()).block(); - BlobAsyncClient blobAsyncClient = blobContainerAsyncClient.getBlobAsyncClient(blobName); - return blobAsyncClient.uploadFromFile(filePath, true); + return storageAsyncClient.createBlobContainer("perfupload" + UUID.randomUUID()) + .flatMap(blobContainerAsyncClient -> blobContainerAsyncClient.getBlobAsyncClient(blobName) + .uploadFromFile(filePath, true)); + } }