Skip to content

Commit cef6f98

Browse files
gavin-aguiarGavin Aguiarvrdmr
authored
Running tests in parallel (#1130)
* Running tests in parallel * Updated lc tests to async * Making lc tests async * Undo asyncio * Flake8 fix * Unskip lc tests for 3.10 * Skip lc tests for 310 * Updating code coverage to v3 * Test fix for 310 ut Co-authored-by: Gavin Aguiar <gavin@GavinPC.localdomain> Co-authored-by: Varad Meru <vrdmr@users.noreply.github.com>
1 parent 832d261 commit cef6f98

File tree

10 files changed

+30
-13
lines changed

10 files changed

+30
-13
lines changed

.github/workflows/ci_e2e_workflow.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString36 }}
7777
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString36 }}
7878
run: |
79-
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
79+
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
8080
- name: Running 3.7 Tests
8181
if: matrix.python-version == 3.7
8282
env:
@@ -88,7 +88,7 @@ jobs:
8888
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString37 }}
8989
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString37 }}
9090
run: |
91-
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
91+
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
9292
- name: Running 3.8 Tests
9393
if: matrix.python-version == 3.8
9494
env:
@@ -100,7 +100,7 @@ jobs:
100100
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString38 }}
101101
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString38 }}
102102
run: |
103-
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
103+
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
104104
- name: Running 3.9 Tests
105105
if: matrix.python-version == 3.9
106106
env:
@@ -112,7 +112,7 @@ jobs:
112112
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString39 }}
113113
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString39 }}
114114
run: |
115-
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
115+
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
116116
- name: Running 3.10 Tests
117117
if: matrix.python-version == 3.10
118118
env:
@@ -124,7 +124,7 @@ jobs:
124124
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString310 }}
125125
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString310 }}
126126
run: |
127-
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
127+
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
128128
- name: Codecov
129129
uses: codecov/codecov-action@v1.0.13
130130
with:

.github/workflows/ogf_workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
- name: Install node and npm
8282
uses: actions/setup-node@v2
8383
with:
84-
node-version: '12'
84+
node-version: '16'
8585
check-latest: true
8686

8787
- name: Azure Login

.github/workflows/ut_ci_workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ jobs:
6464
retry 5 python setup.py extension
6565
- name: Test with pytest
6666
env:
67-
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString310 }}
67+
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString310 }} # needed for installing azure-functions-durable while running setup.py
6868
run: |
69-
python -m pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch tests/unittests
69+
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch tests/unittests
7070
- name: Codecov
71-
uses: codecov/codecov-action@v1.0.13
71+
uses: codecov/codecov-action@v3
7272
with:
7373
file: ./coverage.xml # optional
7474
flags: unittests # optional

azure_functions_worker/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
def format_exception(exception: Exception) -> str:
2525
msg = str(exception) + "\n"
26-
if sys.version_info.minor < 10:
26+
if (sys.version_info.major, sys.version_info.minor) < (3, 10):
2727
msg += ''.join(traceback.format_exception(
2828
etype=type(exception),
2929
tb=exception.__traceback__,
3030
value=exception))
31-
elif sys.version_info.minor == 10:
31+
elif (sys.version_info.major, sys.version_info.minor) == (3, 10):
3232
msg += ''.join(traceback.format_exception(exception))
3333
else:
3434
msg = str(exception)

codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ignore:
2-
- "azure_functions_worker/testutils.py"
3-
- "azure_functions_worker/testutils_*.py"
2+
- "tests/utils/testutils.py"
3+
- "tests/utils/testutils_lc.py"

tests/unittests/test_enable_debug_logging_functions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import os
55
from unittest.mock import patch
66

7+
import pytest
8+
79
from tests.utils import testutils
810
from azure_functions_worker.constants import PYTHON_ENABLE_DEBUG_LOGGING
911
from tests.utils.testutils import TESTS_ROOT, remove_path
@@ -42,6 +44,7 @@ def tearDownClass(cls):
4244
def get_script_dir(cls):
4345
return testutils.UNIT_TESTS_FOLDER / 'log_filtering_functions'
4446

