Skip to content

Commit 2f8f424

Browse files
hallvictoriaVictoria Hall
and
Victoria Hall
authored
fix: unique function names (#1557)
* initial test fixes * del function_app * refactor variables into separate file e2e & unit tests * refactor variables for all pipelines * typo * absolute paths * run all db tests * typo --------- Co-authored-by: Victoria Hall <[email protected]>
1 parent 296e3c6 commit 2f8f424

16 files changed

+122
-183
lines changed

eng/ci/core-tools-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ resources:
1010
ref: refs/tags/release
1111

1212
variables:
13-
- template: /ci/variables/build.yml@eng
14-
- template: /ci/variables/cfs.yml@eng
15-
- group: python-integration-resources
13+
- template: /eng/templates/utils/official-variables.yml@self
14+
1615
extends:
1716
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
1817
parameters:

eng/ci/custom-image-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ resources:
1010
ref: refs/tags/release
1111

1212
variables:
13-
- template: /ci/variables/build.yml@eng
14-
- template: /ci/variables/cfs.yml@eng
15-
- group: python-integration-resources
13+
- template: /eng/templates/utils/official-variables.yml@self
1614

1715
extends:
1816
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/ci/docker-consumption-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ resources:
2121
ref: refs/tags/release
2222

2323
variables:
24-
- template: /ci/variables/build.yml@eng
25-
- template: /ci/variables/cfs.yml@eng
26-
- group: python-integration-resources
24+
- template: /eng/templates/utils/official-variables.yml@self
2725

2826
extends:
2927
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/ci/docker-dedicated-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ resources:
2121
ref: refs/tags/release
2222

2323
variables:
24-
- template: /ci/variables/build.yml@eng
25-
- template: /ci/variables/cfs.yml@eng
26-
- group: python-integration-resources
24+
- template: /eng/templates/utils/official-variables.yml@self
2725

2826
extends:
2927
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/ci/integration-tests.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ resources:
3131
ref: refs/tags/release
3232

3333
variables:
34-
- template: /ci/variables/build.yml@eng
35-
- template: /ci/variables/cfs.yml@eng
36-
- group: python-integration-resources
37-
- name: isSdkRelease
38-
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/sdk/')]
39-
- name: isExtensionsRelease
40-
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/extensions/')]
34+
- template: /eng/templates/utils/variables.yml@self
35+
- template: /eng/templates/utils/official-variables.yml@self
4136

4237
extends:
4338
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/ci/official-build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ resources:
2828
ref: refs/tags/release
2929

3030
variables:
31-
- template: /ci/variables/build.yml@eng
32-
- template: /ci/variables/cfs.yml@eng
33-
- group: python-integration-resources
31+
- template: /eng/templates/utils/variables.yml@self
32+
- template: /eng/templates/utils/official-variables.yml@self
3433

3534
extends:
3635
template: v1/1ES.Official.PipelineTemplate.yml@1es

eng/ci/public-build.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ resources:
2727
ref: refs/tags/release
2828

2929
variables:
30-
- name: isSdkRelease
31-
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/sdk/')]
32-
- name: isExtensionsRelease
33-
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/extensions/')]
30+
- template: /eng/templates/utils/variables.yml@self
3431

3532
extends:
3633
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es

eng/scripts/test-extensions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
python -m pip install --upgrade pip
44
if [[ $2 != "3.7" ]]; then
55
python -m pip install -e $1/PythonExtensionArtifact
6-
python -m pip install --pre -U -e .[test-http-v2]
6+
python -m pip install --pre -e .[test-http-v2]
77
fi
88
if [[ $2 != "3.7" && $2 != "3.8" ]]; then
99
python -m pip install -e $1/PythonExtensionArtifact

eng/scripts/test-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
python -m pip install --upgrade pip
44
python -m pip install -e $1/PythonSdkArtifact
5-
python -m pip install -U -e .[dev]
5+
python -m pip install -e .[dev]
66

77
if [[ $2 != "3.7" ]]; then
88
python -m pip install --pre -U -e .[test-http-v2]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
displayName: 'Install test python extension, dependencies and the worker'
117117
condition: or(eq(variables.isExtensionsRelease, true), eq(variables['USETESTPYTHONEXTENSIONS'], true))
118118
- bash: |
119-
python -m pytest -q -n auto --dist loadfile --reruns 4 --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py tests/extension_tests/http_v2_tests
119+
python -m pytest -q -n auto --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
120120
env:
121121
AzureWebJobsStorage: $(STORAGE_CONNECTION)
122122
AzureWebJobsCosmosDBConnectionString: $(COSMOSDB_CONNECTION)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variables:
2+
- template: /ci/variables/build.yml@eng
3+
- template: /ci/variables/cfs.yml@eng
4+
- group: python-integration-resources

eng/templates/utils/variables.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variables:
2+
- name: isSdkRelease
3+
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/sdk/')]
4+
- name: isExtensionsRelease
5+
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/extensions/')]

tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_enabled.py renamed to tests/extension_tests/deferred_bindings_tests/test_deferred_bindings.py

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import unittest
55

6+
import azure.functions as func
67
from tests.utils import testutils
78

89
from azure_functions_worker import protos
@@ -20,6 +21,14 @@
2021
'deferred_bindings_tests' / \
2122
'deferred_bindings_functions' / \
2223
'deferred_bindings_enabled'
24+
DEFERRED_BINDINGS_DISABLED_DIR = testutils.EXTENSION_TESTS_FOLDER / \
25+
'deferred_bindings_tests' / \
26+
'deferred_bindings_functions' / \
27+
'deferred_bindings_disabled'
28+
DEFERRED_BINDINGS_ENABLED_DUAL_DIR = testutils.EXTENSION_TESTS_FOLDER / \
29+
'deferred_bindings_tests' / \
30+
'deferred_bindings_functions' / \
31+
'deferred_bindings_enabled_dual'
2332

2433

2534
class MockMBD:
@@ -35,6 +44,7 @@ def __init__(self, version: str, source: str,
3544
"is only supported for 3.9+.")
3645
class TestDeferredBindingsEnabled(testutils.AsyncTestCase):
3746

47+
@testutils.retryable_test(3, 5)
3848
async def test_deferred_bindings_enabled_metadata(self):
3949
async with testutils.start_mockhost(
4050
script_root=DEFERRED_BINDINGS_ENABLED_DIR) as host:
@@ -43,7 +53,9 @@ async def test_deferred_bindings_enabled_metadata(self):
4353
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
4454
self.assertEqual(r.response.result.status,
4555
protos.StatusResult.Success)
56+
del sys.modules['function_app']
4657

58+
@testutils.retryable_test(3, 5)
4759
async def test_deferred_bindings_enabled_log(self):
4860
async with testutils.start_mockhost(
4961
script_root=DEFERRED_BINDINGS_ENABLED_DIR) as host:
@@ -56,11 +68,74 @@ async def test_deferred_bindings_enabled_log(self):
5668
enabled_log_present = True
5769
break
5870
self.assertTrue(enabled_log_present)
71+
del sys.modules['function_app']
72+
73+
74+
@unittest.skipIf(sys.version_info.minor <= 8, "The base extension"
75+
"is only supported for 3.9+.")
76+
class TestDeferredBindingsDisabled(testutils.AsyncTestCase):
77+
78+
@testutils.retryable_test(3, 5)
79+
async def test_deferred_bindings_disabled_metadata(self):
80+
async with testutils.start_mockhost(
81+
script_root=DEFERRED_BINDINGS_DISABLED_DIR) as host:
82+
await host.init_worker()
83+
r = await host.get_functions_metadata()
84+
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
85+
self.assertEqual(r.response.result.status,
86+
protos.StatusResult.Success)
87+
del sys.modules['function_app']
88+
89+
@testutils.retryable_test(3, 5)
90+
async def test_deferred_bindings_disabled_log(self):
91+
async with testutils.start_mockhost(
92+
script_root=DEFERRED_BINDINGS_DISABLED_DIR) as host:
93+
await host.init_worker()
94+
r = await host.get_functions_metadata()
95+
disabled_log_present = False
96+
for log in r.logs:
97+
message = log.message
98+
if "Deferred bindings enabled: False" in message:
99+
disabled_log_present = True
100+
break
101+
self.assertTrue(disabled_log_present)
102+
del sys.modules['function_app']
103+
104+
105+
@unittest.skipIf(sys.version_info.minor <= 8, "The base extension"
106+
"is only supported for 3.9+.")
107+
class TestDeferredBindingsEnabledDual(testutils.AsyncTestCase):
108+
109+
@testutils.retryable_test(3, 5)
110+
async def test_deferred_bindings_dual_metadata(self):
111+
async with testutils.start_mockhost(
112+
script_root=DEFERRED_BINDINGS_ENABLED_DUAL_DIR) as host:
113+
await host.init_worker()
114+
r = await host.get_functions_metadata()
115+
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
116+
self.assertEqual(r.response.result.status,
117+
protos.StatusResult.Success)
118+
del sys.modules['function_app']
119+
120+
@testutils.retryable_test(3, 5)
121+
async def test_deferred_bindings_dual_enabled_log(self):
122+
async with testutils.start_mockhost(
123+
script_root=DEFERRED_BINDINGS_ENABLED_DUAL_DIR) as host:
124+
await host.init_worker()
125+
r = await host.get_functions_metadata()
126+
enabled_log_present = False
127+
for log in r.logs:
128+
message = log.message
129+
if "Deferred bindings enabled: True" in message:
130+
enabled_log_present = True
131+
break
132+
self.assertTrue(enabled_log_present)
133+
del sys.modules['function_app']
59134

60135

61136
@unittest.skipIf(sys.version_info.minor <= 8, "The base extension"
62137
"is only supported for 3.9+.")
63-
class TestDeferredBindingsEnabledHelpers(testutils.AsyncTestCase):
138+
class TestDeferredBindingsHelpers(testutils.AsyncTestCase):
64139

65140
def test_deferred_bindings_enabled_decode(self):
66141
binding = BlobClientConverter
@@ -92,27 +167,31 @@ async def test_check_deferred_bindings_enabled(self):
92167
93168
The second represents if the current binding is deferred binding. If this is
94169
True, then deferred bindings must also be enabled at the function level.
95-
96-
Test type 1: type is supported, deferred_bindings_enabled is not yet set
97-
Test type 2: type is supported, deferred_bindings_enabled is already set
98170
"""
99171
async with testutils.start_mockhost(
100172
script_root=DEFERRED_BINDINGS_ENABLED_DIR) as host:
101173
await host.init_worker()
102-
self.assertEqual(meta.check_deferred_bindings_enabled(
103-
BlobClient, False), (True, True))
104174

175+
# Type is not supported, deferred_bindings_enabled is not yet set
105176
self.assertEqual(meta.check_deferred_bindings_enabled(
106-
BlobClient, True), (True, True))
177+
func.InputStream, False), (False, False))
107178

179+
# Type is not supported, deferred_bindings_enabled already set
108180
self.assertEqual(meta.check_deferred_bindings_enabled(
109-
ContainerClient, False), (True, True))
181+
func.InputStream, True), (True, False))
110182

183+
# Type is supported, deferred_bindings_enabled is not yet set
111184
self.assertEqual(meta.check_deferred_bindings_enabled(
112-
ContainerClient, True), (True, True))
113-
185+
BlobClient, False), (True, True))
186+
self.assertEqual(meta.check_deferred_bindings_enabled(
187+
ContainerClient, False), (True, True))
114188
self.assertEqual(meta.check_deferred_bindings_enabled(
115189
StorageStreamDownloader, False), (True, True))
116190

191+
# Type is supported, deferred_bindings_enabled is already set
192+
self.assertEqual(meta.check_deferred_bindings_enabled(
193+
BlobClient, True), (True, True))
194+
self.assertEqual(meta.check_deferred_bindings_enabled(
195+
ContainerClient, True), (True, True))
117196
self.assertEqual(meta.check_deferred_bindings_enabled(
118197
StorageStreamDownloader, True), (True, True))

tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_disabled.py

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

0 commit comments

Comments
 (0)