|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -# import asyncio |
16 | | -# import os |
17 | | -# import pathlib |
18 | | -# import random |
19 | | -# import socket |
20 | | -# import subprocess |
21 | | -# import time |
22 | | - |
23 | 15 | # import pytest |
24 | 16 | import requests |
25 | 17 | from testing_support.db_settings import azurefunction_settings |
|
28 | 20 | # validate_transaction_metrics, |
29 | 21 | # ) |
30 | 22 |
|
31 | | -# from urllib.request import urlopen |
32 | | - |
33 | | -# from azure_functions_worker import main |
34 | | - |
35 | | -# from newrelic.api.web_transaction import web_transaction |
36 | | - |
37 | | -# from azure_functions_worker.main import start_async |
38 | | -# from azure_functions_worker.utils.dependency import DependencyManager |
39 | | - |
40 | | - |
41 | | -# from testing_support.util import instance_hostname |
42 | | - |
43 | 23 | DB_SETTINGS = azurefunction_settings()[0] |
44 | 24 | AZURE_HOST = DB_SETTINGS["host"] |
45 | 25 | AZURE_PORT = DB_SETTINGS["port"] |
@@ -113,116 +93,3 @@ def test_ping(): |
113 | 93 | # assert response.status_code == 200 |
114 | 94 | # assert response.text == "Hello, Reli!" |
115 | 95 | # assert response.headers["Content-Type"] == "text/plain" |
116 | | - |
117 | | - |
118 | | -# ATTEMPT #2 |
119 | | - |
120 | | - |
121 | | -# def available_port(): |
122 | | -# """ |
123 | | -# Get an available port on the local machine. |
124 | | -# """ |
125 | | -# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
126 | | -# sock.bind(("", 0)) |
127 | | -# port = sock.getsockname()[1] |
128 | | -# sock.close() |
129 | | -# return port |
130 | | - |
131 | | - |
132 | | -# # @pytest.fixture(autouse=True, scope="module") |
133 | | -# # def func_start_storage_emulator(): |
134 | | -# # # Emulate storage |
135 | | -# # subprocess.Popen(["azurite", "--tableHost", "127.0.0.1"]) |
136 | | - |
137 | | - |
138 | | -# # PORT = available_port() |
139 | | -# PORT = 7071 |
140 | | - |
141 | | - |
142 | | -# # @validate_transaction_metrics( |
143 | | -# # "function_app:basic_page", |
144 | | -# # group="AzureFunction", |
145 | | -# # # scoped_metrics=_test_application_index_scoped_metrics |
146 | | -# # ) |
147 | | -# # @pytest.fixture(autouse=True, scope="module") |
148 | | -# def func_start_dispatcher(): |
149 | | -# # azure_function_command = os.path.join(os.environ["TOX_ENV_DIR"], "bin", "func") |
150 | | -# # azure_function_command = "func" |
151 | | - |
152 | | -# # cmd = ["cd", f"{os.getcwd()}/tests/framework_azure/", "&&", "func", "start"] #, "--port", str(PORT)] |
153 | | -# cmd = ["func", "start"] # , "--port", str(PORT)] |
154 | | -# # cmd = ["cd", f"{os.environ.get('TOX_ENV_DIR')}/tests/framework_azure", "&&", "func", "start", "--port", str(PORT)] |
155 | | -# cmd_str = " ".join(cmd) |
156 | | -# # cmd = f"cd tests/framework_azure && newrelic-admin run-program func start --port {str(PORT)}" |
157 | | - |
158 | | -# try: |
159 | | -# # runs but on different process from instrumentation. |
160 | | -# # We need to do this, but somehow on the same process |
161 | | -# # subprocess.Popen(cmd_str, shell=True, env=os.environ, cwd=f"{os.getcwd()}") # nosec # also passes but diff process |
162 | | -# subprocess.Popen(cmd, env=os.environ, cwd=f"{os.getcwd()}") # passes, but diff process |
163 | | -# # subprocess.run(cmd, shell=True, env=os.environ) # nosec |
164 | | -# # os.system(cmd_str) # nosec |
165 | | - |
166 | | -# except Exception as e: |
167 | | -# print(f"Error: {e}") |
168 | | - |
169 | | - |
170 | | -# # @validate_transaction_metrics( |
171 | | -# # "function_app:basic_page", |
172 | | -# # group="AzureFunction", |
173 | | -# # # scoped_metrics=_test_application_index_scoped_metrics |
174 | | -# # ) |
175 | | -# def test_basic_function(): |
176 | | -# # @validate_transaction_metrics( |
177 | | -# # "function_app:basic_page", |
178 | | -# # group="AzureFunction", |
179 | | -# # # scoped_metrics=_test_application_index_scoped_metrics |
180 | | -# # ) |
181 | | -# # def _test(): |
182 | | -# # func_start_dispatcher() |
183 | | - |
184 | | -# # _test() |
185 | | -# func_start_dispatcher() |
186 | | -# # Wait until the connection is established before making the request. |
187 | | -# for _ in range(50): |
188 | | -# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
189 | | -# try: |
190 | | -# sock.connect(("127.0.0.1", PORT)) |
191 | | -# sock.close() |
192 | | -# break |
193 | | -# except (socket.error, ConnectionRefusedError) as e: |
194 | | -# pass |
195 | | - |
196 | | -# time.sleep(0.5) |
197 | | - |
198 | | -# response = requests.get(f"http://127.0.0.1:{PORT}/basic?user=Reli") |
199 | | -# assert response.status_code == 200 |
200 | | -# assert response.text == "Hello, Reli!" |
201 | | -# assert response.headers["Content-Type"] == "text/plain" |
202 | | -# # response = requests.get(f"http://127.0.0.1:{PORT}/basic?user=Bradlington") |
203 | | -# # assert response.status_code == 200 |
204 | | -# # assert response.text == "Hello, Bradlington!" |
205 | | -# # assert response.headers["Content-Type"] == "text/plain" |
206 | | - |
207 | | - |
208 | | -# def get_open_port(): |
209 | | -# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
210 | | -# s.bind(("", 0)) |
211 | | -# port = s.getsockname()[1] |
212 | | -# s.close() |
213 | | -# return port |
214 | | - |
215 | | - |
216 | | -# # DependencyManager.initialize() |
217 | | -# # DependencyManager.use_worker_dependencies() |
218 | | - |
219 | | -# @pytest.fixture(autouse=True, scope="module") |
220 | | -# def target_dispatcher(): |
221 | | -# return asyncio.run( |
222 | | -# start_async( |
223 | | -# host="127.0.0.1", |
224 | | -# port=get_open_port(), |
225 | | -# worker_id="deadbeef-cafe-10c8-ba11-50de7ec7ab1e", |
226 | | -# request_id="ba5eba11-ba5e-bead-5elf-affab1e0babe", |
227 | | -# ) |
228 | | -# ) |
0 commit comments