Skip to content

Commit 2db0d13

Browse files
committed
test: test Event Grid functions locally
1 parent 7b6776e commit 2db0d13

18 files changed

Lines changed: 249 additions & 319 deletions

File tree

‎eng/templates/official/jobs/ci-core-tools-tests.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,4 @@ jobs:
3737
AzureWebJobsEventHubConnectionString: $(LinuxEventHubConnectionString311)
3838
AzureWebJobsServiceBusConnectionString: $(LinuxServiceBusConnectionString311)
3939
AzureWebJobsSqlConnectionString: $(LinuxSqlConnectionString311)
40-
AzureWebJobsEventGridTopicUri: $(LinuxEventGridTopicUriString311)
41-
AzureWebJobsEventGridConnectionKey: $(LinuxEventGridConnectionKeyString311)
4240
displayName: 'Running Python Language Worker E2E Tests'

‎eng/templates/official/jobs/ci-custom-image-tests.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,5 @@ jobs:
3636
AzureWebJobsEventHubConnectionString: $(LinuxEventHubConnectionString311)
3737
AzureWebJobsServiceBusConnectionString: $(LinuxServiceBusConnectionString311)
3838
AzureWebJobsSqlConnectionString: $(LinuxSqlConnectionString311)
39-
AzureWebJobsEventGridTopicUri: $(LinuxEventGridTopicUriString311)
40-
AzureWebJobsEventGridConnectionKey: $(LinuxEventGridConnectionKeyString311)
4139
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
4240
displayName: "Running Python DockerCustom tests"

‎eng/templates/official/jobs/ci-docker-dedicated-tests.yml‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ jobs:
1616
PYTHON_VERSION: '3.10'
1717
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
1818
SQL_CONNECTION: $(LinuxSqlConnectionString310)
19-
EVENTGRID_URI: $(LinuxEventGridTopicUriString310)
20-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString310)
2119
Python311:
2220
PYTHON_VERSION: '3.11'
2321
STORAGE_CONNECTION: $(LinuxStorageConnectionString311)
2422
SQL_CONNECTION: $(LinuxSqlConnectionString311)
25-
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
26-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
2723
Python312:
2824
PYTHON_VERSION: '3.12'
2925
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
3026
SQL_CONNECTION: $(LinuxSqlConnectionString312)
31-
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
32-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)
3327

3428
steps:
3529
- task: PipAuthenticate@1
@@ -54,7 +48,5 @@ jobs:
5448
AzureWebJobsStorage: $(STORAGE_CONNECTION)
5549
STORAGE_CONNECTION: $(STORAGE_CONNECTION)
5650
AzureWebJobsSqlConnectionString: $(SQL_CONNECTION)
57-
AzureWebJobsEventGridTopicUri: $(EVENTGRID_URI)
58-
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)
5951
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
6052
displayName: "Running $(PYTHON_VERSION) Docker Dedicated tests"

