Skip to content
Merged
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 @@ -58,6 +58,7 @@ com.azure:azure-communication-sms;1.0.3;1.1.0-beta.1
com.azure:azure-communication-identity;1.1.1;1.2.0-beta.1
com.azure:azure-communication-phonenumbers;1.0.3;1.1.0-beta.1
com.azure:azure-containers-containerregistry;1.0.0-beta.3;1.0.0-beta.4
com.azure:azure-containers-containerregistry-perf;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-core;1.18.0;1.19.0-beta.2
com.azure:azure-core-amqp;2.3.0;2.4.0-beta.1
com.azure:azure-core-amqp-experimental;1.0.0-beta.1;1.0.0-beta.1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Azure Container Registry Performance test client library for Java

Represents Performance tests for Azure Container Registry for Java.

## Getting started

### Prerequisites

- A [Java Development Kit (JDK)][jdk_link], version 8 or later.
- [Azure Subscription][azure_subscription]

### Adding the package to your product

You will need the following environment variables for running the tests to access the live resources:

```
CONTAINERREGISTRY_ENDPOINT=<azure container registry service endpoint>
CONTAINERREGISTRY_REGISTRY_NAME=<azure container registry name.>
CONTAINERREGISTRY_SUBSCRIPTION_ID=<subscription id in which azure container registry is created.>

// You should also have the default credentials set up done.
AZURE_TENANT_ID=<azure tenant id.>
AZURE_CLIENT_ID=<azure client id.>
```

### Adding the package to your product
## Key concepts

## Examples
#### Executing the performance test
1. Compile the performance project into a standalone jar using the command from the root of the perf project folder
```
mvn clean package -f sdk/containerregistry/azure-containers-containerregistry-perf/pom.xml

2. Execute the corresponding perf test in the project using the command.
```
java -jar <path-to-packaged-jar-with-dependencies-from-step-1> <options-for-the-test>
java -jar sdk/containerregistry/azure-containers-containerregistry-perf/target/azure-containers-containerregistry-perf-1.0.0-beta.1-jar-with-dependencies.jar getmanifestproperties --warmup 1 --iterations 1 --parallel 50 --duration 15 --count 1000
java -jar sdk/containerregistry/azure-containers-containerregistry-perf/target/azure-containers-containerregistry-perf-1.0.0-beta.1-jar-with-dependencies.jar listrepositorytests --warmup 1 --iterations 1 --parallel 50 --duration 15 --count 1000

#### Common perf test command line options for Text Analytics
- `--duration` - Number of seconds to run the main test for. Default is 10.
- `--iterations` - Number of iterations of main test loop.
- `--parallel` - Number of operations to execute in parallel,
- `--warmup` - Duration of test warmup time in seconds before the test attributes are calculated.


