Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ com.azure:azure-identity;1.2.4;1.3.0-beta.3
com.azure:azure-identity-perf;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-iot-deviceupdate;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-messaging-eventgrid;4.0.0;4.1.0-beta.1
com.azure:azure-messaging-eventgrid-perf;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-messaging-eventhubs;5.6.0;5.7.0-beta.1
com.azure:azure-messaging-eventhubs-checkpointstore-blob;1.5.1;1.6.0-beta.1
com.azure:azure-messaging-servicebus;7.1.0;7.2.0-beta.1
Expand Down
3 changes: 3 additions & 0 deletions sdk/eventgrid/azure-messaging-eventgrid-perf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Release History

## 1.0.0-beta.1 (Unreleased)
43 changes: 43 additions & 0 deletions sdk/eventgrid/azure-messaging-eventgrid-perf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Azure Performance and Stress client library for Java

Azure Performance and Stress client library is a collection of classes which form the performance testing framework. It
helps developers create their performance tests for their APIs.

## Getting started

### Prerequisites

- Java Development Kit (JDK) with version 8 or above

### Adding the package to your product

[//]: # ({x-version-update-start;com.azure:perf-test-core;current})
```xml
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-evenggrid-perf</artifactId>
<version>1.0.0-beta.1</version>
</dependency>
```
[//]: # ({x-version-update-end})

## Key concepts


## Examples

## Troubleshooting

## Next steps

## Contributing

For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/master/CONTRIBUTING.md).

1. Fork it
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
1. Create new Pull Request

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fcommon%2Fperf-test-core%2FREADME.png)
67 changes: 67 additions & 0 deletions sdk/eventgrid/azure-messaging-eventgrid-perf/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventgrid-perf</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-messaging-eventgrid-perf;current} -->
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventgrid</artifactId>
<version>4.1.0-beta.1</version> <!-- {x-version-update;com.azure:azure-messaging-eventgrid;current} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>perf-test-core</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:perf-test-core;current} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-serializer-json-jackson</artifactId>
<version>1.2.0</version> <!-- {x-version-update;com.azure:azure-core-serializer-json-jackson;dependency} -->
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-assembly-plugin;external_dependency} -->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
com.azure.messaging.eventgrid.perf.App
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.eventgrid.perf;

import com.azure.perf.test.core.PerfStressProgram;

/**
* Runs the Event Grid performance test.
*
* <p>To run from command line. Package the project into a jar with dependencies via mvn clean package.
* Then run the program with 'java -jar azure-messaging-eventgrid-perf-1.0.0-beta.1-jar-with-dependencies.jar' </p>
*
* <p> To run from IDE, set all the required environment variables in IntelliJ via Run -&gt; EditConfigurations section.
* Then run the App's main method via IDE.</p>
*/
public class App {
/**
* Run the EventGrid perf test
* @param args the arguments
*/
public static void main(String[] args) {
PerfStressProgram.run(new Class<?>[] {
SendCloudEventsTest.class,
SendEventGridEventsTest.class,
SendCustomEventsTest.class
}, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.eventgrid.perf;

import java.time.OffsetDateTime;

class CustomEvent {
private final String id;
private final OffsetDateTime time;
private final String subject;
private final String foo;
private final String type;
private final String data;
private final String dataVersion;

CustomEvent(String id, OffsetDateTime time, String subject, String foo,
String type, String data, String dataVersion) {
this.id = id;
this.time = time;
this.subject = subject;
this.foo = foo;
this.type = type;
this.data = data;
this.dataVersion = dataVersion;
}

public String getData() {
return data;
}

public OffsetDateTime getTime() {
return time;
}

public String getDataVersion() {
return dataVersion;
}

public String getFoo() {
return foo;
}

public String getId() {
return id;
}

public String getSubject() {
return subject;
}

public String getType() {
return type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.eventgrid.perf;

import com.azure.core.models.CloudEvent;
import com.azure.core.models.CloudEventDataFormat;
import com.azure.core.util.BinaryData;
import com.azure.perf.test.core.PerfStressOptions;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Test performance of sending cloud events
*/
public class SendCloudEventsTest extends ServiceTest<PerfStressOptions> {
/**
* Create the SendCloudEventsTest
* @param options options
*/
public SendCloudEventsTest(PerfStressOptions options) {
super(options);
}

@Override
public void run() {
cloudEventPublisherClient.sendEvents(createEvents());
}

// Perform the Async API call to be tested here
@Override
public Mono<Void> runAsync() {
return cloudEventPublisherAsyncClient.sendEvents(createEvents());
}

private List<CloudEvent> createEvents() {
List<CloudEvent> events = new ArrayList<>();
for (int i = 0; i < options.getCount(); i++) {
String dataPayload = String.join("", Collections.nCopies(options.getCount(), "A"));
CloudEvent ce = new CloudEvent("https://www.eventgrid.com/", "EG.Perf",
BinaryData.fromObject(new TestModelClass(dataPayload)), CloudEventDataFormat.JSON, "application/json");
events.add(ce);
}
return events;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.eventgrid.perf;

import com.azure.core.util.BinaryData;
import com.azure.perf.test.core.PerfStressOptions;
import reactor.core.publisher.Mono;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

/**
* Test performance of sending custom events
*/
public class SendCustomEventsTest extends ServiceTest<PerfStressOptions> {

/**
* Create the SendCustomEventsTest
* @param options options.
*/
public SendCustomEventsTest(PerfStressOptions options) {
super(options);
}

@Override
public void run() {
customEventPublisherClient.sendEvents(createEvents());
}

// Perform the Async API call to be tested here
@Override
public Mono<Void> runAsync() {
return customEventPublisherAsyncClient.sendEvents(createEvents());
}

private List<BinaryData> createEvents() {
List<BinaryData> events = new ArrayList<>();
for (int i = 0; i < options.getCount(); i++) {
String dataPayload = String.join("", Collections.nCopies(options.getCount(), "A"));
CustomEvent customEvent = new CustomEvent(
UUID.randomUUID().toString(),
OffsetDateTime.now(),
"Test",
"bar",
"Microsoft.MockPublisher.TestEvent",
dataPayload,
"0.1"
);
events.add(BinaryData.fromObject(customEvent));
}
return events;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.eventgrid.perf;

import com.azure.core.util.BinaryData;
import com.azure.messaging.eventgrid.EventGridEvent;
import com.azure.perf.test.core.PerfStressOptions;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Test performance of sending event grid events
*/
public class SendEventGridEventsTest extends ServiceTest<PerfStressOptions> {

/**
* Create the SendEventGridEventsTest
* @param options options
*/
public SendEventGridEventsTest(PerfStressOptions options) {
super(options);
}

@Override
public void run() {
eventGridEventPublisherClient.sendEvents(createEvents());
}

// Perform the Async API call to be tested here
@Override
public Mono<Void> runAsync() {
return eventGridEventPublisherAsyncClient.sendEvents(createEvents());
}

private List<EventGridEvent> createEvents() {
List<EventGridEvent> events = new ArrayList<>();
for (int i = 0; i < options.getCount(); i++) {
String dataPayload = String.join("", Collections.nCopies(options.getCount(), "A"));
EventGridEvent event = new EventGridEvent("https://www.eventgrid.com/", "EG.Perf",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be using this uri?

BinaryData.fromObject(new TestModelClass(dataPayload)), "v1");
events.add(event);
}
return events;
}
}
Loading