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
Setup integration testing against real Azure services on the CI #37
Comments
|
@JonathanGiles mentioned that the tests are not executed against "real" Azure services (as tests could be unstable). They are run against proxies that have recorded specific Azure HTTP responses (this is my understanding, I'm sure @JonathanGiles will clarify this). |
|
It would be great to hear more details. |
|
The Azure SDK uses a mechanism called "PlayBack Testing". Basically it records the network calls when invoking the Azure services, stores the requests/responses in JSon, and then runs the tests against these JSon files. Here is the test class in AppConfiguration which is setting up the When in PLAYBACK it will override the classpath configured HttpClient with PlaybackClient that is capable of matching up requests with the recorded responses. Or, when in RECORD it will add an HttpPipelinePolicy that will record network calls to create the playback record. And here is an example of a playback record: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/appconfiguration/azure-data-appconfiguration/src/test/resources/session-records/ConfigurationAsyncClientTest.addConfigurationSettingConvenience%5B1%5D.json Read https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/core/azure-core-test |
|
We could probably try it with the config extension, since it is fairly simple. |
|
Thanks for the explanation, @agoncal. I think this concept of PlayBack testing could work well for testing on JVM. For native, I have a bit of methodological concerns: Quarkus native integration tests consist of two substantial parts: 1. a test application 2. assertions. Out of those, only the test app is compiled into native executable. It is compiled together with all its transitive dependencies. I think it would not be correct to switch the production HTTP client for the PlayBack client, because that would result in a substantially different test app. We could miss important native mode issues in that way. I wonder how hard it would be to modify the concept so that the recorded responses would be sent over HTTP by a mock server? We should definitely use this for JVM testing while we do not have anything better. A technical question: How does the Azure SDK team handle to life cycle of the recorded responses? Are they updated regularly - time based, or perhaps on every deployment of the given Azure service? |
|
cc @maxandersen |
|
@ppalaga Good question. @alzimmermsft do you know how often the JSON requests/responses are updated? |
|
Unfortunately, there isn't an exact answer to how often the playback record are re-recorded as this is left to the maintainer/maintainers of a given SDK. Generally, they should either be re-recorded or updated when new service features are supported by the SDK, but in many cases only new tests are recorded in these cases and minimal updates are applied to existing recordings (for example changing API versions in the JSON file with a find and replace mechanism). And for the SDKs this works as we also perform nightly, or manually triggered if needed, testing against live Azure resources. I recently began discussions with our engineering systems team on ways we could make it easier, and safer, to record playback recordings by hooking into our existing live testing pipelines but at that time this was more a developer convenience, both internally and externally, and I didn't push too much on this. I can start those discussions up again if there will be a requirement to maintain "fresh" playback recordings. Azure/azure-sdk-tools#5138
Funny you mention this as this is something we are currently migrating to 😄 Azure/azure-sdk-for-java#24792 We're migrating to an out-of-process mock server instead of using the in-process mock |
|
@alzimmermsft so it is accurate to say that each time we bump the version of the Azure SDK we should re-record the JSON outputs? |
|
FYI I am starting experimenting this feature: https://github.com/quarkiverse/quarkus-azure-services/tree/agoncal/playback |
I may have been a bit unclear on wording there, any time the SDK supports a new Azure service version the playback records should be re-recorded, not any time a new SDK version is released. So, say AppConfiguration releases a new service version that the SDK supports the playback recordings should be re-recorded, but we do new SDK releases every month and those don't require re-recording. |
Great news, thanks for the info! We will be able to use it for both JVM and native tests then. |
|
@alzimmermsft when I record my test again the real Azure App Configuration service, it generates a JSON file with empty calls and variables. What is do is just set the When executing the test I do see some traces related to HTTP requests: |
|
@agoncal I don't know much about how the public class TestExample extends TestBase {
public ConfigurationClient setupTestClient() {
ConfigurationClientBuilder builder = new ConfigurationClientBuilder()
// In PLAYBACK use the PlaybackClient otherwise let the classpath determine the HttpClient.
.httpClient(getTestMode() == TestMode.PLAYBACK ? interceptorManager.getPlaybackClient() : null)
.endpoint(endpoint)
// TokenCredential needs to be mocked in PLAYBACK as it shouldn't require the network in PLAYBACK.
.credential(getTestMode() == TestMode.PLAYBACK ? mockCredential : realCredential);
if (getTestMode() == TestMode.RECORD) {
// Add the RecordNetworkPolicy in RECORD mode to capture requests and responses.
builder.addPolicy(interceptorManager.getRecordPolicy());
}
return builder.builderClient();
}
} |
|
Hello @ppalaga @agoncal Today I talked to @backwind1233 who is from Azure Spring Cloud team and has been working on developing spring starter on top of Azure Java SDK (which is quite similar Quarkus Azure service extension). He showed me that Azure Spring Cloud starters does run integration test against real azure services, for example, this file declares App Config service that will be deployed and tested during the integration testing. As a result, I think we can circle back and also consider this direction which was the original request. I'll work on it next week and share more later. |
|
I endorse @majguo 's approach to follow the existing practice for Spring Cloud Azure, which is to use actual service instances. |
|
Since I talked to @alzimmermsft, the Azure SDK team created this blog post with a video on there Test Proxy. It's really what we are looking for. Check it out https://devblogs.microsoft.com/azure-sdk/level-up-your-cloud-testing-game-with-the-azure-sdk-test-proxy. |
|
@agoncal @ppalaga @edburns and All - Thank you all for valuable inputs. I just created a separate issue #110 to track the enhancement about setting up the integration tests using the Azure SDK test proxy. This issue (#37) will just serve its original request - Setup integration testing against real Azure services on the CI. |
We chatted about this with @agoncal
The text was updated successfully, but these errors were encountered: