Skip to content

Commit 0a80f54

Browse files
authored
test: add ServiceBus SDK tests (#1678)
* Add servicebus sdk worker tests * Add as part of current sb tests * remove old file * renaming * fixes + refactor blob sdk to emulator * directory fix * directory fix * rename sb directory * move emulator connection strings to variable groups * same for unit tests * add sb topic tests * Revert me later * Add snake case tests + remove topic test + single sb batch test * dir fix * fix tests * remove testqueue-batch + debugging e2e * remove debug log * fix eg connection reference * move emulator var group to separate file * off * lint * remove batch * merge fixes * fix test dir * fix test dir pt 2 * fix miss * remove v1 tests * fix tests * lint
1 parent 47fa7ab commit 0a80f54

File tree

21 files changed

+405
-156
lines changed

21 files changed

+405
-156
lines changed

.github/ISSUE_TEMPLATE/deferred_bindings_bug_report.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/deferred_bindings_feature_request.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

eng/ci/emulator-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ variables:
3434
- template: /ci/variables/build.yml@eng
3535
- template: /ci/variables/cfs.yml@eng
3636
- template: /eng/templates/utils/variables.yml@self
37+
- template: /eng/templates/utils/emulator-variables.yml@self
3738

3839
extends:
3940
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/ci/public-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ resources:
2828

2929
variables:
3030
- template: /eng/templates/utils/variables.yml@self
31+
- template: /eng/templates/utils/emulator-variables.yml@self
3132

3233
extends:
3334
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/templates/jobs/ci-emulator-tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ jobs:
9090
- bash: |
9191
python -m pytest -q --dist loadfile --reruns 4 --ignore=tests/emulator_tests/test_servicebus_functions.py tests/emulator_tests
9292
env:
93-
AzureWebJobsStorage: "UseDevelopmentStorage=true"
93+
AzureWebJobsStorage: $(AzureWebJobsStorage)
94+
AZURE_STORAGE_CONNECTION_STRING: $(AZURE_STORAGE_CONNECTION_STRING)
9495
AzureWebJobsEventHubConnectionString: $(EmulatorEventHubConnectionString)
9596
AzureWebJobsCosmosDBConnectionString: $(EmulatorCosmosDBConnectionString)
9697
CosmosDBEmulatorUrl: $(CosmosDBEmulatorUrl)
@@ -109,7 +110,8 @@ jobs:
109110
- bash: |
110111
python -m pytest -q --dist loadfile --reruns 4 tests/emulator_tests/test_servicebus_functions.py
111112
env:
112-
AzureWebJobsStorage: "UseDevelopmentStorage=true"
113+
AzureWebJobsStorage: $(AzureWebJobsStorage)
113114
AzureWebJobsServiceBusConnectionString: $(EmulatorServiceBusConnectionString)
115+
AzureWebJobsServiceBusSDKConnectionString: $(AzureWebJobsServiceBusSDKConnectionString)
114116
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
115117
displayName: "Running $(PYTHON_VERSION) Python ServiceBus Linux Emulator Tests"

eng/templates/jobs/ci-unit-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@ jobs:
6363
condition: and(eq(variables.isSdkRelease, false), eq(variables.isExtensionsRelease, false), eq(variables['USETESTPYTHONSDK'], false), eq(variables['USETESTPYTHONEXTENSIONS'], false))
6464
env:
6565
PYTHON_VERSION: $(PYTHON_VERSION)
66+
AZURE_STORAGE_CONNECTION_STRING: $(AZURE_STORAGE_CONNECTION_STRING)
6667
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
6768

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
Write-Host "skipTest: $(skipTest)"
154154
displayName: 'Display skipTest variable'
155155
- bash: |
156-
python -m pytest -q --dist loadfile --reruns 4 --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend tests/extension_tests/deferred_bindings_tests tests/extension_tests/http_v2_tests
156+
python -m pytest -q --dist loadfile --reruns 4 --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
157157
env:
158158
AzureWebJobsStorage: $(STORAGE_CONNECTION)
159159
AzureWebJobsCosmosDBConnectionString: $(COSMOSDB_CONNECTION)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
variables:
2+
- group: python-emulator-resources

workers/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ dev = [
8282
"pre-commit",
8383
"invoke",
8484
"cryptography",
85+
"jsonpickle",
8586
"orjson"
8687
]
8788
test-http-v2 = [
@@ -90,7 +91,8 @@ test-http-v2 = [
9091
]
9192
test-deferred-bindings = [
9293
"azurefunctions-extensions-bindings-blob==1.1.1",
93-
"azurefunctions-extensions-bindings-eventhub==1.0.0b1"
94+
"azurefunctions-extensions-bindings-eventhub==1.0.0b1",
95+
"azurefunctions-extensions-bindings-servicebus==1.0.0b1"
9496
]
9597

9698
[build-system]

workers/tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py renamed to workers/tests/emulator_tests/blob_functions/blob_functions_sdk/function_app.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@app.function_name(name="put_bc_trigger")
1212
@app.blob_output(arg_name="file",
1313
path="python-worker-tests/test-blobclient-trigger.txt",
14-
connection="AzureWebJobsStorage")
14+
connection="AZURE_STORAGE_CONNECTION_STRING")
1515
@app.route(route="put_bc_trigger")
1616
def put_bc_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
1717
file.set(req.get_body())
@@ -21,10 +21,10 @@ def put_bc_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
2121
@app.function_name(name="bc_blob_trigger")
2222
@app.blob_trigger(arg_name="client",
2323
path="python-worker-tests/test-blobclient-trigger.txt",
24-
connection="AzureWebJobsStorage")
24+
connection="AZURE_STORAGE_CONNECTION_STRING")
2525
@app.blob_output(arg_name="$return",
2626
path="python-worker-tests/test-blobclient-triggered.txt",
27-
connection="AzureWebJobsStorage")
27+
connection="AZURE_STORAGE_CONNECTION_STRING")
2828
def bc_blob_trigger(client: blob.BlobClient) -> str:
2929
blob_properties = client.get_blob_properties()
3030
file = client.download_blob(encoding='utf-8').readall()
@@ -38,7 +38,7 @@ def bc_blob_trigger(client: blob.BlobClient) -> str:
3838
@app.function_name(name="get_bc_blob_triggered")
3939
@app.blob_input(arg_name="client",
4040
path="python-worker-tests/test-blobclient-triggered.txt",
41-
connection="AzureWebJobsStorage")
41+
connection="AZURE_STORAGE_CONNECTION_STRING")
4242
@app.route(route="get_bc_blob_triggered")
4343
def get_bc_blob_triggered(req: func.HttpRequest,
4444
client: blob.BlobClient) -> str:
@@ -48,7 +48,7 @@ def get_bc_blob_triggered(req: func.HttpRequest,
4848
@app.function_name(name="put_cc_trigger")
4949
@app.blob_output(arg_name="file",
5050
path="python-worker-tests/test-containerclient-trigger.txt",
51-
connection="AzureWebJobsStorage")
51+
connection="AZURE_STORAGE_CONNECTION_STRING")
5252
@app.route(route="put_cc_trigger")
5353
def put_cc_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
5454
file.set(req.get_body())
@@ -58,10 +58,10 @@ def put_cc_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
5858
@app.function_name(name="cc_blob_trigger")
5959
@app.blob_trigger(arg_name="client",
6060
path="python-worker-tests/test-containerclient-trigger.txt",
61-
connection="AzureWebJobsStorage")
61+
connection="AZURE_STORAGE_CONNECTION_STRING")
6262
@app.blob_output(arg_name="$return",
6363
path="python-worker-tests/test-containerclient-triggered.txt",
64-
connection="AzureWebJobsStorage")
64+
connection="AZURE_STORAGE_CONNECTION_STRING")
6565
def cc_blob_trigger(client: blob.ContainerClient) -> str:
6666
container_properties = client.get_container_properties()
6767
file = client.download_blob("test-containerclient-trigger.txt",
@@ -75,7 +75,7 @@ def cc_blob_trigger(client: blob.ContainerClient) -> str:
7575
@app.function_name(name="get_cc_blob_triggered")
7676
@app.blob_input(arg_name="client",
7777
path="python-worker-tests/test-containerclient-triggered.txt",
78-
connection="AzureWebJobsStorage")
78+
connection="AZURE_STORAGE_CONNECTION_STRING")
7979
@app.route(route="get_cc_blob_triggered")
8080
def get_cc_blob_triggered(req: func.HttpRequest,
8181
client: blob.ContainerClient) -> str:
@@ -86,7 +86,7 @@ def get_cc_blob_triggered(req: func.HttpRequest,
8686
@app.function_name(name="put_ssd_trigger")
8787
@app.blob_output(arg_name="file",
8888
path="python-worker-tests/test-ssd-trigger.txt",
89-
connection="AzureWebJobsStorage")
89+
connection="AZURE_STORAGE_CONNECTION_STRING")
9090
@app.route(route="put_ssd_trigger")
9191
def put_ssd_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
9292
file.set(req.get_body())
@@ -96,10 +96,10 @@ def put_ssd_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
9696
@app.function_name(name="ssd_blob_trigger")
9797
@app.blob_trigger(arg_name="stream",
9898
path="python-worker-tests/test-ssd-trigger.txt",
99-
connection="AzureWebJobsStorage")
99+
connection="AZURE_STORAGE_CONNECTION_STRING")
100100
@app.blob_output(arg_name="$return",
101101
path="python-worker-tests/test-ssd-triggered.txt",
102-
connection="AzureWebJobsStorage")
102+
connection="AZURE_STORAGE_CONNECTION_STRING")
103103
def ssd_blob_trigger(stream: blob.StorageStreamDownloader) -> str:
104104
# testing chunking
105105
file = ""
@@ -113,7 +113,7 @@ def ssd_blob_trigger(stream: blob.StorageStreamDownloader) -> str:
113113
@app.function_name(name="get_ssd_blob_triggered")
114114
@app.blob_input(arg_name="stream",
115115
path="python-worker-tests/test-ssd-triggered.txt",
116-
connection="AzureWebJobsStorage")
116+
connection="AZURE_STORAGE_CONNECTION_STRING")
117117
@app.route(route="get_ssd_blob_triggered")
118118
def get_ssd_blob_triggered(req: func.HttpRequest,
119119
stream: blob.StorageStreamDownloader) -> str:
@@ -124,7 +124,7 @@ def get_ssd_blob_triggered(req: func.HttpRequest,
124124
@app.route(route="get_bc_bytes")
125125
@app.blob_input(arg_name="client",
126126
path="python-worker-tests/test-blob-extension-bytes.txt",
127-
connection="AzureWebJobsStorage")
127+
connection="AZURE_STORAGE_CONNECTION_STRING")
128128
def get_bc_bytes(req: func.HttpRequest, client: blob.BlobClient) -> str:
129129
return client.download_blob(encoding='utf-8').readall()
130130

