Skip to content

Commit b2a0bf6

Browse files
gavin-aguiarGavin AguiarYunchuWang
authored
Moved consumption tests in a separate pipeline (#1148)
* Moved consumption tests in separate pipeline * Installing pytest * Updated dependencies * Added xdist to pytest * Installing dependencies * Installing additional dependencies * Formatted yml file * Added __init__ * Added requests to dependencies * Added crypto to dependencies * Install all dependencies * Unskipped tests for py310 * Undo last change * Give permissions to temp dir * Temp: check user * Testing build worker * Fix syntax error * Ignore errors in cleanup * Added dependency isolation flag * Building webhost * Deleting temp dir * Adding logs * Check if dir is empty * Removing library mounting * Fixing flake8 test * Skipped downloading library * list dirs * Update ci_consumption_workflow.yml * Updated yml to checkout code * Skipping protobuf tests for py310 Co-authored-by: Gavin Aguiar <gavin@GavinPC> Co-authored-by: peterstone2017 <[email protected]>
1 parent cef6f98 commit b2a0bf6

File tree

5 files changed

+68
-26
lines changed

5 files changed

+68
-26
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow will run all tests in tests/consumption_tests in Docker using a consumption image
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: CI Consumption tests
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches: [ dev, master, main, release/* ]
10+
pull_request:
11+
branches: [ dev, master, main, release/* ]
12+
13+
jobs:
14+
build:
15+
name: "Python Consumption CI Run"
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
21+
22+
steps:
23+
- name: Checkout code.
24+
uses: actions/checkout@v2
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U -e .[dev]
32+
python setup.py build
33+
python setup.py webhost --branch-name=dev
34+
python setup.py extension
35+
- name: Running 3.7 Tests
36+
if: matrix.python-version == 3.7
37+
env:
38+
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString37 }}
39+
run: python -m pytest -n auto --instafail tests/consumption_tests
40+
- name: Running 3.8 Tests
41+
if: matrix.python-version == 3.8
42+
env:
43+
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString38 }}
44+
run: python -m pytest -n auto --instafail tests/consumption_tests
45+
- name: Running 3.9 Tests
46+
if: matrix.python-version == 3.9
47+
env:
48+
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString39 }}
49+
run: python -m pytest -n auto --instafail tests/consumption_tests
50+
- name: Running 3.10 Tests
51+
if: matrix.python-version == 3.10
52+
env:
53+
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString310 }}
54+
run: python -m pytest -n auto --instafail tests/consumption_tests

.github/workflows/ci_e2e_workflow.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,6 @@ jobs:
6565
retry 5 python setup.py build
6666
retry 5 python setup.py webhost --branch-name=dev
6767
retry 5 python setup.py extension
68-
- name: Running 3.6 Tests
69-
if: matrix.python-version == 3.6
70-
env:
71-
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString36 }}
72-
AzureWebJobsCosmosDBConnectionString: ${{ secrets.LinuxCosmosDBConnectionString36 }}
73-
AzureWebJobsEventHubConnectionString: ${{ secrets.LinuxEventHubConnectionString36 }}
74-
AzureWebJobsServiceBusConnectionString: ${{ secrets.LinuxServiceBusConnectionString36 }}
75-
AzureWebJobsSqlConnectionString: ${{ secrets.LinuxSqlConnectionString36 }}
76-
AzureWebJobsEventGridTopicUri: ${{ secrets.LinuxEventGridTopicUriString36 }}
77-
AzureWebJobsEventGridConnectionKey: ${{ secrets.LinuxEventGridConnectionKeyString36 }}
78-
run: |
79-
python -m pytest -n auto --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch --cov-append tests/endtoend
8068
- name: Running 3.7 Tests
8169
if: matrix.python-version == 3.7
8270
env:

tests/endtoend/test_linux_consumption.py renamed to tests/consumption_tests/test_linux_consumption.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
_DEFAULT_HOST_VERSION = "4"
1414

1515

16-
@skipIf(sys.version_info >= (3, 10, 0),
17-
"Skip the tests for Python 3.10 and above")
1816
class TestLinuxConsumption(TestCase):
1917
"""Test worker behaviors on specific scenarios.
2018
@@ -92,6 +90,8 @@ def test_common_libraries(self):
9290
self.assertIn('pyodbc', content)
9391
self.assertIn('requests', content)
9492

93+
@skipIf(sys.version_info.minor == 10,
94+
"Protobuf pinning fails during remote build")
9595
def test_new_protobuf(self):
9696
"""A function app with the following requirements.txt:
9797
@@ -105,7 +105,8 @@ def test_new_protobuf(self):
105105
self._py_version) as ctrl:
106106
ctrl.assign_container(env={
107107
"AzureWebJobsStorage": self._storage,
108-
"SCM_RUN_FROM_PACKAGE": self._get_blob_url("NewProtobuf")
108+
"SCM_RUN_FROM_PACKAGE": self._get_blob_url("NewProtobuf"),
109+
"PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
109110
})
110111
req = Request('GET', f'{ctrl.url}/api/HttpTrigger')
111112
resp = ctrl.send_request(req)
@@ -119,6 +120,8 @@ def test_new_protobuf(self):
119120
self.assertEqual(content['google.protobuf'], '3.15.8')
120121
self.assertEqual(content['grpc'], '1.33.2')
121122

123+
@skipIf(sys.version_info.minor == 10,
124+
"Protobuf pinning fails during remote build")
122125
def test_old_protobuf(self):
123126
"""A function app with the following requirements.txt:
124127
@@ -132,7 +135,8 @@ def test_old_protobuf(self):
132135
self._py_version) as ctrl:
133136
ctrl.assign_container(env={
134137
"AzureWebJobsStorage": self._storage,
135-
"SCM_RUN_FROM_PACKAGE": self._get_blob_url("OldProtobuf")
138+
"SCM_RUN_FROM_PACKAGE": self._get_blob_url("OldProtobuf"),
139+
"PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
136140
})
137141
req = Request('GET', f'{ctrl.url}/api/HttpTrigger')
138142
resp = ctrl.send_request(req)
@@ -213,6 +217,7 @@ def test_pinning_functions_to_older_version(self):
213217
"AzureWebJobsStorage": self._storage,
214218
"SCM_RUN_FROM_PACKAGE": self._get_blob_url(
215219
"PinningFunctions"),
220+
"PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
216221
})
217222
req = Request('GET', f'{ctrl.url}/api/HttpTrigger1')
218223
resp = ctrl.send_request(req)

tests/utils/testutils_lc.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,14 @@ def spawn_container(self,
162162
"""
163163
# Construct environment variables and start the docker container
164164
worker_path = os.path.join(PROJECT_ROOT, 'azure_functions_worker')
165-
library_path = os.path.join(tempfile.gettempdir(), _FUNC_FILE_NAME,
166-
'azure', 'functions')
167-
self._download_azure_functions()
165+
166+
# TODO: Mount library in docker container
167+
# self._download_azure_functions()
168168

169169
container_worker_path = (
170170
f"/azure-functions-host/workers/python/{self._py_version}/"
171171
"LINUX/X64/azure_functions_worker"
172172
)
173-
container_library_path = (
174-
f"/azure-functions-host/workers/python/{self._py_version}/"
175-
"LINUX/X64/azure/functions"
176-
)
177173

178174
run_cmd = []
179175
run_cmd.extend([self._docker_cmd, "run", "-p", "0:80", "-d"])
@@ -183,9 +179,7 @@ def spawn_container(self,
183179
run_cmd.extend(["-e", f"CONTAINER_NAME={self._uuid}"])
184180
run_cmd.extend(["-e", f"CONTAINER_ENCRYPTION_KEY={_DUMMY_CONT_KEY}"])
185181
run_cmd.extend(["-e", "WEBSITE_PLACEHOLDER_MODE=1"])
186-
run_cmd.extend(["-e", "PYTHON_ISOLATE_WORKER_DEPENDENCIES=1"])
187182
run_cmd.extend(["-v", f'{worker_path}:{container_worker_path}'])
188-
run_cmd.extend(["-v", f'{library_path}:{container_library_path}'])
189183

190184
for key, value in env.items():
191185
run_cmd.extend(["-e", f"{key}={value}"])
@@ -295,7 +289,8 @@ def __enter__(self):
295289
def __exit__(self, exc_type, exc_value, traceback):
296290
logs = self.get_container_logs()
297291
self.safe_kill_container()
298-
shutil.rmtree(os.path.join(tempfile.gettempdir(), _FUNC_FILE_NAME))
292+
shutil.rmtree(os.path.join(tempfile.gettempdir(), _FUNC_FILE_NAME),
293+
ignore_errors=True)
299294

300295
if traceback:
301296
print(f'Test failed with container logs: {logs}',

0 commit comments

Comments
 (0)