Skip to content

Commit

Permalink
[Perf] Remove azure-core dependency from perf-test-core (#19598)
Browse files Browse the repository at this point in the history
- Reduces issues when testing older SDK versions
  • Loading branch information
mikeharder committed Mar 3, 2021
1 parent be77bc9 commit e5789dc
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 147 deletions.
9 changes: 5 additions & 4 deletions common/perf-test-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@
<rules>
<bannedDependencies>
<includes>
<include>com.azure:*</include>
<include>com.fasterxml.jackson.core:jackson-databind:[2.12.1]</include> <!-- {x-include-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->

<!-- special allowance for perf-test-core as it is not a shipping library: -->
<include>com.beust:jcommander:[1.78]</include> <!-- {x-include-update;com.beust:jcommander;external_dependency} -->

<include>io.projectreactor:reactor-core:[3.3.12.RELEASE]</include> <!-- {x-include-update;io.projectreactor:reactor-core;external_dependency} -->
</includes>
</bannedDependencies>
</rules>
Expand All @@ -76,9 +77,9 @@
<version>1.78</version> <!-- {x-version-update;com.beust:jcommander;external_dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.8.0</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.12.RELEASE</version> <!-- {x-version-update;io.projectreactor:reactor-core;external_dependency} -->
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@

package com.azure.perf.test.core;

import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;

class ExceptionTest extends PerfStressTest<PerfStressOptions> {
private final ClientLogger logger = new ClientLogger(ExceptionTest.class);

/**
* Sets up the Exception test.
* @param options the options to setup the test with.
Expand All @@ -21,8 +18,7 @@ public ExceptionTest(PerfStressOptions options) {
public void run() {
try {
throw new IllegalArgumentException();
} catch (Exception ex) {
logger.info("Test exception.", ex);
} catch (Exception e) {
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@

package com.azure.perf.test.core;

import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;


class SleepTest extends PerfStressTest<PerfStressOptions> {
private static final ClientLogger LOGGER = new ClientLogger(SleepTest.class);
private static final AtomicInteger INSTANCE_COUNT = new AtomicInteger();
private final int secondsPerOperation;


public SleepTest(PerfStressOptions options) {
super(options);

Expand All @@ -35,8 +31,7 @@ private static int pow(int value, int exponent) {
public void run() {
try {
Thread.sleep(secondsPerOperation * 1000);
} catch (InterruptedException e) {
throw LOGGER.logExceptionAsError(new RuntimeException(e));
} catch (Exception e) {
}
}

Expand Down
4 changes: 1 addition & 3 deletions common/perf-test-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

module com.azure.core.test.perf {
requires reactor.core;
requires org.reactivestreams;
requires jcommander;
requires reactor.netty;
requires io.netty.handler;
requires com.fasterxml.jackson.annotation;
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.azure.core;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public ServiceTest(TOptions options) {
.httpClient(new NettyAsyncHttpClientBuilder()
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 8888)))
.build());
//.httpClient(PerfStressHttpClient.create(options));

this.searchIndexAsyncClient = builder.buildAsyncClient();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.microsoft.azure.servicebus.perf;

import com.azure.core.util.logging.ClientLogger;
import com.azure.perf.test.core.TestDataCreationHelper;
import com.microsoft.azure.servicebus.perf.core.ServiceBusStressOptions;
import com.microsoft.azure.servicebus.perf.core.ServiceTest;
Expand All @@ -22,7 +21,6 @@
* Performance test.
*/
public class ReceiveAndDeleteMessageTest extends ServiceTest<ServiceBusStressOptions> {
private final ClientLogger logger = new ClientLogger(ReceiveAndDeleteMessageTest.class);
private final ServiceBusStressOptions options;
private final String messageContent;

Expand Down Expand Up @@ -68,10 +66,10 @@ public void run() {
try {
messages = receiver.receiveBatch(options.getMessagesToReceive());
if (messages.size() <= 0) {
throw logger.logExceptionAsWarning(new RuntimeException("Error. Should have received some messages."));
throw new RuntimeException("Error. Should have received some messages.");
}
} catch (Exception e) {
throw logger.logExceptionAsWarning(new RuntimeException(e));
throw new RuntimeException(e);
}
}

Expand All @@ -80,7 +78,6 @@ public Mono<Void> runAsync() {
return Mono.fromFuture(receiver.receiveBatchAsync(options.getMessagesToReceive()))
.handle((messages, synchronousSink) -> {
int count = messages.size();
logger.verbose(" Async received size of received : {}", count);
if (count <= 0) {
synchronousSink.error(new RuntimeException("Error. Should have received some messages."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.microsoft.azure.servicebus.perf;

import com.azure.core.util.logging.ClientLogger;
import com.azure.perf.test.core.TestDataCreationHelper;
import com.microsoft.azure.servicebus.perf.core.ServiceBusStressOptions;
import com.microsoft.azure.servicebus.perf.core.ServiceTest;
Expand All @@ -23,7 +22,6 @@
* Performance test.
*/
public class ReceiveAndLockMessageTest extends ServiceTest<ServiceBusStressOptions> {
private final ClientLogger logger = new ClientLogger(ReceiveAndLockMessageTest.class);
private final ServiceBusStressOptions options;
private final String messageContent;

Expand Down Expand Up @@ -62,14 +60,14 @@ public void run() {
try {
messages = receiver.receiveBatch(options.getMessagesToReceive());
} catch (Exception e) {
throw logger.logExceptionAsWarning(new RuntimeException(e));
throw new RuntimeException(e);
}

for (IMessage message : messages) {
try {
receiver.complete(message.getLockToken());
} catch (InterruptedException | ServiceBusException e) {
throw logger.logExceptionAsWarning(new RuntimeException(e));
throw new RuntimeException(e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.microsoft.azure.servicebus.perf;

import com.azure.core.util.logging.ClientLogger;
import com.azure.perf.test.core.TestDataCreationHelper;
import com.microsoft.azure.servicebus.perf.core.ServiceBusStressOptions;
import com.microsoft.azure.servicebus.perf.core.ServiceTest;
Expand All @@ -18,7 +17,6 @@
* Performance test.
*/
public class SendMessageTest extends ServiceTest<ServiceBusStressOptions> {
private final ClientLogger logger = new ClientLogger(SendMessageTest.class);
private final Message message;

/**
Expand All @@ -37,7 +35,7 @@ public void run() {
try {
sender.send(message);
} catch (InterruptedException | ServiceBusException e) {
throw logger.logExceptionAsWarning(new RuntimeException(e));
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.microsoft.azure.servicebus.perf;

import com.azure.core.util.logging.ClientLogger;
import com.azure.perf.test.core.TestDataCreationHelper;
import com.microsoft.azure.servicebus.perf.core.ServiceBusStressOptions;
import com.microsoft.azure.servicebus.perf.core.ServiceTest;
Expand All @@ -21,8 +20,6 @@
* Performance test.
*/
public class SendMessagesTest extends ServiceTest<ServiceBusStressOptions> {
private final ClientLogger logger = new ClientLogger(SendMessagesTest.class);

private final List<IMessage> messages;

/**
Expand All @@ -46,7 +43,7 @@ public void run() {
try {
sender.sendBatch(messages);
} catch (InterruptedException | ServiceBusException e) {
throw logger.logExceptionAsWarning(new RuntimeException(e));
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package com.microsoft.azure.servicebus.perf.core;

import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.perf.test.core.PerfStressOptions;
import com.azure.perf.test.core.PerfStressTest;
import com.microsoft.azure.servicebus.ClientFactory;
Expand All @@ -21,7 +19,6 @@
* @param <TOptions> for performance configuration.
*/
public abstract class ServiceTest<TOptions extends PerfStressOptions> extends PerfStressTest<TOptions> {
private final ClientLogger logger = new ClientLogger(ServiceTest.class);
private static final String AZURE_SERVICE_BUS_CONNECTION_STRING = "AZURE_SERVICE_BUS_CONNECTION_STRING";
private static final String AZURE_SERVICEBUS_QUEUE_NAME = "AZURE_SERVICEBUS_QUEUE_NAME";
protected static final int TOTAL_MESSAGE_MULTIPLIER = 300;
Expand All @@ -40,26 +37,24 @@ public abstract class ServiceTest<TOptions extends PerfStressOptions> extends Pe
public ServiceTest(TOptions options, ReceiveMode receiveMode) {
super(options);
String connectionString = System.getenv(AZURE_SERVICE_BUS_CONNECTION_STRING);
if (CoreUtils.isNullOrEmpty(connectionString)) {
throw logger.logExceptionAsError(new IllegalArgumentException("Environment variable "
+ AZURE_SERVICE_BUS_CONNECTION_STRING + " must be set."));
if (connectionString == null || connectionString.length() == 0) {
throw new IllegalArgumentException("Environment variable "
+ AZURE_SERVICE_BUS_CONNECTION_STRING + " must be set.");
}
logger.verbose("connectionString : {}", connectionString);

String queueName = System.getenv(AZURE_SERVICEBUS_QUEUE_NAME);
if (CoreUtils.isNullOrEmpty(queueName)) {
throw logger.logExceptionAsError(new IllegalArgumentException("Environment variable "
+ AZURE_SERVICEBUS_QUEUE_NAME + " must be set."));
if (queueName == null || queueName.length() == 0) {
throw new IllegalArgumentException("Environment variable "
+ AZURE_SERVICEBUS_QUEUE_NAME + " must be set.");
}
logger.verbose("queueName : {}", queueName);

// Setup the service client
try {
this.factory = MessagingFactory.createFromConnectionString(connectionString);
this.sender = ClientFactory.createMessageSenderFromEntityPath(factory, queueName);
this.receiver = ClientFactory.createMessageReceiverFromEntityPath(factory, queueName, receiveMode);
} catch (ServiceBusException | InterruptedException | ExecutionException e) {
throw logger.logExceptionAsWarning(new RuntimeException(e));
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package com.azure.storage.blob.perf.core;

import com.azure.core.util.CoreUtils;
import com.azure.perf.test.core.PerfStressHttpClient;
import com.azure.perf.test.core.PerfStressOptions;
import com.azure.perf.test.core.PerfStressTest;
import com.azure.storage.blob.BlobServiceAsyncClient;
Expand All @@ -26,8 +25,7 @@ public ServiceTest(TOptions options) {

// Setup the service client
BlobServiceClientBuilder builder = new BlobServiceClientBuilder()
.connectionString(connectionString)
.httpClient(PerfStressHttpClient.create(options));
.connectionString(connectionString);

blobServiceClient = builder.buildClient();
blobServiceAsyncClient = builder.buildAsyncClient();
Expand Down

0 comments on commit e5789dc

Please sign in to comment.