@@ -133,7 +133,7 @@ def get_bc_bytes(req: func.HttpRequest, client: blob.BlobClient) -> str:
133133
@app.route(route="get_cc_bytes")
134134
@app.blob_input(arg_name="client",
135135
path="python-worker-tests/test-blob-extension-bytes.txt",
136-
connection="AzureWebJobsStorage")
136+
connection="AZURE_STORAGE_CONNECTION_STRING")
137137
def get_cc_bytes(req: func.HttpRequest,
138138
client: blob.ContainerClient) -> str:
139139
return client.download_blob("test-blob-extension-bytes.txt",
@@ -144,7 +144,7 @@ def get_cc_bytes(req: func.HttpRequest,
144144
@app.route(route="get_ssd_bytes")
145145
@app.blob_input(arg_name="stream",
146146
path="python-worker-tests/test-blob-extension-bytes.txt",
147-
connection="AzureWebJobsStorage")
147+
connection="AZURE_STORAGE_CONNECTION_STRING")
148148
def get_ssd_bytes(req: func.HttpRequest,
149149
stream: blob.StorageStreamDownloader) -> str:
150150
return stream.readall().decode('utf-8')
@@ -154,7 +154,7 @@ def get_ssd_bytes(req: func.HttpRequest,
154154
@app.route(route="get_bc_str")
155155
@app.blob_input(arg_name="client",
156156
path="python-worker-tests/test-blob-extension-str.txt",
157-
connection="AzureWebJobsStorage")
157+
connection="AZURE_STORAGE_CONNECTION_STRING")
158158
def get_bc_str(req: func.HttpRequest, client: blob.BlobClient) -> str:
159159
return client.download_blob(encoding='utf-8').readall()
160160

@@ -163,7 +163,7 @@ def get_bc_str(req: func.HttpRequest, client: blob.BlobClient) -> str:
163163
@app.route(route="get_cc_str")
164164
@app.blob_input(arg_name="client",
165165
path="python-worker-tests",
166-
connection="AzureWebJobsStorage")
166+
connection="AZURE_STORAGE_CONNECTION_STRING")
167167
def get_cc_str(req: func.HttpRequest, client: blob.ContainerClient) -> str:
168168
return client.download_blob("test-blob-extension-str.txt",
169169
encoding='utf-8').readall()
@@ -173,7 +173,7 @@ def get_cc_str(req: func.HttpRequest, client: blob.ContainerClient) -> str:
173173
@app.route(route="get_ssd_str")
174174
@app.blob_input(arg_name="stream",
175175
path="python-worker-tests/test-blob-extension-str.txt",
176-
connection="AzureWebJobsStorage")
176+
connection="AZURE_STORAGE_CONNECTION_STRING")
177177
def get_ssd_str(req: func.HttpRequest, stream: blob.StorageStreamDownloader) -> str:
178178
return stream.readall().decode('utf-8')
179179

