Skip to content

test: move E2E test scenarios out from unit tests #1502

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

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions eng/scripts/clean-up-resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from azure.storage.blob import ContainerClient
from azure.cosmos import CosmosClient

# Clean up Blob storage account
container_client = ContainerClient.from_connection_string(
conn_str="AzureWebJobsStorage",
container_name="python-worker-tests")
for blob in container_client.list_blobs():
container_client.delete_blob(blob.name)

# Clean up CosmosDB
cosmos_client = CosmosClient.from_connection_string(
conn_str="AzureWebJobsCosmosDBConnectionString")
database = cosmos_client.get_database_client("test")
container = database.get_container_client("items")
for item in container.query_items(
query='SELECT * FROM items',
enable_cross_partition_query=True):
container.delete_item(item, partition_key='Widget')
12 changes: 12 additions & 0 deletions eng/templates/official/jobs/ci-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,15 @@ jobs:
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)
USETESTPYTHONSDK: or(eq(variables.isSdkRelease, true), eq(variables['USETESTPYTHONSDK'], true))
displayName: "Running $(PYTHON_VERSION) Python E2E Tests"
- bash: |
python eng/scripts/clean-up-resources.py
env:
AzureWebJobsStorage: $(STORAGE_CONNECTION)
AzureWebJobsCosmosDBConnectionString: $(COSMOSDB_CONNECTION)
AzureWebJobsEventHubConnectionString: $(EVENTHUB_CONNECTION)
AzureWebJobsServiceBusConnectionString: $(SERVICEBUS_CONNECTION)
AzureWebJobsSqlConnectionString: $(SQL_CONNECTION)
AzureWebJobsEventGridTopicUri: $(EVENTGRID_URI)
AzureWebJobsEventGridConnectionKey: $(EVENTGRID_CONNECTION)
displayName: "Clean Up Test Resources"
condition: always()
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ Repository = "https://github.com/Azure/azure-functions-python-worker"

[project.optional-dependencies]
dev = [
"azure-cosmos", # Used for cleaning up test resources
"azure-eventhub", # Used for EventHub E2E tests
"azure-functions-durable", # Used for Durable E2E tests
"azure-storage-blob", # Used for cleaning up test resources
"flask",
"fastapi~=0.103.2",
"pydantic",
Expand Down
29 changes: 29 additions & 0 deletions tests/endtoend/http_functions/async_logging/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import asyncio
import logging

import azure.functions

logger = logging.getLogger('my function')


async def main(req: azure.functions.HttpRequest):
logger.info('hello %s', 'info')

await asyncio.sleep(0.1)

# Create a nested task to check if invocation_id is still
# logged correctly.
await asyncio.ensure_future(nested())

await asyncio.sleep(0.1)

return 'OK-async'


async def nested():
try:
1 / 0
except ZeroDivisionError:
logger.error('and another error', exc_info=True)
Loading
Loading