Skip to content
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

Add integration test module for appconfiguration #15582

Merged
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
####
# PRLabel: %App Configuration
/sdk/appconfiguration/ @mssfang @alzimmermsft
/sdk/appconfiguration/spring-cloud-azure-*/ @mrm9084 @saragluna @yiliuTo @chenrujun @zhoufenqin @jialindai
/sdk/appconfiguration/azure-spring-cloud-azure-*/ @mrm9084 @saragluna @yiliuTo @chenrujun @zhoufenqin @jialindai
chenrujun marked this conversation as resolved.
Show resolved Hide resolved

# PRLabel: %Batch
/sdk/batch/ @xingwu1 @bgklein @matthchr
Expand Down
1 change: 1 addition & 0 deletions eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ com.microsoft.azure:spring-cloud-azure-appconfiguration-config;1.2.8-beta.1;1.2.
com.microsoft.azure:spring-cloud-azure-feature-management-web;1.2.8-beta.1;1.2.8-beta.1
com.microsoft.azure:spring-cloud-azure-feature-management;1.2.8-beta.1;1.2.8-beta.1
com.microsoft.azure:spring-cloud-starter-azure-appconfiguration-config;1.2.8-beta.1;1.2.8-beta.1
com.microsoft.azure:spring-cloud-starter-azure-appconfiguration-config-test;1.2.8-beta.1;1.2.8-beta.1

# Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current
# version. Unreleased dependencies are only valid for dependency versions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version> <!-- {x-version-update;org.springframework.boot:spring-boot-starter-parent;external_dependency} -->
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-cloud-starter-appconfiguration-config-test</artifactId>
<version>1.2.8-beta.1</version> <!-- {x-version-update;com.microsoft.azure:azure-spring-cloud-starter-appconfiguration-config-test;current} -->

<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-starter-azure-appconfiguration-config</artifactId>
<version>1.2.8-beta.1</version> <!-- {x-version-update;com.microsoft.azure:spring-cloud-starter-azure-appconfiguration-config;current} -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.microsoft.azure.spring.cloud.config;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.assertj.core.api.Assertions.assertThat;

public class SampleIT {

private final Logger log = LoggerFactory.getLogger(SampleIT.class);
@Test
public void sampleTest() {
log.info("test log info.");
assertThat(true).isEqualTo(true);
}
}
4 changes: 4 additions & 0 deletions sdk/appconfiguration/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ extends:
- name: spring-cloud-starter-azure-appconfiguration-config
groupId: com.microsoft.azure
safeName: springcloudstarterazureappconfigurationconfig
AdditionalModules:
- name: azure-spring-cloud-starter-appconfiguration-config-test
groupId: com.microsoft.azure
safeName: azurespringcloudstarterappconfigurationconfigtest
1 change: 1 addition & 0 deletions sdk/appconfiguration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<module>azure-spring-cloud-feature-management</module>
<module>azure-spring-cloud-feature-management-web</module>
<module>azure-spring-cloud-starter-appconfiguration-config</module>
<module>azure-spring-cloud-starter-appconfiguration-config-test</module>
</modules>
</project>
19 changes: 16 additions & 3 deletions sdk/appconfiguration/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ jobs:
parameters:
ServiceDirectory: appconfiguration
Artifacts:
- name: azure-data-appconfiguration
groupId: com.azure
safeName: azuredataappconfiguration
- name: azure-spring-cloud-starter-appconfiguration-config-test
groupId: com.microsoft.azure
safeName: azurespringcloudstarterappconfigurationconfigtest
TimeoutInMinutes: 90
EnvVars:
AZURE_TEST_MODE: RECORD
AZURE_APPCONFIG_CONNECTION_STRING: $(AZURE_APPCONFIG_CONNECTION_STRING)
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
PostRunSteps:
- script: |
python --version
python -m pip install setuptools termcolor in_place
python sdk/spring/scripts/replace_util.py --module appconfiguration --log debug --color false
displayName: 'Run replace_util.py'
- task: Maven@3
displayName: 'Run tests again.'
inputs:
mavenPomFile: pom.xml
goals: clean verify
options: '-Dgpg.skip -Dmaven.wagon.http.pool=false -Dmaven.javadoc.skip=true -Drevapi.skip=true -pl $(ProjectList)'
5 changes: 4 additions & 1 deletion sdk/spring/azure-spring-cloud-autoconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ Support": this will configure the project to make sure you can integrate easily
For instance, let's assume that you want to use Event Hubs starter, you can add the usual `spring-cloud-starter-azure-eventhubs`
dependency to your project and the Spring Cloud auto-configuration will kick-in:

[//]: # ({x-version-update-start;com.microsoft.azure:spring-cloud-starter-azure-eventhubs;current})
```xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-starter-azure-eventhubs</artifactId>
<version>1.2.8</version>
</dependency>
```
[//]: # ({x-version-update-end})

Note that there is no need to add a `version` as those are managed already by the project.

Expand Down Expand Up @@ -59,7 +62,7 @@ Spring allow all the supported logging systems to set logger levels set in the S

The following example shows potential logging settings in `application.properties`:

```properties
```
logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
Expand Down
9 changes: 8 additions & 1 deletion sdk/spring/scripts/replace_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
VERSION_UPDATE_ITEMS = 'version_update_items'

config = {
'appconfiguration': {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than this complexity, wouldn't it be better to just have two test modules with the different versions and use the POM to control where the sources are loaded from?

Copy link
Author

Choose a reason for hiding this comment

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

have two test modules

Test code can not be shared in 2 modules.
We just want to write test code in one place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Remember that this complexity will make your build more brittle and harder for others to debug if something goes wrong. If there is a more "Maveny" way to do this with POM configuration then that would be better. Duplicating the tests might also be preferrable.

Copy link
Author

Choose a reason for hiding this comment

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

If there is a more "Maveny" way to do this with POM configuration then that would be better

I agree, but I didn't find that way.

Duplicating the tests might also be preferrable.

If we have many tests, for example, 50 ~ 100 tests, change the pom file is better than keep same code in 2 place. We already discussed inside our team. And spring module and cosmos module already do like this.

'sdk/appconfiguration/azure-spring-cloud-starter-appconfiguration-config-test/pom.xml': {
VERSION_UPDATE_ITEMS: (
VersionUpdateItem('org.springframework.boot:spring-boot-starter-parent', '2.2.9.RELEASE'),
)
}
},
'cosmos': {
'sdk/cosmos/azure-spring-data-cosmos-test/pom.xml': {
VERSION_UPDATE_ITEMS: (
Expand Down Expand Up @@ -83,7 +90,7 @@ def get_args():
parser.add_argument(
'--module',
type = str,
choices = ['spring', 'cosmos'],
choices = ['spring', 'cosmos', 'appconfiguration'],
required = False,
default = 'cosmos',
help = 'Specify the target module.'
Expand Down