‎eng/templates/official/jobs/ci-e2e-tests.yml‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,22 @@ jobs:
1717
PYTHON_VERSION: '3.10'
1818
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
1919
SQL_CONNECTION: $(LinuxSqlConnectionString310)
20-
EVENTGRID_URI: $(LinuxEventGridTopicUriString310)
21-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString310)
2220
Python311:
2321
PYTHON_VERSION: '3.11'
2422
STORAGE_CONNECTION: $(LinuxStorageConnectionString311)
2523
SQL_CONNECTION: $(LinuxSqlConnectionString311)
26-
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
27-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
2824
Python312:
2925
PYTHON_VERSION: '3.12'
3026
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
3127
SQL_CONNECTION: $(LinuxSqlConnectionString312)
32-
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
33-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)
3428
Python313:
3529
PYTHON_VERSION: '3.13'
3630
STORAGE_CONNECTION: $(LinuxStorageConnectionString37)
3731
SQL_CONNECTION: $(LinuxSqlConnectionString37)
38-
EVENTGRID_URI: $(LinuxEventGridTopicUriString37)
39-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString37)
4032
Python314:
4133
PYTHON_VERSION: '3.14'
4234
STORAGE_CONNECTION: $(LinuxStorageConnectionString38)
4335
SQL_CONNECTION: $(LinuxSqlConnectionString38)
44-
EVENTGRID_URI: $(LinuxEventGridTopicUriString38)
45-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString38)
4636
steps:
4737
- task: PipAuthenticate@1
4838
displayName: 'Authenticate pip to CFS'
@@ -162,8 +152,6 @@ jobs:
162152
AzureWebJobsStorage: $(STORAGE_CONNECTION)
163153
STORAGE_CONNECTION: $(STORAGE_CONNECTION)
164154
AzureWebJobsSqlConnectionString: $(SQL_CONNECTION)
165-
AzureWebJobsEventGridTopicUri: $(EVENTGRID_URI)
166-
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)
167155
skipTest: $(skipTest)
168156
PYAZURE_WEBHOST_DEBUG: true
169157
displayName: "Running $(PYTHON_VERSION) Python E2E Tests"

workers/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/function_app.py renamed to workers/tests/emulator_tests/eventgrid_functions/eventgrid_functions_stein/function_app.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import json
2+
import logging
23
from datetime import datetime
34

45
import azure.functions as func
56

6-
from azure_functions_worker import logging
7-
87
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
98

109

