Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function(config) {
// inject following environment values into browser testing with window.__env__
// environment values MUST be exported or set with same console running "karma start"
// https://www.npmjs.com/package/karma-env-preprocessor
envPreprocessor: ["EVENTHUB_CONNECTION_STRING_BROWSER", "EVENTHUB_NAME", "IOTHUB_EH_COMPATIBLE_CONNECTION_STRING_BROWSER"],
envPreprocessor: ["EVENTHUB_CONNECTION_STRING", "EVENTHUB_NAME", "IOTHUB_EH_COMPATIBLE_CONNECTION_STRING"],

// test results reporter to use
// possible values: 'dots', 'progress'
Expand Down
11 changes: 4 additions & 7 deletions sdk/eventhub/event-hubs/test/utils/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ export enum EnvVarKeys {
AZURE_CLIENT_SECRET = "AZURE_CLIENT_SECRET"
}

function getEnvVarValue(name: string, addBrowserSuffix?: boolean): string | undefined {
function getEnvVarValue(name: string): string | undefined {
if (isNode) {
return process.env[name];
} else {
const nameForBrowser = addBrowserSuffix ? name + "_BROWSER" : name;
// @ts-ignore
return window.__env__[nameForBrowser];
return window.__env__[name];
}
}

export function getEnvVars(): { [key in EnvVarKeys]: any } {
return {
[EnvVarKeys.EVENTHUB_CONNECTION_STRING]: getEnvVarValue(
EnvVarKeys.EVENTHUB_CONNECTION_STRING,
!isNode
EnvVarKeys.EVENTHUB_CONNECTION_STRING
),
[EnvVarKeys.EVENTHUB_NAME]: getEnvVarValue(EnvVarKeys.EVENTHUB_NAME),
[EnvVarKeys.IOTHUB_EH_COMPATIBLE_CONNECTION_STRING]: getEnvVarValue(
EnvVarKeys.IOTHUB_EH_COMPATIBLE_CONNECTION_STRING,
!isNode
EnvVarKeys.IOTHUB_EH_COMPATIBLE_CONNECTION_STRING
),
[EnvVarKeys.AZURE_TENANT_ID]: getEnvVarValue(EnvVarKeys.AZURE_TENANT_ID),
[EnvVarKeys.AZURE_CLIENT_ID]: getEnvVarValue(EnvVarKeys.AZURE_CLIENT_ID),
Expand Down
18 changes: 4 additions & 14 deletions sdk/eventhub/event-hubs/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,52 @@ jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-integration.yml
parameters:
PackageName: "@azure/event-hubs"
ResourceServiceDirectory: eventhub
# Remove Browser tests from matrix since they are currently a no-op
Matrix:
Linux_Node10:
OSVmImage: "ubuntu-16.04"
TestType: "node"
NodeVersion: "10.x"
EVENTHUB_NAME: "hub_linux_node10"
Windows_Node10:
OSVmImage: "windows-2019"
TestType: "node"
NodeVersion: "10.x"
EVENTHUB_NAME: "hub_windows_node10"
macOS_Node10:
OSVmImage: "macOS-10.13"
TestType: "node"
NodeVersion: "10.x"
EVENTHUB_NAME: "hub_mac_node10"
Linux_Node12:
OSVmImage: "ubuntu-16.04"
TestType: "node"
NodeVersion: "12.x"
EVENTHUB_NAME: "hub_linux_node12"
Windows_Node12:
OSVmImage: "windows-2019"
TestType: "node"
NodeVersion: "12.x"
EVENTHUB_NAME: "hub_windows_node12"
macOS_Node12:
OSVmImage: "macOS-10.13"
TestType: "node"
NodeVersion: "12.x"
EVENTHUB_NAME: "hub_mac_node12"
Linux_Node8:
OSVmImage: "ubuntu-16.04"
TestType: "node"
NodeVersion: "8.x"
EVENTHUB_NAME: "hub_linux_node8"
Windows_Node8:
OSVmImage: "windows-2019"
TestType: "node"
NodeVersion: "8.x"
EVENTHUB_NAME: "hub_windows_node8"
macOS_Node8:
OSVmImage: "macOS-10.13"
TestType: "node"
NodeVersion: "8.x"
EVENTHUB_NAME: "hub_mac_node8"
Windows_Browser:
OSVmImage: "windows-2019"
TestType: "browser"
EVENTHUB_NAME: "hub_windows_chrome"
EnvVars:
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)
IOTHUB_EH_COMPATIBLE_CONNECTION_STRING: $(js-event-hubs-test-iothub-connection-string)
EVENTHUB_CONNECTION_STRING: $(js-event-hubs-test-connection-string)
IOTHUB_EH_COMPATIBLE_CONNECTION_STRING_BROWSER: $(js-event-hubs-test-browser-iothub-connection-string)
EVENTHUB_CONNECTION_STRING_BROWSER: $(js-event-hubs-test-browser-connection-string)
EVENTHUB_NAME: $(EVENTHUB_NAME)
EVENTHUB_CONNECTION_STRING: $(EVENTHUB_CONNECTION_STRING)
IOTHUB_EH_COMPATIBLE_CONNECTION_STRING: $(IOTHUB_EH_COMPATIBLE_CONNECTION_STRING)
9 changes: 5 additions & 4 deletions sdk/eventhub/event-processor-host/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-integration.yml
parameters:
PackageName: "@azure/event-processor-host"
ResourceServiceDirectory: eventhub
# Remove Browser tests from matrix since they are currently a no-op
Matrix:
Linux_Node10:
Expand All @@ -24,9 +25,9 @@ jobs:
OSVmImage: "macOS-10.13"
TestType: "node"
EnvVars:
EVENTHUB_CONNECTION_STRING: $(js-event-hubs-test-connection-string)
EVENTHUB_NAME: $(js-event-hubs-test-name)
IOTHUB_CONNECTION_STRING: $(js-event-processor-host-test-iothub-connection-string)
STORAGE_CONNECTION_STRING: $(js-event-hubs-test-storage-connection-string)
EVENTHUB_NAME: $(EVENTHUB_NAME)
EVENTHUB_CONNECTION_STRING: $(EVENTHUB_CONNECTION_STRING)
IOTHUB_CONNECTION_STRING: $(IOTHUB_CONNECTION_STRING)
STORAGE_CONNECTION_STRING: $(STORAGE_CONNECTION_STRING)
# Event Hubs tests do not support concurrent execution
MaxParallel: 1
214 changes: 214 additions & 0 deletions sdk/eventhub/test-resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseName": {
"type": "string",
"defaultValue": "[resourceGroup().name]",
"metadata": {
"description": "The base resource name."
}
}
},
"variables": {
"apiVersion": "2017-04-01",
"storageApiVersion": "2019-04-01",
"iotApiVersion": "2018-04-01",
"namespaceName": "[parameters('baseName')]",
"storageAccountName": "[concat('storage', parameters('baseName'))]",
"containerName": "container",
"iotName": "[concat('iot', parameters('baseName'))]",
"authorizationName": "[concat(parameters('baseName'), '/RootManageSharedAccessKey')]",
"eventHubName": "eventhub",
"eventHubNameFull": "[concat(parameters('baseName'), '/eventhub')]",
"location": "[resourceGroup().location]"
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('namespaceName')]",
"location": "[variables('location')]",
"sku": {
"name": "Standard",
"tier": "Standard",
"capacity": 5
},
"properties": {
"zoneRedundant": false,
"isAutoInflateEnabled": false,
"maximumThroughputUnits": 0
}
},
{
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('authorizationName')]",
"location": "[variables('location')]",
"dependsOn": ["[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"],
"properties": {
"rights": ["Listen", "Manage", "Send"]
}
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('eventHubNameFull')]",
"location": "[variables('location')]",
"dependsOn": ["[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"],
"properties": {
"messageRetentionInDays": 1,
"partitionCount": 4
}
},
{
"type": "Microsoft.EventHub/namespaces/networkRuleSets",
"apiVersion": "[variables('apiVersion')]",
"name": "[concat(variables('namespaceName'), '/default')]",
"location": "[variables('location')]",
"dependsOn": ["[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"],
"properties": {
"defaultAction": "Deny",
"virtualNetworkRules": [],
"ipRules": []
}
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs/consumergroups",
"apiVersion": "[variables('apiVersion')]",
"name": "[concat(variables('eventHubNameFull'), '/$Default')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('namespaceName'), variables('eventHubName'))]",
"[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"
],
"properties": {}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "[variables('storageApiVersion')]",
"name": "[variables('storageAccountName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"enabled": true
},
"blob": {
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
},
"resources": [
{
"name": "[concat('default/', variables('containerName'))]",
"type": "blobServices/containers",
"apiVersion": "[variables('storageApiVersion')]",
"dependsOn": ["[variables('storageAccountName')]"]
}
]
},
{
"type": "Microsoft.Devices/IotHubs",
"apiVersion": "[variables('ioTapiVersion')]",
"name": "[variables('iotName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"sku": {
"name": "S1",
"tier": "Standard",
"capacity": 1
},
"properties": {
"ipFilterRules": [],
"eventHubEndpoints": {
"events": {
"retentionTimeInDays": 1,
"partitionCount": 4
}
},
"routing": {
"endpoints": {
"serviceBusQueues": [],
"serviceBusTopics": [],
"eventHubs": [],
"storageContainers": []
},
"routes": [],
"fallbackRoute": {
"name": "$fallback",
"source": "DeviceMessages",
"condition": "true",
"endpointNames": ["events"],
"isEnabled": true
}
},
"storageEndpoints": {
"$default": {
"sasTtlAsIso8601": "PT1H",
"connectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), variables('storageApiVersion')).keys[0].value, ';EndpointSuffix=', 'core.windows.net')]",
"containerName": "[variables('containerName')]"
}
},
"messagingEndpoints": {
"fileNotifications": {
"lockDurationAsIso8601": "PT1M",
"ttlAsIso8601": "PT1H",
"maxDeliveryCount": 10
}
},
"enableFileUploadNotifications": false,
"cloudToDevice": {
"maxDeliveryCount": 10,
"defaultTtlAsIso8601": "PT1H",
"feedback": {
"lockDurationAsIso8601": "PT1M",
"ttlAsIso8601": "PT1H",
"maxDeliveryCount": 10
}
},
"features": "None"
}
}
],
"outputs": {
"EVENTHUB_NAME": {
"type": "string",
"value": "[variables('eventHubName')]"
},
"EVENTHUB_CONNECTION_STRING": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.EventHub/namespaces/authorizationRules', variables('namespaceName'), 'RootManageSharedAccessKey'), variables('apiVersion')).primaryConnectionString]"
},
"IOTHUB_CONNECTION_STRING": {
"type": "string",
"value": "[concat('HostName=', reference(resourceId('Microsoft.Devices/IoTHubs', variables('iotName')), providers('Microsoft.Devices', 'IoTHubs').apiVersions[0]).hostName, ';SharedAccessKeyName=iothubowner;SharedAccessKey=', listKeys(resourceId('Microsoft.Devices/IotHubs', variables('iotName')), providers('Microsoft.Devices', 'IoTHubs').apiVersions[0]).value[0].primaryKey)]"
},
"IOTHUB_EH_COMPATIBLE_CONNECTION_STRING": {
"type": "string",
"value": "[concat('Endpoint=',reference(resourceId('Microsoft.Devices/IoTHubs', variables('iotName'))).eventHubEndpoints.events.endpoint,';SharedAccessKeyName=iothubowner;SharedAccessKey=',listKeys(resourceId('Microsoft.Devices/IotHubs',variables('iotName')),variables('iotApiVersion')).value[0].primaryKey,';EntityPath=',variables('iotName'))]"
},
"STORAGE_CONNECTION_STRING": {
"type": "string",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), variables('storageApiVersion')).keys[0].value, ';EndpointSuffix=', 'core.windows.net')]"
}
}
}