-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add support for the perf library for ACR. #23118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
sdk/containerregistry/azure-containers-containerregistry-perf/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Release History | ||
|
|
||
| ## 1.0.0-beta.1 (Unreleased) | ||
|
|
62 changes: 62 additions & 0 deletions
62
sdk/containerregistry/azure-containers-containerregistry-perf/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
|  |
78 changes: 78 additions & 0 deletions
78
sdk/containerregistry/azure-containers-containerregistry-perf/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
25 changes: 25 additions & 0 deletions
25
...containerregistry-perf/src/main/java/com/azure/containers/containerregistry/perf/App.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 -> 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); | ||
| } | ||
| } |
56 changes: 56 additions & 0 deletions
56
.../src/main/java/com/azure/containers/containerregistry/perf/GetManifestPropertiesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
...y-perf/src/main/java/com/azure/containers/containerregistry/perf/ListRepositoryTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
105 changes: 105 additions & 0 deletions
105
...stry-perf/src/main/java/com/azure/containers/containerregistry/perf/core/ServiceTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
| 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)); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header #Resolved