You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by is...@apache.org on 2022/05/20 12:56:17 UTC
[airavata-data-lake] branch master updated: add testFetchMetadata
This is an automated email from the ASF dual-hosted git repository.
isjarana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-data-lake.git
The following commit(s) were added to refs/heads/master by this push:
new 5394a63 add testFetchMetadata
new ef91466 Merge pull request #97 from isururanawaka/test_framework
5394a63 is described below
commit 5394a63f66d20175ffabcf951315e38064a69386
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Fri May 20 08:55:32 2022 -0400
add testFetchMetadata
---
.../loadtesting/handlers/LoadTestHandler.java | 69 ++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/loadtesting-utilities/src/main/java/org/apache/airavata/datalake/loadtesting/handlers/LoadTestHandler.java b/loadtesting-utilities/src/main/java/org/apache/airavata/datalake/loadtesting/handlers/LoadTestHandler.java
index 78a3ec2..b92950e 100644
--- a/loadtesting-utilities/src/main/java/org/apache/airavata/datalake/loadtesting/handlers/LoadTestHandler.java
+++ b/loadtesting-utilities/src/main/java/org/apache/airavata/datalake/loadtesting/handlers/LoadTestHandler.java
@@ -296,6 +296,75 @@ public class LoadTestHandler {
+ }
+
+
+
+ @RequestMapping(value = "/testFetchMetadata", method = RequestMethod.GET)
+ @ResponseBody
+ public String testFetchMetadata(@RequestParam("username") String username,
+ @RequestParam("tenantId") String tenantId,
+ @RequestParam("totalIterations") int iterations,
+ @RequestParam("reportChunkSize") int reportChunkSize,
+ @RequestParam("filePath") String filePath,
+ @RequestParam("entityId") String resourceId) {
+
+
+ ManagedChannel channel = ManagedChannelBuilder.forAddress(serviceHost, servicePort).usePlaintext().build();
+ ResourceServiceGrpc.ResourceServiceBlockingStub resourceClient = ResourceServiceGrpc.newBlockingStub(channel);
+
+
+
+ int successRequests = 0;
+ int failureRequests = 0;
+ long sum = 0;
+
+ Map<String, String> latencyMap = new HashMap<>();
+
+ int chunkSize = 1;
+
+ for (int i = 0; i < iterations; i++) {
+ try {
+ long beginLatency = System.currentTimeMillis();
+ FetchResourceMetadataRequest request = FetchResourceMetadataRequest
+ .newBuilder()
+ .setAuthToken(DRMSServiceAuthToken.newBuilder()
+ .setAuthenticatedUser(AuthenticatedUser.newBuilder()
+ .setTenantId(tenantId)
+ .setUsername(username)
+ .build()))
+ .setResourceId(resourceId)
+ .build();
+ FetchResourceMetadataResponse response = resourceClient.fetchResourceMetadata(request);
+ long endLatency = System.currentTimeMillis();
+
+ long diff = endLatency - beginLatency;
+ latencyMap.put(String.valueOf(i), String.valueOf(diff));
+ sum += diff;
+ if (response.getMetadataCount()!= 0) {
+ successRequests++;
+ }
+ } catch (Exception ex) {
+ failureRequests++;
+ }
+
+ if (chunkSize % reportChunkSize == 0) {
+ long avgSuccessRate = (successRequests / chunkSize) * 100;
+ long avgFailureRare = (failureRequests / chunkSize) * 100;
+
+ writeToAFile(latencyMap, avgSuccessRate, avgFailureRare, filePath, "testResourceCreateRequest");
+ latencyMap.clear();
+ successRequests = 0;
+ failureRequests = 0;
+ chunkSize = 1;
+ } else {
+ chunkSize++;
+ }
+ }
+ return "load test completed";
+
+
+
}