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

Running tests in parallel #1130

Merged
merged 11 commits into from
Nov 22, 2022
62 changes: 31 additions & 31 deletions tests/endtoend/test_linux_consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def test_placeholder_mode_root_returns_ok(self):
self._py_version) as ctrl:
req = Request('GET', ctrl.url)
resp = ctrl.send_request(req)
self.assertTrue(resp.ok)
await self.assertTrue(resp.ok)

async def test_http_no_auth(self):
"""An HttpTrigger function app with 'azure-functions' library
Expand All @@ -60,7 +60,7 @@ async def test_http_no_auth(self):
})
req = Request('GET', f'{ctrl.url}/api/HttpTrigger')
resp = ctrl.send_request(req)
self.assertEqual(resp.status_code, 200)
await self.assertEqual(resp.status_code, 200)

async def test_common_libraries(self):
"""A function app with the following requirements.txt:
Expand All @@ -83,14 +83,14 @@ async def test_common_libraries(self):
})
req = Request('GET', f'{ctrl.url}/api/HttpTrigger')
resp = ctrl.send_request(req)
self.assertEqual(resp.status_code, 200)
await self.assertEqual(resp.status_code, 200)
content = resp.json()
self.assertIn('azure.functions', content)
self.assertIn('azure.storage.blob', content)
self.assertIn('numpy', content)
self.assertIn('cryptography', content)
self.assertIn('pyodbc', content)
self.assertIn('requests', content)
await self.assertIn('azure.functions', content)
await self.assertIn('azure.storage.blob', content)
await self.assertIn('numpy', content)
await self.assertIn('cryptography', content)
await self.assertIn('pyodbc', content)
await self.assertIn('requests', content)

async def test_new_protobuf(self):
"""A function app with the following requirements.txt:
Expand All @@ -109,15 +109,15 @@ async def test_new_protobuf(self):
})
req = Request('GET', f'{ctrl.url}/api/HttpTrigger')
resp = ctrl.send_request(req)
self.assertEqual(resp.status_code, 200)
await self.assertEqual(resp.status_code, 200)

content = resp.json()

# Worker always picks up the SDK version bundled with the image
# Version of the packages are inconsistent due to isolation's bug
self.assertEqual(content['azure.functions'], '1.7.0')
self.assertEqual(content['google.protobuf'], '3.15.8')
self.assertEqual(content['grpc'], '1.33.2')
await self.assertEqual(content['azure.functions'], '1.7.0')
await self.assertEqual(content['google.protobuf'], '3.15.8')
await self.assertEqual(content['grpc'], '1.33.2')

async def test_old_protobuf(self):
"""A function app with the following requirements.txt:
Expand All @@ -136,15 +136,15 @@ async def test_old_protobuf(self):
})
req = Request('GET', f'{ctrl.url}/api/HttpTrigger')
resp = ctrl.send_request(req)
self.assertEqual(resp.status_code, 200)
await self.assertEqual(resp.status_code, 200)

content = resp.json()

# Worker always picks up the SDK version bundled with the image
# Version of the packages are inconsistent due to isolation's bug
self.assertIn(content['azure.functions'], '1.5.0')
self.assertIn(content['google.protobuf'], '3.8.0')
self.assertIn(content['grpc'], '1.27.1')
await self.assertIn(content['azure.functions'], '1.5.0')
await self.assertIn(content['google.protobuf'], '3.8.0')
await self.assertIn(content['grpc'], '1.27.1')

async def test_debug_logging_disabled(self):
"""An HttpTrigger function app with 'azure-functions' library
Expand All @@ -160,18 +160,18 @@ async def test_debug_logging_disabled(self):
req = Request('GET', f'{ctrl.url}/api/HttpTrigger1')
resp = ctrl.send_request(req)

self.assertEqual(resp.status_code, 200)
await self.assertEqual(resp.status_code, 200)
container_log = ctrl.get_container_logs()
func_start_idx = container_log.find(
"Executing 'Functions.HttpTrigger1'")
self.assertTrue(func_start_idx > -1,
await self.assertTrue(func_start_idx > -1,
"HttpTrigger function is not executed.")
func_log = container_log[func_start_idx:]

self.assertIn('logging info', func_log)
self.assertIn('logging warning', func_log)
self.assertIn('logging error', func_log)
self.assertNotIn('logging debug', func_log)
await self.assertIn('logging info', func_log)
await self.assertIn('logging warning', func_log)
await self.assertIn('logging error', func_log)
await self.assertNotIn('logging debug', func_log)

async def test_debug_logging_enabled(self):
"""An HttpTrigger function app with 'azure-functions' library
Expand All @@ -189,17 +189,17 @@ async def test_debug_logging_enabled(self):
req = Request('GET', f'{ctrl.url}/api/HttpTrigger1')
resp = ctrl.send_request(req)

self.assertEqual(resp.status_code, 200)
await self.assertEqual(resp.status_code, 200)
container_log = ctrl.get_container_logs()
func_start_idx = container_log.find(
"Executing 'Functions.HttpTrigger1'")
self.assertTrue(func_start_idx > -1)
await self.assertTrue(func_start_idx > -1)
func_log = container_log[func_start_idx:]

self.assertIn('logging info', func_log)
self.assertIn('logging warning', func_log)
self.assertIn('logging error', func_log)
self.assertIn('logging debug', func_log)
await self.assertIn('logging info', func_log)
await self.assertIn('logging warning', func_log)
await self.assertIn('logging error', func_log)
await self.assertIn('logging debug', func_log)

async def test_pinning_functions_to_older_version(self):
"""An HttpTrigger function app with 'azure-functions==1.11.1' library
Expand All @@ -217,8 +217,8 @@ async def test_pinning_functions_to_older_version(self):
req = Request('GET', f'{ctrl.url}/api/HttpTrigger1')
resp = ctrl.send_request(req)

self.assertEqual(resp.status_code, 200)
self.assertIn("Func Version: 1.11.1", resp.text)
await self.assertEqual(resp.status_code, 200)
await self.assertIn("Func Version: 1.11.1", resp.text)

def _get_blob_url(self, scenario_name: str) -> str:
return (
Expand Down
3 changes: 2 additions & 1 deletion tests/unittests/test_shared_memory_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@skipIf(sys.platform == 'darwin', 'MacOS M1 machines do not correctly test the'
'shared memory filesystems and thus skipping'
' these tests for the time being')
@pytest.mark.flaky(reruns=3)
gavin-aguiar marked this conversation as resolved.
Show resolved Hide resolved
class TestSharedMemoryMap(testutils.SharedMemoryTestCase):
"""
Tests for SharedMemoryMap.
Expand Down Expand Up @@ -56,6 +55,7 @@ def test_init_with_invalid_inputs(self):
'Invalid memory map'):
SharedMemoryMap(self.file_accessor, mem_map_name, None)

@pytest.mark.flaky(reruns=3)
def test_put_bytes(self):
"""
Create a SharedMemoryMap and write bytes to it.
Expand All @@ -73,6 +73,7 @@ def test_put_bytes(self):
dispose_status = shared_mem_map.dispose()
self.assertTrue(dispose_status)

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