47+
@pytest.mark.flaky(reruns=3)
4548
def test_debug_logging_enabled(self):
4649
"""
4750
Verify when cx debug logging is enabled, cx function debug logs
@@ -79,6 +82,7 @@ def tearDownClass(cls):
7982
def get_script_dir(cls):
8083
return testutils.UNIT_TESTS_FOLDER / 'log_filtering_functions'
8184

85+
@pytest.mark.flaky(reruns=3)
8286
def test_debug_logging_disabled(self):
8387
"""
8488
Verify when cx debug logging is disabled, cx function debug logs
@@ -125,6 +129,7 @@ def tearDownClass(cls):
125129
def get_script_dir(cls):
126130
return testutils.UNIT_TESTS_FOLDER / 'log_filtering_functions'
127131

132+
@pytest.mark.flaky(reruns=3)
128133
def test_debug_logging_filtered(self):
129134
"""
130135
Verify when cx debug logging is enabled and host logging level

tests/unittests/test_http_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def check_log_async_logging(self, host_out: typing.List[str]):
100100
self.assertIn('hello info', host_out)
101101
self.assertIn('and another error', host_out)
102102

103+
@pytest.mark.flaky(reruns=3)
103104
def test_debug_logging(self):
104105
r = self.webhost.request('GET', 'debug_logging')
105106
self.assertEqual(r.status_code, 200)
@@ -111,6 +112,7 @@ def check_log_debug_logging(self, host_out: typing.List[str]):
111112
self.assertIn('logging error', host_out)
112113
self.assertNotIn('logging debug', host_out)
113114

115+
@pytest.mark.flaky(reruns=3)
114116
def test_debug_with_user_logging(self):
115117
r = self.webhost.request('GET', 'debug_user_logging')
116118
self.assertEqual(r.status_code, 200)
@@ -306,6 +308,7 @@ def test_application_octet_stream_content_type(self):
306308
if (os.path.exists(received_img_file)):
307309
os.remove(received_img_file)
308310

311+
@pytest.mark.flaky(reruns=3)
309312
def test_user_event_loop_error(self):
310313
# User event loop is not supported in HTTP trigger
311314
r = self.webhost.request('GET', 'user_event_loop/')

tests/unittests/test_log_filtering_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Licensed under the MIT License.
33
import typing
44

5+
import pytest
6+
57
from tests.utils import testutils
68

79
HOST_JSON_TEMPLATE_WITH_LOGLEVEL_INFO = """\
@@ -60,6 +62,7 @@ def check_log_debug_logging(self, host_out: typing.List[str]):
6062
# See HOST_JSON_TEMPLATE_WITH_LOGLEVEL_INFO, debug log is disabled
6163
self.assertNotIn('logging debug', host_out)
6264

65+
@pytest.mark.flaky(reruns=3)
6366
def test_debug_with_user_logging(self):
6467
r = self.webhost.request('GET', 'debug_user_logging')
6568
self.assertEqual(r.status_code, 200)

tests/unittests/test_shared_memory_map.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import unittest
77
from unittest import skipIf
88

9+
import pytest
10+
911
from tests.utils import testutils
1012
from azure_functions_worker.bindings.shared_memory_data_transfer \
1113
import SharedMemoryMap
@@ -53,6 +55,7 @@ def test_init_with_invalid_inputs(self):
5355
'Invalid memory map'):
5456
SharedMemoryMap(self.file_accessor, mem_map_name, None)
5557

58+
@pytest.mark.flaky(reruns=3)
5659
def test_put_bytes(self):
5760
"""
5861
Create a SharedMemoryMap and write bytes to it.
@@ -70,6 +73,7 @@ def test_put_bytes(self):
7073
dispose_status = shared_mem_map.dispose()
7174
self.assertTrue(dispose_status)
7275

76+
@pytest.mark.flaky(reruns=3)
7377
def test_get_bytes(self):
7478
"""
7579
Create a SharedMemoryMap, write bytes to it and then read them back.

tests/unittests/test_third_party_http_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def tearDownClass(cls):
5353
def get_script_dir(cls):
5454
pass
5555

56+
@pytest.mark.flaky(reruns=3)
5657
def test_debug_logging(self):
5758
r = self.webhost.request('GET', 'debug_logging', no_prefix=True)
5859
self.assertEqual(r.status_code, 200)
@@ -64,6 +65,7 @@ def check_log_debug_logging(self, host_out: typing.List[str]):
6465
self.assertIn('logging error', host_out)
6566
self.assertNotIn('logging debug', host_out)
6667

68+
@pytest.mark.flaky(reruns=3)
6769
def test_debug_with_user_logging(self):
6870
r = self.webhost.request('GET', 'debug_user_logging',
6971
no_prefix=True)

0 commit comments

Comments
 (0)