Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unique function names #1557

Merged
merged 12 commits into from
Aug 8, 2024
5 changes: 2 additions & 3 deletions eng/ci/core-tools-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ resources:
ref: refs/tags/release

variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
- template: /eng/templates/utils/official-variables.yml@self

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
parameters:
Expand Down
4 changes: 1 addition & 3 deletions eng/ci/custom-image-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ resources:
ref: refs/tags/release

variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
- template: /eng/templates/utils/official-variables.yml@self

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
Expand Down
4 changes: 1 addition & 3 deletions eng/ci/docker-consumption-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ resources:
ref: refs/tags/release

variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
- template: /eng/templates/utils/official-variables.yml@self

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
Expand Down
4 changes: 1 addition & 3 deletions eng/ci/docker-dedicated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ resources:
ref: refs/tags/release

variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
- template: /eng/templates/utils/official-variables.yml@self

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
Expand Down
9 changes: 2 additions & 7 deletions eng/ci/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ resources:
ref: refs/tags/release

variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
- name: isSdkRelease
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/sdk/')]
- name: isExtensionsRelease
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/extensions/')]
- template: /eng/templates/utils/variables.yml@self
- template: /eng/templates/utils/official-variables.yml@self

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
Expand Down
5 changes: 2 additions & 3 deletions eng/ci/official-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ resources:
ref: refs/tags/release

variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
- template: /eng/templates/utils/variables.yml@self
- template: /eng/templates/utils/official-variables.yml@self

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1es
Expand Down
5 changes: 1 addition & 4 deletions eng/ci/public-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ resources:
ref: refs/tags/release

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

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
Expand Down
2 changes: 1 addition & 1 deletion eng/scripts/test-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
python -m pip install --upgrade pip
if [[ $2 != "3.7" ]]; then
python -m pip install -e $1/PythonExtensionArtifact
python -m pip install --pre -U -e .[test-http-v2]
python -m pip install --pre -e .[test-http-v2]
fi
if [[ $2 != "3.7" && $2 != "3.8" ]]; then
python -m pip install -e $1/PythonExtensionArtifact
Expand Down
2 changes: 1 addition & 1 deletion eng/scripts/test-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

python -m pip install --upgrade pip
python -m pip install -e $1/PythonSdkArtifact
python -m pip install -U -e .[dev]
python -m pip install -e .[dev]

if [[ $2 != "3.7" ]]; then
python -m pip install --pre -U -e .[test-http-v2]
Expand Down
4 changes: 4 additions & 0 deletions eng/templates/utils/official-variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variables:
- template: /ci/variables/build.yml@eng
- template: /ci/variables/cfs.yml@eng
- group: python-integration-resources
5 changes: 5 additions & 0 deletions eng/templates/utils/variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variables:
- name: isSdkRelease
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/sdk/')]
- name: isExtensionsRelease
value: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/extensions/')]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import unittest

import azure.functions as func
from tests.utils import testutils

from azure_functions_worker import protos
Expand All @@ -20,6 +21,14 @@
'deferred_bindings_tests' / \
'deferred_bindings_functions' / \
'deferred_bindings_enabled'
DEFERRED_BINDINGS_DISABLED_DIR = testutils.EXTENSION_TESTS_FOLDER / \
'deferred_bindings_tests' / \
'deferred_bindings_functions' / \
'deferred_bindings_disabled'
DEFERRED_BINDINGS_ENABLED_DUAL_DIR = testutils.EXTENSION_TESTS_FOLDER / \
'deferred_bindings_tests' / \
'deferred_bindings_functions' / \
'deferred_bindings_enabled_dual'


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

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

@testutils.retryable_test(3, 5)
async def test_deferred_bindings_enabled_log(self):
async with testutils.start_mockhost(
script_root=DEFERRED_BINDINGS_ENABLED_DIR) as host:
Expand All @@ -56,11 +68,74 @@ async def test_deferred_bindings_enabled_log(self):
enabled_log_present = True
break
self.assertTrue(enabled_log_present)
del sys.modules['function_app']


@unittest.skipIf(sys.version_info.minor <= 8, "The base extension"
"is only supported for 3.9+.")
class TestDeferredBindingsDisabled(testutils.AsyncTestCase):

