Skip to content

Commit

Permalink
Fix eg tests (#35766)
Browse files Browse the repository at this point in the history
* add partner registration to test-resources

* no longer need static env vars

* fix spotbugs
  • Loading branch information
billwert authored Jul 6, 2023
1 parent 2e5aba7 commit 04d79bb
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,14 @@
</Match>
<Bug pattern="NM_CONFUSING"/>

<!-- This method is made synchronous by blocking and waiting for a result. They do not return
anything, so it can be ignored. -->
<Match>
<Class name="com.microsoft.azure.eventgrid.implementation.EventGridClientImpl"/>
<Method name="publishEvents"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
</Match>

<Match>
<Class name="com.azure.ai.metricsadvisor.implementation.models.InfluxDBParameter"/>
<Method name="getUserName"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -176,7 +177,7 @@ private static String canonicalizeEventType(final String eventType) {
if (eventType == null) {
return null;
} else {
return eventType.toLowerCase();
return eventType.toLowerCase(Locale.ROOT);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
Expand Down Expand Up @@ -184,7 +185,7 @@ private static String canonicalizeEventType(final String eventType) {
if (eventType == null) {
return null;
} else {
return eventType.toLowerCase();
return eventType.toLowerCase(Locale.ROOT);
}
}
}
75 changes: 73 additions & 2 deletions sdk/eventgrid/test-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
}
},
"variables": {
"apiVersion": "2020-06-01",
"apiVersion": "2022-06-15",
"eventGridTopicName": "[concat(parameters('baseName'), 'topic')]",
"cloudeventTopicName": "[concat(parameters('baseName'), 'cloudevent-topic')]",
"cloudeventDomainName": "[concat(parameters('baseName'), 'cloudevent-domain')]",
"customeventTopicName": "[concat(parameters('baseName'), 'customevent-topic')]"
"customeventTopicName": "[concat(parameters('baseName'), 'customevent-topic')]",
"partnerRegistrationName": "[concat(parameters('baseName'), 'partner-registration')]",
"partnerConfigurationName": "default",
"partnerNamespaceName": "[concat(parameters('baseName'), 'partner-namespace')]",
"partnerChannelName": "[concat(parameters('baseName'), 'partner-channel')]",
"partnerTopicName": "[concat(parameters('baseName'), 'partner-topic')]"
},
"resources": [
{
Expand Down Expand Up @@ -72,6 +77,60 @@
}
}
}
},
{
"type": "Microsoft.EventGrid/partnerRegistrations",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('partnerRegistrationName')]",
"location": "global"
},
{
"type": "Microsoft.EventGrid/partnerConfigurations",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('partnerConfigurationName')]",
"dependsOn": [
"[resourceId('Microsoft.EventGrid/partnerRegistrations', variables('partnerRegistrationName'))]"
],
"location": "global",
"properties": {
"partnerAuthorization": {
"authorizedPartnersList": [
{
"partnerRegistrationImmutableId": "[reference(variables('partnerRegistrationName')).partnerRegistrationImmutableId]"
}
]
}
}
},
{
"type": "Microsoft.EventGrid/partnerNamespaces",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('partnerNamespaceName')]",
"dependsOn": [
"[resourceId('Microsoft.EventGrid/partnerConfigurations', variables('partnerConfigurationName'))]"
],
"location": "[resourceGroup().location]",
"properties": {
"partnerRegistrationFullyQualifiedId": "[resourceId('Microsoft.EventGrid/partnerRegistrations', variables('partnerRegistrationName'))]",
"partnerTopicRoutingMode": "ChannelNameHeader"
}
},
{
"type": "Microsoft.EventGrid/partnerNamespaces/channels",
"apiVersion": "[variables('apiVersion')]",
"name": "[concat(variables('partnerNamespaceName'), '/', variables('partnerChannelName'))]",
"dependsOn": [
"[resourceId('Microsoft.EventGrid/partnerNamespaces', variables('partnerNamespaceName'))]"
],
"properties": {
"channelType": "PartnerTopic",
"partnerTopicInfo": {
"azureSubscriptionId": "[subscription().subscriptionId]",
"name": "[variables('partnerTopicName')]",
"resourceGroupName": "[resourceGroup().Name]",
"source": "customSource"
}
}
}
],
"outputs": {
Expand Down Expand Up @@ -106,6 +165,18 @@
"AZURE_EVENTGRID_CUSTOM_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/topics', variables('customeventTopicName')), variables('apiVersion')).key1]"
},
"EVENTGRID_PARTNER_NAMESPACE_TOPIC_ENDPOINT": {
"type": "string",
"value": "[reference(variables('partnerNamespaceName')).endpoint]"
},
"EVENTGRID_PARTNER_NAMESPACE_TOPIC_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventGrid/partnerNamespaces', variables('partnerNamespaceName')), variables('apiVersion')).key1]"
},
"EVENTGRID_PARTNER_CHANNEL_NAME": {
"type": "string",
"value": "[variables('partnerChannelName')]"
}
}
}
7 changes: 0 additions & 7 deletions sdk/eventgrid/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ stages:
- name: azure-messaging-eventgrid-cloudnative-cloudevents
groupId: com.azure
safeName: azuremessagingeventgridcloudnativecloudevents
EnvVars:
# Static resource is used for testing publishing events to partner topics because this feature is not GA yet.
# Python var names were used when the keys were added to TestSecrets2 Key Vault.
# Instead of duplicating it in all languages, we'll use this temporarily until this feature is GA'd.
EVENTGRID_PARTNER_NAMESPACE_TOPIC_ENDPOINT: $(python-eventgrid-partner-endpoint)
EVENTGRID_PARTNER_NAMESPACE_TOPIC_KEY: $(python-eventgrid-partner-key)
EVENTGRID_PARTNER_CHANNEL_NAME: $(python-eventgrid-partner-channel-name)

0 comments on commit 04d79bb

Please sign in to comment.