Skip to content

Commit 18b9dc2

Browse files
author
Victoria Hall
committed
debug logging test
1 parent bc35881 commit 18b9dc2

File tree

7 files changed

+75
-22
lines changed

7 files changed

+75
-22
lines changed

.github/workflows/ci_e2e_workflow.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ jobs:
7575
retry 5 python setup.py extension
7676
mkdir logs
7777
- name: Grant execute permission
78-
run: chmod +x .github/Scripts/fwpc-tests.sh .github/Scripts/e2e-tests.sh
78+
run: |
79+
chmod +x .github/Scripts/fwpc-tests.sh
80+
chmod +x .github/Scripts/e2e-tests.sh
7981
- name: Running 3.7 Tests
8082
if: matrix.python-version == 3.7
8183
env:
@@ -87,7 +89,9 @@ jobs:
8789
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString37 }}
8890
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString37 }}
8991
ARCHIVE_WEBHOST_LOGS: ${{ github.event.inputs.archive_webhost_logging }}
90-
run: .github/Scripts/fwpc-tests.sh .github/Scripts/e2e-tests.sh
92+
run: |
93+
.github/Scripts/fwpc-tests.sh
94+
.github/Scripts/e2e-tests.sh
9195
- name: Running 3.8 Tests
9296
if: matrix.python-version == 3.8
9397
env:
@@ -99,7 +103,9 @@ jobs:
99103
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString38 }}
100104
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString38 }}
101105
ARCHIVE_WEBHOST_LOGS: ${{ github.event.inputs.archive_webhost_logging }}
102-
run: .github/Scripts/fwpc-tests.sh .github/Scripts/e2e-tests.sh
106+
run: |
107+
.github/Scripts/fwpc-tests.sh
108+
.github/Scripts/e2e-tests.sh
103109
- name: Running 3.9 Tests
104110
if: matrix.python-version == 3.9
105111
env:
@@ -111,7 +117,9 @@ jobs:
111117
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString39 }}
112118
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString39 }}
113119
ARCHIVE_WEBHOST_LOGS: ${{ github.event.inputs.archive_webhost_logging }}
114-
run: .github/Scripts/fwpc-tests.sh .github/Scripts/e2e-tests.sh
120+
run: |
121+
.github/Scripts/fwpc-tests.sh
122+
.github/Scripts/e2e-tests.sh
115123
- name: Running 3.10 Tests
116124
if: matrix.python-version == 3.10
117125
env:
@@ -123,7 +131,9 @@ jobs:
123131
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString310 }}
124132
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString310 }}
125133
ARCHIVE_WEBHOST_LOGS: ${{ github.event.inputs.archive_webhost_logging }}
126-
run: .github/Scripts/fwpc-tests.sh .github/Scripts/e2e-tests.sh
134+
run: |
135+
.github/Scripts/fwpc-tests.sh
136+
.github/Scripts/e2e-tests.sh
127137
- name: Running 3.11 Tests
128138
if: matrix.python-version == 3.11
129139
env:
@@ -135,7 +145,9 @@ jobs:
135145
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString311 }}
136146
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString311 }}
137147
ARCHIVE_WEBHOST_LOGS: ${{ github.event.inputs.archive_webhost_logging }}
138-
run: .github/Scripts/fwpc-tests.sh .github/Scripts/e2e-tests.sh
148+
run: |
149+
.github/Scripts/fwpc-tests.sh
150+
.github/Scripts/e2e-tests.sh
139151
- name: Codecov
140152
uses: codecov/codecov-action@v3
141153
with:

python/test/worker.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"defaultWorkerPath":"worker.py",
77
"workerIndexing": "true"
88
}
9-
}
9+
}