11-
@app.function_name(name="eventGridTrigger")
10+
@app.function_name(name="eventgrid_trigger")
1211
@app.event_grid_trigger(arg_name="event")
1312
@app.blob_output(arg_name="$return",
1413
path="python-worker-tests/test-eventgrid-triggered.txt",
15-
connection="STORAGE_CONNECTION")
14+
connection="AzureWebJobsStorage")
1615
def event_grid_trigger(event: func.EventGridEvent) -> str:
1716
logging.info("Event grid function is triggered!")
1817
return json.dumps({
@@ -52,32 +51,11 @@ def eventgrid_output_binding(
5251
return func.HttpResponse(r_value)
5352

5453

55-
@app.function_name(name="eventgrid_output_binding_message_to_blobstore")
56-
@app.queue_trigger(arg_name="msg", queue_name="test-event-grid-storage-queue",
57-
connection="STORAGE_CONNECTION")
58-
@app.blob_output(arg_name="$return",
59-
path="python-worker-tests/test-eventgrid-output-binding.txt",
60-
connection="STORAGE_CONNECTION")
61-
def eventgrid_output_binding_message_to_blobstore(
62-
msg: func.QueueMessage) -> bytes:
63-
return msg.get_body()
64-
65-
66-
@app.function_name(name="eventgrid_output_binding_success")
67-
@app.route(route="eventgrid_output_binding_success")
68-
@app.blob_input(arg_name="file",
69-
path="python-worker-tests/test-eventgrid-output-binding.txt",
70-
connection="STORAGE_CONNECTION")
71-
def eventgrid_output_binding_success(
72-
req: func.HttpRequest, file: func.InputStream) -> str:
73-
return file.read().decode('utf-8')
74-
75-
7654
@app.function_name(name="get_eventgrid_triggered")
7755
@app.route(route="get_eventgrid_triggered")
7856
@app.blob_input(arg_name="file",
7957
path="python-worker-tests/test-eventgrid-triggered.txt",
80-
connection="STORAGE_CONNECTION")
58+
connection="AzureWebJobsStorage")
8159
def get_eventgrid_triggered(
8260
req: func.HttpRequest, file: func.InputStream) -> str:
8361
return file.read().decode('utf-8')

workers/tests/endtoend/eventgrid_functions/eventgrid_functions_stein/generic/function_app.py renamed to workers/tests/emulator_tests/eventgrid_functions/eventgrid_functions_stein/generic/function_app.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import json
2+
import logging
23
from datetime import datetime
34

45
import azure.functions as func
56

6-
from azure_functions_worker import logging
7-
87
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
98

109

11-
@app.function_name(name="eventGridTrigger")
10+
@app.function_name(name="eventgrid_trigger")
1211
@app.event_grid_trigger(arg_name="event", type="eventGridTrigger")
1312
@app.generic_output_binding(
1413
arg_name="$return",
1514
type="blob",
16-
connection="STORAGE_CONNECTION",
15+
connection="AzureWebJobsStorage",
1716
path="python-worker-tests/test-eventgrid-triggered.txt")
1817
def event_grid_trigger(event: func.EventGridEvent) -> str:
1918
logging.info("Event grid function is triggered!")
@@ -57,35 +56,6 @@ def eventgrid_output_binding(
5756
return func.HttpResponse(r_value)
5857

5958

60-
@app.function_name(name="eventgrid_output_binding_message_to_blobstore")
61-
@app.generic_trigger(arg_name="msg",
62-
type="queueTrigger",
63-
queue_name="test-event-grid-storage-queue",
64-
connection="STORAGE_CONNECTION")
65-
@app.generic_output_binding(
66-
arg_name="$return",
67-
type="blob",
68-
connection="STORAGE_CONNECTION",
69-
path="python-worker-tests/test-eventgrid-output-binding.txt")
70-
def eventgrid_output_binding_message_to_blobstore(
71-
msg: func.QueueMessage) -> bytes:
72-
return msg.get_body()
73-
74-
75-
@app.function_name(name="eventgrid_output_binding_success")
76-
@app.generic_trigger(arg_name="req", type="httpTrigger",
77-
route="eventgrid_output_binding_success")
78-
@app.generic_output_binding(arg_name="$return", type="http")
79-
@app.generic_input_binding(
80-
arg_name="file",
81-
type="blob",
82-
path="python-worker-tests/test-eventgrid-output-binding.txt",
83-
connection="STORAGE_CONNECTION")
84-
def eventgrid_output_binding_success(
85-
req: func.HttpRequest, file: func.InputStream) -> str:
86-
return file.read().decode('utf-8')
87-
88-
8959
@app.function_name(name="get_eventgrid_triggered")
9060
@app.generic_trigger(arg_name="req", type="httpTrigger",
9161
route="get_eventgrid_triggered")
@@ -94,7 +64,7 @@ def eventgrid_output_binding_success(
9464
arg_name="file",
9565
type="blob",
9666
path="python-worker-tests/test-eventgrid-triggered.txt",
97-
connection="STORAGE_CONNECTION")
67+
connection="AzureWebJobsStorage")
9868
def get_eventgrid_triggered(
9969
req: func.HttpRequest, file: func.InputStream) -> str:
10070
return file.read().decode('utf-8')

workers/tests/endtoend/eventgrid_functions/eventgrid_output_binding/__init__.py renamed to workers/tests/emulator_tests/eventgrid_functions/eventgrid_output_binding/__init__.py

File renamed without changes.

workers/tests/endtoend/eventgrid_functions/eventgrid_output_binding/function.json renamed to workers/tests/emulator_tests/eventgrid_functions/eventgrid_output_binding/function.json

File renamed without changes.

workers/tests/endtoend/eventgrid_functions/eventgrid_trigger/__init__.py renamed to workers/tests/emulator_tests/eventgrid_functions/eventgrid_trigger/__init__.py

File renamed without changes.

workers/tests/endtoend/eventgrid_functions/eventgrid_trigger/function.json renamed to workers/tests/emulator_tests/eventgrid_functions/eventgrid_trigger/function.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "blob",
1212
"direction": "out",
1313
"name": "$return",
14-
"connection": "STORAGE_CONNECTION",
14+
"connection": "AzureWebJobsStorage",
1515
"path": "python-worker-tests/test-eventgrid-triggered.txt"
1616
}
1717
]

0 commit comments

Comments
 (0)