Skip to content

Commit ec04544

Browse files
authored
Add EventHub Emulation and Restructure E2E Tests (#61)
* Add EventHub emulation and comment out currently unsupported tests
1 parent 8a52678 commit ec04544

File tree

85 files changed

+1221
-1530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1221
-1530
lines changed

README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,13 @@ This repo contains end-to-end tests for Node.js on Azure Functions. These are au
1212
Here is the general flow of the pipeline:
1313

1414
1. Install node modules and build both the tests themselves and the test apps
15-
2. Create several resources in Azure that will be used for testing different bindings. A unique resource prefix is generated for each individual build so that builds aren't sharing resources
15+
2. Emulate several resources in Azure that will be used for testing different bindings
1616
3. Run the tests. A few notes:
17-
1. These are run in parallel by OS, but in serial by Node.js version and programming model version. Theoretically every combination could be run in parallel, but that would use a ton of Azure Pipelines agents and create a lot of Azure resources for minimal gain in time.
17+
1. These are run in parallel by OS, but in serial by Node.js version and programming model version. Theoretically every combination could be run in parallel, but that would use a ton of Azure Pipelines agents
1818
2. The primary method of validation is to run core tools against the test app and validate the output
19-
4. Delete the Azure resources
19+
4. Shutdown the emulated Azure resources (automatic)
2020
5. Upload test results
2121

22-
## Running locally
23-
24-
### Install core tools
25-
26-
1. Run `./scripts/install-func-cli.ps1` in PowerShell to install the latest nightly build of Azure Functions Core Tools
27-
28-
### Build
29-
30-
1. Run `npm run install` and `npm run build` in the root directory, and in the test app folders (`app/v3` and `app/v4`)
31-
32-
### Create resources
33-
34-
You need to create resources once in your subscription, but then you can reuse the same resources for many different test runs. The CI pipeline will create and delete resources each time, but you don't need to do that.
35-
36-
1. Set the environment variable `BUILD_BUILDNUMBER` to any number like `20230520.1`. You want it to be reasonably unique because this will be used as a prefix for your Azure resources.
37-
2. Run `az login` and `az account set -s <subscription id>` if you're not already logged in to the [Azure CLI](https://learn.microsoft.com/cli/azure/get-started-with-azure-cli). The tests will use these credentials.
38-
3. Run `npm run createResources`
39-
4. Validate the resources were created. You should see a resource group in your subscription like `e2edarwin202305201group` with several resources
40-
41-
### Run tests
42-
43-
1. Run `npm run testV3` to test the v3 app, `npm run testV4` to test the v4 app, or `npm run test` to test both
44-
4522
## Code of Conduct
4623

4724
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

app/v3/cosmosDBTrigger/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the MIT License.
1+
// // Copyright (c) .NET Foundation. All rights reserved.
2+
// // Licensed under the MIT License.
33

4-
import { AzureFunction, Context } from '@azure/functions';
4+
// import { AzureFunction, Context } from '@azure/functions';
55

6-
const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<void> {
7-
context.log(`cosmosDBTrigger processed ${documents.length} documents`);
8-
for (const document of documents) {
9-
context.log(`cosmosDBTrigger was triggered by "${document.testData}"`);
10-
}
11-
};
6+
// const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<void> {
7+
// context.log(`cosmosDBTrigger processed ${documents.length} documents`);
8+
// for (const document of documents) {
9+
// context.log(`cosmosDBTrigger was triggered by "${document.testData}"`);
10+
// }
11+
// };
1212

13-
export default cosmosDBTrigger;
13+
// export default cosmosDBTrigger;
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the MIT License.
1+
// // Copyright (c) .NET Foundation. All rights reserved.
2+
// // Licensed under the MIT License.
33

4-
import { AzureFunction, Context } from '@azure/functions';
4+
// import { AzureFunction, Context } from '@azure/functions';
55

6-
const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<any[]> {
7-
context.log(`cosmosDBTriggerAndOutput processed ${documents.length} documents`);
8-
for (const document of documents) {
9-
context.log(`cosmosDBTriggerAndOutput was triggered by "${document.testData}"`);
10-
}
11-
return documents;
12-
};
6+
// const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<any[]> {
7+
// context.log(`cosmosDBTriggerAndOutput processed ${documents.length} documents`);
8+
// for (const document of documents) {
9+
// context.log(`cosmosDBTriggerAndOutput was triggered by "${document.testData}"`);
10+
// }
11+
// return documents;
12+
// };
1313

14-
export default cosmosDBTrigger;
14+
// export default cosmosDBTrigger;

app/v3/eventHubManyTrigger/function.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"type": "eventHubTrigger",
55
"name": "eventHubMessages",
66
"direction": "in",
7-
"eventHubName": "e2eTestHubManyTrigger",
8-
"connection": "e2eTest_eventHub",
7+
"eventHubName": "e2e-test-hub-many-trigger",
8+
"connection": "EventHubConnection",
99
"cardinality": "many"
1010
}
1111
],