## 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%2Fsdk%template%2Fperf-test-core%2FREADME.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?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-containers-containerregistry-perf</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-containers-containerregistry-perf;current} -->
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-containers-containerregistry</artifactId>
<version>1.0.0-beta.4</version> <!-- {x-version-update;com.azure:azure-containers-containerregistry;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.resourcemanager</groupId>
<artifactId>azure-resourcemanager-containerregistry</artifactId>
<version>2.6.0</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-containerregistry;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.3.3</version> <!-- {x-version-update;com.azure:azure-identity;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.containers.containerregistry.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,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.containers.containerregistry.perf;

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

/**
* Runs the Azure Container Registry performance test.
*
* <p>To run from command line. Package the project into a jar with dependencies via mvn clean package.
* Then run the program via java -jar 'compiled-jar-with-dependencies-path' </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 {
public static void main(String[] args) {
PerfStressProgram.run(new Class<?>[]{
GetManifestPropertiesTest.class,
ListRepositoryTests.class,
}, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.containers.containerregistry.perf;

;

import com.azure.containers.containerregistry.ContainerRepository;
import com.azure.containers.containerregistry.ContainerRepositoryAsync;
import com.azure.containers.containerregistry.RegistryArtifact;
import com.azure.containers.containerregistry.RegistryArtifactAsync;
import com.azure.containers.containerregistry.models.ArtifactManifestProperties;
import com.azure.containers.containerregistry.perf.core.ServiceTest;
import com.azure.perf.test.core.PerfStressOptions;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.List;

import static com.azure.containers.containerregistry.perf.core.Utils.REPOSITORY_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG1_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG2_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG3_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG4_NAME;

public class GetManifestPropertiesTest extends ServiceTest<PerfStressOptions> {
private final RegistryArtifactAsync registryArtifactAsync;
private final RegistryArtifact registryArtifact;
private final List<String> tags;

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

tags = Arrays.asList(TEST_PERF_TAG1_NAME, TEST_PERF_TAG2_NAME, TEST_PERF_TAG3_NAME, TEST_PERF_TAG4_NAME);
registryArtifact = containerRegistryClient.getArtifact(REPOSITORY_NAME, TEST_PERF_TAG1_NAME);
registryArtifactAsync = containerRegistryAsyncClient.getArtifact(REPOSITORY_NAME, TEST_PERF_TAG1_NAME);
}

@Override
public Mono<Void> globalSetupAsync() {
return super.globalSetupAsync()
.then(importImageAsync(REPOSITORY_NAME, tags));
}

@Override
public void run() {
registryArtifact.getManifestProperties();
}

@Override
public Mono<Void> runAsync() {
return registryArtifactAsync.getManifestProperties()
.then();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.containers.containerregistry.perf;

import com.azure.containers.containerregistry.perf.core.ServiceTest;
import com.azure.perf.test.core.PerfStressOptions;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.List;

import static com.azure.containers.containerregistry.perf.core.Utils.REPOSITORY_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG1_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG2_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG3_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.TEST_PERF_TAG4_NAME;

public class ListRepositoryTests extends ServiceTest<PerfStressOptions> {

public ListRepositoryTests(PerfStressOptions options) {
super(options);
}

@Override
public Mono<Void> globalSetupAsync() {
return super.globalSetupAsync()
.then(importImageAsync(REPOSITORY_NAME, Arrays.asList(TEST_PERF_TAG1_NAME, TEST_PERF_TAG2_NAME, TEST_PERF_TAG3_NAME, TEST_PERF_TAG4_NAME)));
}

@Override
public void run() {
containerRegistryClient.listRepositoryNames();
}

@Override
public Mono<Void> runAsync() {
return containerRegistryAsyncClient.listRepositoryNames().then();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.containers.containerregistry.perf.core;
Copy link
Member

@alzimmermsft alzimmermsft Jul 21, 2021

Choose a reason for hiding this comment

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

Missing license header #Resolved


import com.azure.containers.containerregistry.ContainerRegistryAsyncClient;
import com.azure.containers.containerregistry.ContainerRegistryClient;
import com.azure.containers.containerregistry.ContainerRegistryClientBuilder;
import com.azure.core.credential.TokenCredential;
import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.profile.AzureProfile;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.perf.test.core.PerfStressOptions;
import com.azure.perf.test.core.PerfStressTest;
import com.azure.resourcemanager.containerregistry.ContainerRegistryManager;
import com.azure.resourcemanager.containerregistry.models.ImportImageParameters;
import com.azure.resourcemanager.containerregistry.models.ImportMode;
import com.azure.resourcemanager.containerregistry.models.ImportSource;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.stream.Collectors;

import static com.azure.containers.containerregistry.perf.core.Utils.CONFIGURATION;
import static com.azure.containers.containerregistry.perf.core.Utils.PROPERTY_CONTAINERREGISTRY_ENDPOINT;
import static com.azure.containers.containerregistry.perf.core.Utils.PROPERTY_CONTAINERREGISTRY_NAME;
import static com.azure.containers.containerregistry.perf.core.Utils.PROPERTY_CONTAINERREGISTRY_RESOURCE_GROUP;
import static com.azure.containers.containerregistry.perf.core.Utils.PROPERTY_CONTAINERREGISTRY_SUBSCRIPTION_ID;
import static com.azure.containers.containerregistry.perf.core.Utils.REGISTRY_URI;

/**
* Base class for Azure Container Registry performance tests.
*/
public abstract class ServiceTest<TOptions extends PerfStressOptions> extends PerfStressTest<TOptions> {
private static final String CONFIGURATION_ERROR = "Configuration %s must be set in either environment variables "
+ "or system properties.%n";

final String registryEndpoint;
final String registryName;
final String rgName;
final String subscriptionId;
final TokenCredential tokenCredential;

protected ContainerRegistryClient containerRegistryClient;
protected ContainerRegistryAsyncClient containerRegistryAsyncClient;



/**
* The base class for Azure Container Registry performance tests.
*
* @param options the configurable options for performing perf testing on this class.
*
* @throws RuntimeException if "AZURE_CONTAINERREGISTRY_ENDPOINT", "AZURE_CLIENT_ID", "AZURE_SUBSCRIPTION_ID" or "AZURE_CLIENT_SECRET" is null or empty.
*/
public ServiceTest(TOptions options) {
super(options);

registryEndpoint = getConfigurationValue(PROPERTY_CONTAINERREGISTRY_ENDPOINT);
registryName = getConfigurationValue(PROPERTY_CONTAINERREGISTRY_NAME);

// DefaultCredentials rely on these values, so ensure that they have been set up.
getConfigurationValue(Configuration.PROPERTY_AZURE_CLIENT_ID);
getConfigurationValue(Configuration.PROPERTY_AZURE_CLIENT_SECRET);

// importImage relies on these values, so ensure that they have been set up.
subscriptionId = getConfigurationValue(PROPERTY_CONTAINERREGISTRY_SUBSCRIPTION_ID);
rgName = getConfigurationValue(PROPERTY_CONTAINERREGISTRY_RESOURCE_GROUP);

tokenCredential = new DefaultAzureCredentialBuilder().build();
ContainerRegistryClientBuilder builder = new ContainerRegistryClientBuilder()
.endpoint(registryEndpoint)
.credential(tokenCredential);

this.containerRegistryClient = builder.buildClient();
this.containerRegistryAsyncClient = builder.buildAsyncClient();
}


private String getConfigurationValue(String configurationName) {
String configurationValue = CONFIGURATION.get(configurationName);
if (CoreUtils.isNullOrEmpty(configurationValue)) {
throw new RuntimeException(String.format(CONFIGURATION_ERROR, configurationName));
}

return configurationValue;
}

protected Mono<Void> importImageAsync(String repositoryName, List<String> tags) {
tags = tags.stream().map(tag -> String.format("%1$s:%2$s", repositoryName, tag)).collect(Collectors.toList());

ContainerRegistryManager manager = ContainerRegistryManager.authenticate(tokenCredential, new AzureProfile(AzureEnvironment.AZURE));

return manager.serviceClient().getRegistries().importImageAsync(
rgName,
registryName,
new ImportImageParameters()
.withMode(ImportMode.FORCE)
.withSource(new ImportSource().withSourceImage(repositoryName)
.withRegistryUri(REGISTRY_URI))
.withTargetTags(tags));
}
}
Loading