tests/endtoend/generic_functions/generic_functions_stein/function_app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ def return_not_processed_last(req: func.HttpRequest, testEntities):
4343
table_name="EventHubBatchTest")
4444
def mytimer(mytimer: func.TimerRequest, testEntity) -> None:
4545
logging.info("This timer trigger function executed successfully")
46+
47+
48+
@app.function_name(name="mytimer2")
49+
@app.schedule(schedule="*/1 * * * * *", arg_name="mytimer",
50+
run_on_startup=False,
51+
use_monitor=False)
52+
@app.generic_input_binding(
53+
arg_name="testEntity",
54+
type="table",
55+
connection="AzureWebJobsStorage",
56+
table_name="EventHubBatchTest")
57+
def mytimer2(mytimer: func.TimerRequest, testEntity):
58+
logging.info("Timer trigger with none return and no type hint")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"scriptFile": "main.py",
3+
"bindings": [
4+
{
5+
"name": "mytimer",
6+
"type": "timerTrigger",
7+
"direction": "in",
8+
"schedule": "*/1 * * * * *",
9+
"runOnStartup": false
10+
},
11+
{
12+
"direction": "in",
13+
"type": "table",
14+
"name": "testEntity",
15+
"partitionKey": "test",
16+
"rowKey": "WillBePopulatedWithGuid",
17+
"tableName": "BindingTestTable",
18+
"connection": "AzureWebJobsStorage"
19+
}
20+
]
21+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
import logging
5+
6+
import azure.functions as func
7+
8+
9+
def main(mytimer: func.TimerRequest, testEntity):
10+
logging.info("Timer trigger with none return and no type hint")

tests/endtoend/test_generic_functions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,18 @@ def test_return_none(self):
5151
timeout=5)
5252
self.assertTrue(r.ok)
5353

54+
def test_return_none_no_type_hint(self):
55+
time.sleep(1)
56+
# Checking webhost status.
57+
r = self.webhost.request('GET', '', no_prefix=True,
58+
timeout=5)
59+
self.assertTrue(r.ok)
60+
5461
def check_log_timer(self, host_out: typing.List[str]):
5562
self.assertEqual(host_out.count("This timer trigger function executed "
5663
"successfully"), 1)
64+
self.assertEqual(host_out.count("Timer trigger with none return "
65+
"and no type hint"), 1)
5766

5867

5968
@skipIf(is_envvar_true(DEDICATED_DOCKER_TEST)

tests/unittests/test_enable_debug_logging_functions.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ class TestDebugLoggingEnabledFunctions(testutils.WebHostTestCase):
2727
"""
2828
@classmethod
2929
def setUpClass(cls):
30-
os_environ = os.environ.copy()
31-
os_environ[PYTHON_ENABLE_DEBUG_LOGGING] = '1'
32-
cls._patch_environ = patch.dict('os.environ', os_environ)
33-
cls._patch_environ.start()
30+
os.environ.update({PYTHON_ENABLE_DEBUG_LOGGING: '1'})
3431
super().setUpClass()
3532

3633
@classmethod
3734
def tearDownClass(cls):
3835
os.environ.pop(PYTHON_ENABLE_DEBUG_LOGGING)
3936
super().tearDownClass()
40-
cls._patch_environ.stop()
4137

4238
@classmethod
4339
def get_script_dir(cls):
@@ -65,17 +61,13 @@ class TestDebugLoggingDisabledFunctions(testutils.WebHostTestCase):
6561
"""
6662
@classmethod
6763
def setUpClass(cls):
68-
os_environ = os.environ.copy()
69-
os_environ[PYTHON_ENABLE_DEBUG_LOGGING] = '0'
70-
cls._patch_environ = patch.dict('os.environ', os_environ)
71-
cls._patch_environ.start()
64+
os.environ.update({PYTHON_ENABLE_DEBUG_LOGGING: '0'})
7265
super().setUpClass()
7366

7467
@classmethod
7568
def tearDownClass(cls):
7669
os.environ.pop(PYTHON_ENABLE_DEBUG_LOGGING)
7770
super().tearDownClass()
78-
cls._patch_environ.stop()
7971

8072
@classmethod
8173
def get_script_dir(cls):
@@ -109,10 +101,7 @@ def setUpClass(cls):
109101
with open(host_json, 'w+') as f:
110102
f.write(HOST_JSON_TEMPLATE_WITH_LOGLEVEL_INFO)
111103

112-
os_environ = os.environ.copy()
113-
os_environ[PYTHON_ENABLE_DEBUG_LOGGING] = '1'
114-
cls._patch_environ = patch.dict('os.environ', os_environ)
115-
cls._patch_environ.start()
104+
os.environ.update({PYTHON_ENABLE_DEBUG_LOGGING: '1'})
116105
super().setUpClass()
117106

118107
@classmethod
@@ -122,7 +111,6 @@ def tearDownClass(cls):
122111

123112
os.environ.pop(PYTHON_ENABLE_DEBUG_LOGGING)
124113
super().tearDownClass()
125-
cls._patch_environ.stop()
126114

127115
@classmethod
128116
def get_script_dir(cls):

0 commit comments

Comments
 (0)