app/v3/eventHubManyTriggerAndOutput/function.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"type": "eventHubTrigger",
55
"name": "eventHubMessages",
66
"direction": "in",
7-
"eventHubName": "e2eTestHubManyTriggerAndOutput",
8-
"connection": "e2eTest_eventHub",
7+
"eventHubName": "e2e-test-hub-many-trigger-and-output",
8+
"connection": "EventHubConnection",
99
"cardinality": "many"
1010
},
1111
{
1212
"type": "eventHub",
1313
"name": "$return",
1414
"direction": "out",
15-
"eventHubName": "e2eTestHubManyTrigger",
16-
"connection": "e2eTest_eventHub"
15+
"eventHubName": "e2e-test-hub-many-trigger",
16+
"connection": "EventHubConnection"
1717
}
1818
],
1919
"scriptFile": "../dist/eventHubManyTriggerAndOutput/index.js"

app/v3/eventHubOneTrigger/function.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"type": "eventHubTrigger",
55
"name": "eventHubMessages",
66
"direction": "in",
7-
"eventHubName": "e2eTestHubOneTrigger",
8-
"connection": "e2eTest_eventHub",
7+
"eventHubName": "e2e-test-hub-one-trigger",
8+
"connection": "EventHubConnection",
99
"cardinality": "one"
1010
}
1111
],

app/v3/eventHubOneTriggerAndOutput/function.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"type": "eventHubTrigger",
55
"name": "eventHubMessages",
66
"direction": "in",
7-
"eventHubName": "e2eTestHubOneTriggerAndOutput",
8-
"connection": "e2eTest_eventHub",
7+
"eventHubName": "e2e-test-hub-one-trigger-and-output",
8+
"connection": "EventHubConnection",
99
"cardinality": "one"
1010
},
1111
{
1212
"type": "eventHub",
1313
"name": "$return",
1414
"direction": "out",
15-
"eventHubName": "e2eTestHubOneTrigger",
16-
"connection": "e2eTest_eventHub"
15+
"eventHubName": "e2e-test-hub-one-trigger",
16+
"connection": "EventHubConnection"
1717
}
1818
],
1919
"scriptFile": "../dist/eventHubOneTriggerAndOutput/index.js"
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the MIT License.
1+
// // Copyright (c) .NET Foundation. All rights reserved.
2+
// // Licensed under the MIT License.
33

4-
import { AzureFunction, Context, HttpRequest } from '@azure/functions';
4+
// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
55

6-
const httpTriggerCosmosDBInput: AzureFunction = async function (
7-
context: Context,
8-
_request: HttpRequest
9-
): Promise<void> {
10-
context.res = {
11-
body: context.bindings.inputDoc.testData,
12-
};
13-
};
6+
// const httpTriggerCosmosDBInput: AzureFunction = async function (
7+
// context: Context,
8+
// _request: HttpRequest
9+
// ): Promise<void> {
10+
// context.res = {
11+
// body: context.bindings.inputDoc.testData,
12+
// };
13+
// };
1414

15-
export default httpTriggerCosmosDBInput;
15+
// export default httpTriggerCosmosDBInput;
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the MIT License.
1+
// // Copyright (c) .NET Foundation. All rights reserved.
2+
// // Licensed under the MIT License.
33

4-
import { AzureFunction, Context, HttpRequest } from '@azure/functions';
4+
// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
55

6-
const httpTriggerCosmosDBOutput: AzureFunction = async function (
7-
context: Context,
8-
request: HttpRequest
9-
): Promise<void> {
10-
context.bindings.outputDoc = request.body;
11-
context.res = { body: 'done' };
12-
};
6+
// const httpTriggerCosmosDBOutput: AzureFunction = async function (
7+
// context: Context,
8+
// request: HttpRequest
9+
// ): Promise<void> {
10+
// context.bindings.outputDoc = request.body;
11+
// context.res = { body: 'done' };
12+
// };
1313

14-
export default httpTriggerCosmosDBOutput;
14+
// export default httpTriggerCosmosDBOutput;
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the MIT License.
1+
// // Copyright (c) .NET Foundation. All rights reserved.
2+
// // Licensed under the MIT License.
33

4-
import { AzureFunction, Context, HttpRequest } from '@azure/functions';
4+
// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
55

6-
const httpTriggerServiceBusOutput: AzureFunction = async function (
7-
context: Context,
8-
request: HttpRequest
9-
): Promise<void> {
10-
context.bindings.outputMsg = request.body.output;
11-
context.res = { body: 'done' };
12-
};
6+
// const httpTriggerServiceBusOutput: AzureFunction = async function (
7+
// context: Context,
8+
// request: HttpRequest
9+
// ): Promise<void> {
10+
// context.bindings.outputMsg = request.body.output;
11+
// context.res = { body: 'done' };
12+
// };
1313

14-
export default httpTriggerServiceBusOutput;
14+
// export default httpTriggerServiceBusOutput;

0 commit comments

Comments
 (0)