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

Eg sync stack testproxy #36656

Merged
merged 47 commits into from
Oct 11, 2023
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
130895c
Add missing sync test cases
billwert Jun 12, 2023
5dc3fca
Enable sync-stack
billwert Jun 23, 2023
2daff85
Remove extra set of aeg-channel-name.
billwert Jun 23, 2023
6a0874a
enable AssertingHttpClient
billwert Jun 23, 2023
b80c1a8
add back missing Context arguments
billwert Jun 29, 2023
043e39a
Don't stop trying dev credentials on failures
billwert Jul 14, 2023
dbc2b6c
Tests now use test proxy and recordings are pushed to assets repo
billwert Sep 6, 2023
18dd529
resolve merge conflicts
srnagar Sep 14, 2023
f9ed9a0
address pr comments
srnagar Sep 14, 2023
64f5e98
fix merge conflicts
srnagar Sep 14, 2023
1b35edc
add exports
srnagar Sep 15, 2023
dcf148a
fix version
srnagar Sep 15, 2023
c6a2bb3
remove unused imports
srnagar Sep 15, 2023
26cc35a
use unreleased test version
srnagar Sep 19, 2023
dc41e49
fix tag
srnagar Sep 19, 2023
fb20989
fix tag
srnagar Sep 19, 2023
5560758
refactor
srnagar Sep 20, 2023
44e43fd
fix spring test after sync stack migration
srnagar Sep 20, 2023
1d2d820
log the test proxy response on error
srnagar Sep 20, 2023
48911db
fix header sanitizer in Service Bus
srnagar Sep 22, 2023
edbe426
fix regex for quantum job tests
srnagar Sep 24, 2023
f4d8493
Add missing sync test cases
billwert Jun 12, 2023
503813c
Enable sync-stack
billwert Jun 23, 2023
a1f0197
Remove extra set of aeg-channel-name.
billwert Jun 23, 2023
5087c06
enable AssertingHttpClient
billwert Jun 23, 2023
b224700
add back missing Context arguments
billwert Jun 29, 2023
e9a00d1
Tests now use test proxy and recordings are pushed to assets repo
billwert Sep 6, 2023
9b5a6eb
address pr comments
srnagar Sep 14, 2023
e01a753
add exports
srnagar Sep 15, 2023
7ec717e
fix version
srnagar Sep 15, 2023
67c932a
use unreleased test version
srnagar Sep 19, 2023
4cffdee
fix tag
srnagar Sep 19, 2023
66939e8
fix tag
srnagar Sep 19, 2023
a7ca1f7
refactor
srnagar Sep 20, 2023
799c12a
fix spring test after sync stack migration
srnagar Sep 20, 2023
507db27
log the test proxy response on error
srnagar Sep 20, 2023
baaf27d
fix header sanitizer in Service Bus
srnagar Sep 22, 2023
5ad9038
fix regex for quantum job tests
srnagar Sep 24, 2023
b29abdd
Put a semaphore around starting the proxy.
billwert Sep 25, 2023
531a43c
make the methods of `TestProxyManager` static and synchronized.
billwert Sep 27, 2023
189b6a3
Use the working directory to search for the root of the repo from.
billwert Sep 29, 2023
7d2ed33
add missing sanitizer setup
billwert Oct 6, 2023
3b8518e
base class has this so it's not needed here
billwert Oct 6, 2023
ceb9d57
removed this in merge accidentally
billwert Oct 6, 2023
10da9a6
resolve merge conflicts
srnagar Oct 9, 2023
6dc76f6
Merge branch 'main' into eg-sync-stack-testproxy
srnagar Oct 10, 2023
dca5125
pin azure-core version
srnagar Oct 10, 2023
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
Prev Previous commit
Next Next commit
add back missing Context arguments
billwert committed Jul 7, 2023
commit b80c1a87e012a1b62450cb250e78dea113bb43d0
Original file line number Diff line number Diff line change
@@ -236,13 +236,14 @@ private void sendCloudEvents(Iterable<CloudEvent> events) {
/**
* Publishes the given events to the set topic or domain and gives the response issued by EventGrid.
* @param events the events to publish.
* @param context the context to use along the pipeline.
*
* @return the response from the EventGrid service.
* @throws NullPointerException if events is {@code null}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> sendEventsWithResponse(Iterable<T> events) {
return this.sendEventsWithResponse(events, null);
public Response<Void> sendEventsWithResponse(Iterable<T> events, Context context) {
return this.sendEventsWithResponse(events, null, context);
}


@@ -252,51 +253,52 @@ public Response<Void> sendEventsWithResponse(Iterable<T> events) {
* @param channelName the channel name to send to Event Grid service. This is only applicable for sending
* Cloud Events to a partner topic in partner namespace. For more details, refer to
* <a href=https://docs.microsoft.com/azure/event-grid/partner-events-overview>Partner Events Overview.</a>
* @param context the context to use along the pipeline.
*
* @return the response from the EventGrid service.
* @throws NullPointerException if events is {@code null}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
@SuppressWarnings("unchecked")
public Response<Void> sendEventsWithResponse(Iterable<T> events, String channelName) {
public Response<Void> sendEventsWithResponse(Iterable<T> events, String channelName, Context context) {
if (this.eventClass == CloudEvent.class) {
return this.sendCloudEventsWithResponse((Iterable<CloudEvent>) events, channelName);
return this.sendCloudEventsWithResponse((Iterable<CloudEvent>) events, channelName, context);
} else if (this.eventClass == EventGridEvent.class) {
return this.sendEventGridEventsWithResponse((Iterable<EventGridEvent>) events);
return this.sendEventGridEventsWithResponse((Iterable<EventGridEvent>) events, context);
} else {
return this.sendCustomEventsWithResponse((Iterable<BinaryData>) events);
return this.sendCustomEventsWithResponse((Iterable<BinaryData>) events, context);
}
}

private Response<Void> sendCustomEventsWithResponse(Iterable<BinaryData> events) {
private Response<Void> sendCustomEventsWithResponse(Iterable<BinaryData> events, Context context) {
if (events == null) {
throw logger.logExceptionAsError(new NullPointerException("'events' cannot be null."));
}
List<Object> objectEvents = StreamSupport.stream(events.spliterator(), false)
.map(event -> (Object) new RawValue(event.toString()))
.collect(Collectors.toList());
return this.impl.publishCustomEventEventsWithResponse(this.hostname, objectEvents, Context.NONE);
return this.impl.publishCustomEventEventsWithResponse(this.hostname, objectEvents, context);
}

private Response<Void> sendEventGridEventsWithResponse(Iterable<EventGridEvent> events) {
private Response<Void> sendEventGridEventsWithResponse(Iterable<EventGridEvent> events, Context context) {
if (events == null) {
throw logger.logExceptionAsError(new NullPointerException("'events' cannot be null."));
}

List<com.azure.messaging.eventgrid.implementation.models.EventGridEvent> eventGridEvents = StreamSupport.stream(events.spliterator(), false)
.map(EventGridEvent::toImpl)
.collect(Collectors.toList());
return this.impl.publishEventGridEventsWithResponse(this.hostname, eventGridEvents, Context.NONE);
return this.impl.publishEventGridEventsWithResponse(this.hostname, eventGridEvents, context);
}

private Response<Void> sendCloudEventsWithResponse(Iterable<CloudEvent> events, String channelName) {
private Response<Void> sendCloudEventsWithResponse(Iterable<CloudEvent> events, String channelName, Context context) {
if (events == null) {
throw logger.logExceptionAsError(new NullPointerException("'events' cannot be null."));
}

List<CloudEvent> cloudEvents = StreamSupport.stream(events.spliterator(), false)
.collect(Collectors.toList());
return this.impl.publishCloudEventEventsWithResponse(this.hostname, cloudEvents, channelName, Context.NONE);
return this.impl.publishCloudEventEventsWithResponse(this.hostname, cloudEvents, channelName, context);
}

/**
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import com.azure.core.models.CloudEvent;
import com.azure.core.models.CloudEventDataFormat;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.messaging.eventgrid.EventGridPublisherClient;
import com.azure.messaging.eventgrid.EventGridPublisherClientBuilder;
import com.azure.messaging.eventgrid.samples.models.User;
@@ -58,6 +59,6 @@ public static void main(String[] args) {
events.add(cloudEventBytes.addExtensionAttribute("extension", "value"));

// send to "my-channel-name" channel
publisherClient.sendEventsWithResponse(events, "my-channel-name");
publisherClient.sendEventsWithResponse(events, "my-channel-name", Context.NONE);
}
}
Original file line number Diff line number Diff line change
@@ -447,7 +447,7 @@ public void publishEventGridEventsSync() {
"1.0")
.setEventTime(OffsetDateTime.now()));

Response<Void> response = egClient.sendEventsWithResponse(events);
Response<Void> response = egClient.sendEventsWithResponse(events, Context.NONE);

assertNotNull(response);
assertEquals(response.getStatusCode(), 200);
@@ -546,7 +546,7 @@ public void publishCloudEventsSync() {
.setSubject("Test")
.setTime(OffsetDateTime.now()));

Response<Void> response = egClient.sendEventsWithResponse(events);
Response<Void> response = egClient.sendEventsWithResponse(events, Context.NONE);

assertNotNull(response);
assertEquals(response.getStatusCode(), 200);
@@ -597,7 +597,7 @@ public void publishCloudEventsToPartnerTopicSync() {
.setTime(OffsetDateTime.now());

Response<Void> response = egClient.sendEventsWithResponse(Arrays.asList(event),
getChannelName(EVENTGRID_PARTNER_CHANNEL_NAME));
getChannelName(EVENTGRID_PARTNER_CHANNEL_NAME), Context.NONE);
assertEquals(200, response.getStatusCode());
}

@@ -622,7 +622,7 @@ public void publishEventGridEventToPartnerTopicSync() {

HttpResponseException exception = assertThrows(HttpResponseException.class, () -> {
egClient.sendEventsWithResponse(Arrays.asList(event),
getChannelName(EVENTGRID_PARTNER_CHANNEL_NAME));
getChannelName(EVENTGRID_PARTNER_CHANNEL_NAME), Context.NONE);
});
assertEquals(400, exception.getResponse().getStatusCode());
}
@@ -653,7 +653,7 @@ public void serialize(TestData testData, JsonGenerator jsonGenerator, Serializer
);
}

Response<Void> response = egClient.sendEventsWithResponse(events);
Response<Void> response = egClient.sendEventsWithResponse(events, Context.NONE);
assertEquals(200, response.getStatusCode());
}

@@ -675,7 +675,7 @@ public void publishCustomEventsSync() {
}
}));
}
Response<Void> response = egClient.sendEventsWithResponse(events);
Response<Void> response = egClient.sendEventsWithResponse(events, Context.NONE);

assertNotNull(response);
assertEquals(response.getStatusCode(), 200);
@@ -700,7 +700,7 @@ public void publishCustomEventsWithSerializerSync() {
}
}, new JacksonJsonSerializerBuilder().build()));
}
Response<Void> response = egClient.sendEventsWithResponse(events);
Response<Void> response = egClient.sendEventsWithResponse(events, Context.NONE);
assertEquals(200, response.getStatusCode());
}