Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
7711785
Disable Jetty by default. (#4964)
mitchdenny Aug 14, 2019
1b40f3a
Update package groups and add description in pom.xml for client libra…
srnagar Aug 14, 2019
7d24f9a
Event Hubs: Synchronous APIs Part 2 (#4970)
conniey Aug 14, 2019
6768fc9
Split the eventhubs client and data pipelines. (#4995)
mitchdenny Aug 14, 2019
58142d5
Add null check to fix spotbugs warning. (#4998)
conniey Aug 14, 2019
f173ae0
Seeing if we can speed up spotbugs (#4988)
JonathanGiles Aug 14, 2019
1ac4b2b
Enabling javadoc production for template. (#4963)
mitchdenny Aug 15, 2019
d44d8c3
Update link to Java Guidelines. (#4842)
Aug 15, 2019
ca83bd9
Fixes on Check on checkstyle (#5003)
mssfang Aug 15, 2019
99e76b4
Update Storage swagger (#4981)
tg-msft Aug 15, 2019
6eb9e89
Added spock test framework and tests for queue service (#4940)
sima-zhu Aug 15, 2019
2eec622
Fix directory path. (#5012)
mitchdenny Aug 16, 2019
56dc993
Renaming IterableResponse to IterableStream (#5002)
JonathanGiles Aug 16, 2019
faa0ef7
Add tracing context to storage blobs (#4752)
samvaity Aug 16, 2019
6f0f73f
Checkstyle - Javadoc - enforce formating for param, return and throw …
vhvb1989 Aug 16, 2019
0beab53
Fixes URL hosts with path segments (#4917)
jianghaolu Aug 16, 2019
f95da5a
Add staging profile id. (#5025)
mitchdenny Aug 16, 2019
5eab1e6
Adding Gauri Prassad to Storage Code Owner List (#5023)
alzimmermsft Aug 16, 2019
e688eb6
Feature/unified pipeline staging profiles (#5018)
mitchdenny Aug 16, 2019
8d0068d
Check if the first character in the passed SASToken string is a quest…
alzimmermsft Aug 16, 2019
41418b4
Make StorageException a POJO (#4924)
alzimmermsft Aug 16, 2019
bb70bee
Smoke test for Java (#4805)
JonathanCrd Aug 16, 2019
076e0f8
Fix URL construction for Storage (#5027)
jianghaolu Aug 17, 2019
84fa1c4
Use constant ServiceBus audience instead of letting the user provide …
bainian12345 Aug 17, 2019
146e3a8
Major version bump for service bus. (#5029)
mitchdenny Aug 17, 2019
b111ad3
CosmosDB: package 2015-04-08 update. (#5033)
yaohaizh Aug 19, 2019
32b7f60
Okhttp bug fix (#4944)
g2vinay Aug 19, 2019
619c70a
Adding rule to expect a text description for deprecated javadoc tags …
vhvb1989 Aug 19, 2019
6f80595
CheckStyle: regex for suppression and a few fiexes for generated chec…
mssfang Aug 19, 2019
37a35dd
remove cosmosdb/data-plane (#5037)
christopheranderson Aug 19, 2019
3aa5160
Adding rule for enforcing final field usage - DoNotMerge until all is…
vhvb1989 Aug 19, 2019
aceafd6
Update Storage Files swagger to 2019-02-02 (#5028)
tg-msft Aug 19, 2019
fe2039f
CosmosDb: Remove blocking calls from CFP (#4602)
milismsft Aug 20, 2019
608b30f
Cosmos Direct TCP port from azure-cosmosdb v2.6.1 (#5042)
Aug 20, 2019
9884b8a
Custom CheckStyle Rule #9: Thrown exception use ClientLogger (#4566)
mssfang Aug 20, 2019
926de5b
Fix Install Linting Issues (#5057)
alzimmermsft Aug 20, 2019
84dfd55
Add tracing context to storage queue (#4934)
samvaity Aug 20, 2019
4d892df
Storage file service spock tests (#4991)
sima-zhu Aug 20, 2019
8935711
Fix the wrong imports (#5069)
sima-zhu Aug 21, 2019
1713919
Added fake connection string for playback tests. (#5072)
sima-zhu Aug 21, 2019
c0386ae
Bump version. (#5077)
mitchdenny Aug 21, 2019
5583eb0
Remove the Netty dependency from azure-core (#4572)
JonathanGiles Aug 22, 2019
a89afa0
Fix tests (#5080)
sima-zhu Aug 22, 2019
88f4a6f
Remove parent/pom.xml for Event Hubs Track 1 (#5090)
conniey Aug 22, 2019
64efc1b
Add tracing context in Storage Files (#4888)
samvaity Aug 22, 2019
6610afa
Add Impressions tracking link to READMEs (#5035)
g2vinay Aug 22, 2019
1234a3a
Tune management build triggering (#5078)
mitchdenny Aug 22, 2019
025647a
JavaDoc and parameter validation improvements (#5098)
conniey Aug 23, 2019
8bd0f47
Storage: Updated Listing Operation Return Types (#4803)
jaschrep-msft Aug 23, 2019
437afae
Playback and Record for Azure Storage Blob (#4971)
alzimmermsft Aug 23, 2019
e77284a
Update Swagger for Blobs and Files (#5094)
alzimmermsft Aug 23, 2019
ebbfe5a
getHandles to listHandles API changes. (#5055)
sima-zhu Aug 24, 2019
26cbf5a
Network: update package 2019_06_01. (#5095)
yaohaizh Aug 24, 2019
b1f7af5
Setup unified pipelines for sdk/authorization. (#4828)
mitchdenny Aug 26, 2019
c5730d1
Setup sdk/loganalytics for unified pipelines. (#4832)
mitchdenny Aug 26, 2019
416710a
Setup event grid for unified pipelines. (#4831)
mitchdenny Aug 26, 2019
9cee15b
Setup mediaservices for unified pipelines. (#4833)
mitchdenny Aug 26, 2019
5f61d18
Setup AI for unified pipelines. (#4827)
mitchdenny Aug 26, 2019
27cfb8e
Setup unified pipelines for sdk/cognitiveservices (#4830)
mitchdenny Aug 26, 2019
10f0d47
Add azure batch code owners (#4573)
bgklein Aug 26, 2019
3911729
Add Storage to SpotBugs Aggregate Report (#5089)
alzimmermsft Aug 26, 2019
e0f3c5a
Using ISO8601 instead of RFC1123 in response type (#5109)
alzimmermsft Aug 26, 2019
6d300f3
Added clearRange and remove the FileRangeWriteType (#5060)
sima-zhu Aug 26, 2019
9371a88
Fixed logger setup bug in Storage SDK test setup (#5112)
jaschrep-msft Aug 26, 2019
6b14ac0
add more eng entries to CODEOWNERS (#5110)
danieljurek Aug 26, 2019
23aa967
Added core-http-netty to set of artificts to publish. (#5107)
mitchdenny Aug 26, 2019
08fab71
Basic plumbing for pipeline caching. (#5086)
mitchdenny Aug 26, 2019
c1d5a52
Whitespace change to test pipeline config.
mitchdenny Aug 26, 2019
109b1a8
Add suppression for null check. (#5118)
mitchdenny Aug 27, 2019
b6a884d
Add netty library to set of docs generated so it can publish/sign. (#…
mitchdenny Aug 27, 2019
bb2c2bb
Enabling Cosmos for Unified Pipelines (#5102)
mitchdenny Aug 27, 2019
ba8dbc1
Removed azure-core-http-netty from the published artifact list. (#5121)
mitchdenny Aug 27, 2019
f6f89c8
CheckStyleRule-Javadoc-Codesnippet Batch#3, No.7 and No.8 (#4920)
mssfang Aug 27, 2019
e4ebe48
Improve Track 1 Event Hubs RBAC tests (#5133)
JamesBirdsall Aug 27, 2019
ed9d8b6
CustomCheckStyleRules: Good Logging Practice (#3359)
mssfang Aug 27, 2019
6ccb9c6
Remove Storage swagger files and reference azure-rest-api-specs (#5116)
tg-msft Aug 28, 2019
9ccb976
Custom CheckStyle rules: Fluent Method Name Check (#3366)
mssfang Aug 28, 2019
3eda854
Remove suppression and fix error. (#5143)
conniey Aug 28, 2019
d2df860
pom updates (#5151)
g2vinay Aug 28, 2019
b7bf03b
use expected artifact names (#5148)
danieljurek Aug 28, 2019
66fd3cd
Custom CheckStyle: Batch 2, Rule #5 and #10; Batch 3, Rule #1 and #6 …
mssfang Aug 28, 2019
d856608
Adding java automatic module names to all track two client libraries …
JonathanGiles Aug 29, 2019
2da7e73
Generated from 5e1bb35d5c3314d8f4fead76c3d69a2522be026b
Aug 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Playback and Record for Azure Storage Blob (Azure#4971)
* Initial recording for Spock unit tests

* Updated client construction to use playback client

* Ignore sleeps in playback

* Tests cleanup after each run

* Each test keeps track of its increment count instead of the global

* Initial testing records (WIP)

* Fixing more playback and record edge cases, added new pipeline exception tracing

* More cleaning up of edge cases

* More edge cases fixed

* Octet-stream response types work properly

* Merged TestCommon into APISpec, removed JUnit dependency in blobs testing

* Added redaction for sensitive information in UserDelegationKey responses

* Added @requires annotations to live tests only

* Added playback records and added test ignore for live tests only

* Set dummy values for playback in pipeline

* Updating failing test records

* Fixed playback issue with AAD

* Cleaning up failing File tests

* Updating playback records

* Updated tests.yml for storage

* Fixed tests and playback, added more testing configurations

* Removing files that were deleted before merge

* Fixed checkstyle rule issues

* Updating playback records

* Responses to comments

* Fixed spacing issue

* Fix unit test issues

* Variable name change to try to fix test

* Added SLF4J testing dependency and ignoring tests that fail live run

* Ignore more failing tests

* Minor change to attempt to fix CI being stuck

* Fixed not enough bytes issue

* Fixed test issue
  • Loading branch information
alzimmermsft authored Aug 23, 2019
commit 437afae4f161957b7ba029f564d34e22c676c5de
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.ProxyOptions;
import com.azure.core.implementation.http.UrlBuilder;
import com.azure.core.test.models.NetworkCallRecord;
import com.azure.core.test.models.RecordedData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.Exceptions;
import reactor.core.publisher.Mono;

import java.net.URI;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -25,14 +26,14 @@
* HTTP client that plays back {@link NetworkCallRecord NetworkCallRecords}.
*/
public final class PlaybackClient implements HttpClient {
private final Logger logger = LoggerFactory.getLogger(PlaybackClient.class);
private final ClientLogger logger = new ClientLogger(PlaybackClient.class);
private final AtomicInteger count = new AtomicInteger(0);
private final Map<String, String> textReplacementRules;
private final RecordedData recordedData;

/**
* Creates a PlaybackClient that replays network calls from {@code recordedData} and replaces
* {@link NetworkCallRecord#response() response text} for any rules specified in {@code textReplacementRules}.
* Creates a PlaybackClient that replays network calls from {@code recordedData} and replaces {@link
* NetworkCallRecord#response() response text} for any rules specified in {@code textReplacementRules}.
*
* @param recordedData The data to playback.
* @param textReplacementRules A set of rules to replace text in network call responses.
Expand Down Expand Up @@ -88,14 +89,16 @@ private Mono<HttpResponse> playbackHttpResponse(final HttpRequest request) {
count.incrementAndGet();

if (networkCallRecord == null) {
if (logger.isWarnEnabled()) {
logger.warn("NOT FOUND - Method: {} URL: {}", incomingMethod, incomingUrl);
logger.warn("Records requested: {}.", count);
}
logger.warning("NOT FOUND - Method: {} URL: {}", incomingMethod, incomingUrl);
logger.warning("Records requested: {}.", count);

return Mono.error(new IllegalStateException("==> Unexpected request: " + incomingMethod + " " + incomingUrl));
}

if (networkCallRecord.exception() != null) {
throw logger.logExceptionAsWarning(Exceptions.propagate(networkCallRecord.exception().get()));
}

int recordStatusCode = Integer.parseInt(networkCallRecord.response().get("StatusCode"));
HttpHeaders headers = new HttpHeaders();

Expand All @@ -112,7 +115,7 @@ private Mono<HttpResponse> playbackHttpResponse(final HttpRequest request) {
}

String rawBody = networkCallRecord.response().get("Body");
byte[] bytes = new byte[0];
byte[] bytes = null;

if (rawBody != null) {
for (Map.Entry<String, String> rule : textReplacementRules.entrySet()) {
Expand All @@ -121,7 +124,20 @@ private Mono<HttpResponse> playbackHttpResponse(final HttpRequest request) {
}
}

bytes = rawBody.getBytes(StandardCharsets.UTF_8);
String contentType = networkCallRecord.response().get("Content-Type");

// octet-stream's are written to disk using Arrays.toString() which creates an output such as "[12, -1]".
if (contentType != null && contentType.equalsIgnoreCase("application/octet-stream")) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
for (String piece : rawBody.substring(1, rawBody.length() - 1).split(", ")) {
outputStream.write(Byte.parseByte(piece));
}

bytes = outputStream.toByteArray();
} else {
bytes = rawBody.getBytes(StandardCharsets.UTF_8);
}

if (bytes.length > 0) {
headers.put("Content-Length", String.valueOf(bytes.length));
}
Expand All @@ -141,7 +157,12 @@ private String applyReplacementRule(String text) {
}

private static String removeHost(String url) {
URI uri = URI.create(url);
return String.format("%s?%s", uri.getPath(), uri.getQuery());
UrlBuilder urlBuilder = UrlBuilder.parse(url);

if (urlBuilder.query().containsKey("sig")) {
urlBuilder.setQueryParameter("sig", "REDACTED");
}

return String.format("%s%s", urlBuilder.path(), urlBuilder.queryString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.core.test.models;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.net.UnknownHostException;

/**
* This class represents a caught throwable during a network call. It is used to serialize exceptions that were thrown
* during the pipeline and deserialize them back into their actual throwable class when running in playback mode.
*/
public class NetworkCallError {
@JsonProperty("Throwable")
private Throwable throwable;

@JsonProperty("ClassName")
private String className;

/**
* Empty constructor used by deserialization.
*/
public NetworkCallError() {
}

/**
* Constructs the class setting the throwable and its class name.
*
* @param throwable Throwable thrown during a network call.
*/
public NetworkCallError(Throwable throwable) {
this.throwable = throwable;
this.className = throwable.getClass().getName();
}

/**
* @return the thrown throwable as the class it was thrown as by converting is using its class name.
*/
public Throwable get() {
switch (className) {
case "java.lang.NullPointerException":
return new NullPointerException(throwable.getMessage());

case "java.lang.IndexOutOfBoundsException":
return new IndexOutOfBoundsException(throwable.getMessage());

case "java.net.UnknownHostException":
return new UnknownHostException(throwable.getMessage());

default:
return throwable;
}
}

/**
* Sets the throwable that was thrown during a network call.
*
* @param throwable Throwable that was thrown.
*/
public void throwable(Throwable throwable) {
this.throwable = throwable;
}

/**
* Sets the name of the class of the throwable. This is used during deserialization the construct the throwable
* as the actual class that was thrown.
*
* @param className Class name of the throwable.
*/
public void className(String className) {
this.className = className;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class NetworkCallRecord {
@JsonProperty("Response")
private Map<String, String> response;

@JsonProperty("Exception")
private NetworkCallError exception;

/**
* Gets the HTTP method for with this network call
*
Expand Down Expand Up @@ -96,4 +99,22 @@ public Map<String, String> response() {
public void response(Map<String, String> response) {
this.response = response;
}

/**
* Gets the throwable thrown during evaluation of the network call.
*
* @return Throwable thrown during the network call.
*/
public NetworkCallError exception() {
return exception;
}

/**
* Sets the throwable thrown during evaluation of the network call.
*
* @param exception Throwable thrown during the network call.
*/
public void exception(NetworkCallError exception) {
this.exception = exception;
}
}
Loading