@@ -183,11 +183,11 @@ def get_ssd_str(req: func.HttpRequest, stream: blob.StorageStreamDownloader) ->
183183
@app.blob_input(arg_name="client",
184184
path="python-worker-tests/test-blob-extension-str.txt",
185185
data_type="STRING",
186-
connection="AzureWebJobsStorage")
186+
connection="AZURE_STORAGE_CONNECTION_STRING")
187187
@app.blob_input(arg_name="blob",
188188
path="python-worker-tests/test-blob-extension-str.txt",
189189
data_type="STRING",
190-
connection="AzureWebJobsStorage")
190+
connection="AZURE_STORAGE_CONNECTION_STRING")
191191
def bc_and_inputstream_input(req: func.HttpRequest, client: blob.BlobClient,
192192
blob: func.InputStream) -> str:
193193
output_msg = ""
@@ -202,11 +202,11 @@ def bc_and_inputstream_input(req: func.HttpRequest, client: blob.BlobClient,
202202
@app.blob_input(arg_name="blob",
203203
path="python-worker-tests/test-blob-extension-str.txt",
204204
data_type="STRING",
205-
connection="AzureWebJobsStorage")
205+
connection="AZURE_STORAGE_CONNECTION_STRING")
206206
@app.blob_input(arg_name="client",
207207
path="python-worker-tests/test-blob-extension-str.txt",
208208
data_type="STRING",
209-
connection="AzureWebJobsStorage")
209+
connection="AZURE_STORAGE_CONNECTION_STRING")
210210
def inputstream_and_bc_input(req: func.HttpRequest, blob: func.InputStream,
211211
client: blob.BlobClient) -> str:
212212
output_msg = ""
@@ -221,7 +221,7 @@ def inputstream_and_bc_input(req: func.HttpRequest, blob: func.InputStream,
221221
@app.blob_input(arg_name="file",
222222
path="python-worker-tests/test-blob-extension-str.txt",
223223
data_type="STRING",
224-
connection="AzureWebJobsStorage")
224+
connection="AZURE_STORAGE_CONNECTION_STRING")
225225
def type_undefined(req: func.HttpRequest, file) -> str:
226226
assert not isinstance(file, blob.BlobClient)
227227
assert not isinstance(file, blob.ContainerClient)
@@ -232,7 +232,7 @@ def type_undefined(req: func.HttpRequest, file) -> str:
232232
@app.function_name(name="put_blob_str")
233233
@app.blob_output(arg_name="file",
234234
path="python-worker-tests/test-blob-extension-str.txt",
235-
connection="AzureWebJobsStorage")
235+
connection="AZURE_STORAGE_CONNECTION_STRING")
236236
@app.route(route="put_blob_str")
237237
def put_blob_str(req: func.HttpRequest, file: func.Out[str]) -> str:
238238
file.set(req.get_body())
@@ -242,7 +242,7 @@ def put_blob_str(req: func.HttpRequest, file: func.Out[str]) -> str:
242242
@app.function_name(name="put_blob_bytes")
243243
@app.blob_output(arg_name="file",
244244
path="python-worker-tests/test-blob-extension-bytes.txt",
245-
connection="AzureWebJobsStorage")
245+
connection="AZURE_STORAGE_CONNECTION_STRING")
246246
@app.route(route="put_blob_bytes")
247247
def put_blob_bytes(req: func.HttpRequest, file: func.Out[bytes]) -> str:
248248
file.set(req.get_body())

0 commit comments

Comments
 (0)