@testutils.retryable_test(3, 5)
async def test_deferred_bindings_disabled_metadata(self):
async with testutils.start_mockhost(
script_root=DEFERRED_BINDINGS_DISABLED_DIR) as host:
await host.init_worker()
r = await host.get_functions_metadata()
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
self.assertEqual(r.response.result.status,
protos.StatusResult.Success)
del sys.modules['function_app']

@testutils.retryable_test(3, 5)
async def test_deferred_bindings_disabled_log(self):
async with testutils.start_mockhost(
script_root=DEFERRED_BINDINGS_DISABLED_DIR) as host:
await host.init_worker()
r = await host.get_functions_metadata()
disabled_log_present = False
for log in r.logs:
message = log.message
if "Deferred bindings enabled: False" in message:
disabled_log_present = True
break
self.assertTrue(disabled_log_present)
del sys.modules['function_app']


@unittest.skipIf(sys.version_info.minor <= 8, "The base extension"
"is only supported for 3.9+.")
class TestDeferredBindingsEnabledDual(testutils.AsyncTestCase):

@testutils.retryable_test(3, 5)
async def test_deferred_bindings_dual_metadata(self):
async with testutils.start_mockhost(
script_root=DEFERRED_BINDINGS_ENABLED_DUAL_DIR) as host:
await host.init_worker()
r = await host.get_functions_metadata()
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
self.assertEqual(r.response.result.status,
protos.StatusResult.Success)
del sys.modules['function_app']

@testutils.retryable_test(3, 5)
async def test_deferred_bindings_dual_enabled_log(self):
async with testutils.start_mockhost(
script_root=DEFERRED_BINDINGS_ENABLED_DUAL_DIR) as host:
await host.init_worker()
r = await host.get_functions_metadata()
enabled_log_present = False
for log in r.logs:
message = log.message
if "Deferred bindings enabled: True" in message:
enabled_log_present = True
break
self.assertTrue(enabled_log_present)
del sys.modules['function_app']


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

def test_deferred_bindings_enabled_decode(self):
binding = BlobClientConverter
Expand All @@ -81,6 +156,7 @@ def test_deferred_bindings_enabled_decode(self):
pytype=BlobClient, datum=datum, metadata={})

self.assertIsNotNone(obj)
del sys.modules['function_app']

async def test_check_deferred_bindings_enabled(self):
"""
Expand All @@ -92,27 +168,31 @@ async def test_check_deferred_bindings_enabled(self):

The second represents if the current binding is deferred binding. If this is
True, then deferred bindings must also be enabled at the function level.

Test type 1: type is supported, deferred_bindings_enabled is not yet set
Test type 2: type is supported, deferred_bindings_enabled is already set
"""
async with testutils.start_mockhost(
script_root=DEFERRED_BINDINGS_ENABLED_DIR) as host:
await host.init_worker()
self.assertEqual(meta.check_deferred_bindings_enabled(
BlobClient, False), (True, True))

# Type is not supported, deferred_bindings_enabled is not yet set
self.assertEqual(meta.check_deferred_bindings_enabled(
BlobClient, True), (True, True))
func.InputStream, False), (False, False))

# Type is not supported, deferred_bindings_enabled already set
self.assertEqual(meta.check_deferred_bindings_enabled(
ContainerClient, False), (True, True))
func.InputStream, True), (True, False))

# Type is supported, deferred_bindings_enabled is not yet set
self.assertEqual(meta.check_deferred_bindings_enabled(
ContainerClient, True), (True, True))

BlobClient, False), (True, True))
self.assertEqual(meta.check_deferred_bindings_enabled(
ContainerClient, False), (True, True))
self.assertEqual(meta.check_deferred_bindings_enabled(
StorageStreamDownloader, False), (True, True))

# Type is supported, deferred_bindings_enabled is already set
self.assertEqual(meta.check_deferred_bindings_enabled(
BlobClient, True), (True, True))
self.assertEqual(meta.check_deferred_bindings_enabled(
ContainerClient, True), (True, True))
self.assertEqual(meta.check_deferred_bindings_enabled(
StorageStreamDownloader, True), (True, True))

This file was deleted.

Loading
Loading