Skip to content

Commit 5e1cc9d

Browse files
committed
Squashed commit of the following:
commit c2d4629 Author: Timothy Pansino <[email protected]> Date: Wed May 10 15:59:13 2023 -0700 Add required option for tox v4 (#795) * Add required option for tox v4 * Update tox in GHA * Remove py27 no-cache-dir commit a963649 Author: Hannah Stepanek <[email protected]> Date: Tue May 9 10:46:39 2023 -0700 Run coverage around pytest (#813) * Run coverage around pytest * Trigger tests * Fixup * Add redis client_no_touch to ignore list * Temporarily remove kafka from coverage * Remove coverage for old libs commit 3d82845 Author: Lalleh Rafeei <[email protected]> Date: Wed May 3 14:50:30 2023 -0700 Omit some frameworks from coverage analysis (#810) * Omit some frameworks from coverage analysis * Remove commas * Change format of omit * Add relative_files option to coverage * Add absolute directory * Add envsitepackagedir * Add coveragerc file * Add codecov.yml * [Mega-Linter] Apply linters fixes * Revert coveragerc file settings * Add files in packages and more frameworks * Remove commented line --------- Co-authored-by: lrafeei <[email protected]> Co-authored-by: Hannah Stepanek <[email protected]> commit fd0fa35 Author: Uma Annamalai <[email protected]> Date: Tue May 2 10:55:36 2023 -0700 Add testing for genshi and mako. (#799) * Add testing for genshi and mako. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: umaannamalai <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit be4fb3d Author: Lalleh Rafeei <[email protected]> Date: Mon May 1 16:01:09 2023 -0700 Add tests for Waitress (#797) * Change import format * Initial commit * Add more tests to adapter_waitress * Remove commented out code * [Mega-Linter] Apply linters fixes * Add assertions to all tests * Add more NR testing to waitress --------- Co-authored-by: lrafeei <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 7103506 Author: Hannah Stepanek <[email protected]> Date: Mon May 1 14:12:31 2023 -0700 Add tests for pyodbc (#796) * Add tests for pyodbc * Move imports into tests to get import coverage * Fixup: remove time import * Trigger tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 363122a Author: Hannah Stepanek <[email protected]> Date: Mon May 1 13:34:35 2023 -0700 Pin virtualenv, fix pip arg deprecation & disable kafka tests (#803) * Pin virtualenv * Fixup: use 20.21.1 instead * Replace install-options with config-settings See pypa/pip#11358. * Temporarily disable kafka tests
1 parent dc81a50 commit 5e1cc9d

File tree

17 files changed

+588
-266
lines changed

17 files changed

+588
-266
lines changed

.github/actions/setup-python-matrix/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ runs:
4747
shell: bash
4848
run: |
4949
python3.10 -m pip install -U pip
50-
python3.10 -m pip install -U wheel setuptools 'tox<4' virtualenv!=20.0.24
50+
python3.10 -m pip install -U wheel setuptools tox 'virtualenv<20.22.0'

.github/workflows/tests.yml

Lines changed: 80 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- elasticsearchserver08
3939
- gearman
4040
- grpc
41-
- kafka
41+
#- kafka
4242
- libcurl
4343
- memcached
4444
- mongodb
@@ -255,6 +255,14 @@ jobs:
255255
- uses: actions/checkout@v3
256256
- uses: ./.github/actions/setup-python-matrix
257257

258+
- name: Install odbc driver for postgresql
259+
run: |
260+
sudo apt-get update
261+
sudo sudo apt-get install odbc-postgresql
262+
sudo sed -i 's/Driver=psqlodbca.so/Driver=\/usr\/lib\/x86_64-linux-gnu\/odbc\/psqlodbca.so/g' /etc/odbcinst.ini
263+
sudo sed -i 's/Driver=psqlodbcw.so/Driver=\/usr\/lib\/x86_64-linux-gnu\/odbc\/psqlodbcw.so/g' /etc/odbcinst.ini
264+
sudo sed -i 's/Setup=libodbcpsqlS.so/Setup=\/usr\/lib\/x86_64-linux-gnu\/odbc\/libodbcpsqlS.so/g' /etc/odbcinst.ini
265+
258266
- name: Get Environments
259267
id: get-envs
260268
run: |
@@ -534,77 +542,77 @@ jobs:
534542
path: ./**/.coverage.*
535543
retention-days: 1
536544

537-
kafka:
538-
env:
539-
TOTAL_GROUPS: 4
540-
541-
strategy:
542-
fail-fast: false
543-
matrix:
544-
group-number: [1, 2, 3, 4]
545-
546-
runs-on: ubuntu-20.04
547-
timeout-minutes: 30
548-
549-
services:
550-
zookeeper:
551-
image: bitnami/zookeeper:3.7
552-
env:
553-
ALLOW_ANONYMOUS_LOGIN: yes
554-
555-
ports:
556-
- 2181:2181
557-
558-
kafka:
559-
image: bitnami/kafka:3.2
560-
ports:
561-
- 8080:8080
562-
- 8081:8081
563-
env:
564-
ALLOW_PLAINTEXT_LISTENER: yes
565-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
566-
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
567-
KAFKA_CFG_LISTENERS: L1://:8080,L2://:8081
568-
KAFKA_CFG_ADVERTISED_LISTENERS: L1://127.0.0.1:8080,L2://kafka:8081,
569-
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: L1:PLAINTEXT,L2:PLAINTEXT
570-
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: L2
571-
572-
steps:
573-
- uses: actions/checkout@v3
574-
- uses: ./.github/actions/setup-python-matrix
575-
576-
# Special case packages
577-
- name: Install librdkafka-dev
578-
run: |
579-
# Use lsb-release to find the codename of Ubuntu to use to install the correct library name
580-
sudo apt-get update
581-
sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
582-
sudo apt-get install -y wget gnupg2 software-properties-common
583-
sudo wget -qO - https://packages.confluent.io/deb/7.2/archive.key | sudo apt-key add -
584-
sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
585-
sudo apt-get update
586-
sudo apt-get install -y librdkafka-dev/$(lsb_release -c | cut -f 2)
587-
588-
- name: Get Environments
589-
id: get-envs
590-
run: |
591-
echo "::set-output name=envs::$(tox -l | grep "^${{ github.job }}\-" | ./.github/workflows/get-envs.py)"
592-
env:
593-
GROUP_NUMBER: ${{ matrix.group-number }}
594-
595-
- name: Test
596-
run: |
597-
tox -vv -e ${{ steps.get-envs.outputs.envs }}
598-
env:
599-
TOX_PARALLEL_NO_SPINNER: 1
600-
PY_COLORS: 0
601-
602-
- name: Upload Coverage Artifacts
603-
uses: actions/upload-artifact@v3
604-
with:
605-
name: coverage-${{ github.job }}-${{ strategy.job-index }}
606-
path: ./**/.coverage.*
607-
retention-days: 1
545+
#kafka:
546+
# env:
547+
# TOTAL_GROUPS: 4
548+
549+
# strategy:
550+
# fail-fast: false
551+
# matrix:
552+
# group-number: [1, 2, 3, 4]
553+
554+
# runs-on: ubuntu-20.04
555+
# timeout-minutes: 30
556+
557+
# services:
558+
# zookeeper:
559+
# image: bitnami/zookeeper:3.7
560+
# env:
561+
# ALLOW_ANONYMOUS_LOGIN: yes
562+
563+
# ports:
564+
# - 2181:2181
565+
566+
# kafka:
567+
# image: bitnami/kafka:3.2
568+
# ports:
569+
# - 8080:8080
570+
# - 8081:8081
571+
# env:
572+
# ALLOW_PLAINTEXT_LISTENER: yes
573+
# KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
574+
# KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
575+
# KAFKA_CFG_LISTENERS: L1://:8080,L2://:8081
576+
# KAFKA_CFG_ADVERTISED_LISTENERS: L1://127.0.0.1:8080,L2://kafka:8081,
577+
# KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: L1:PLAINTEXT,L2:PLAINTEXT
578+
# KAFKA_CFG_INTER_BROKER_LISTENER_NAME: L2
579+
580+
# steps:
581+
# - uses: actions/checkout@v3
582+
# - uses: ./.github/actions/setup-python-matrix
583+
584+
# # Special case packages
585+
# - name: Install librdkafka-dev
586+
# run: |
587+
# # Use lsb-release to find the codename of Ubuntu to use to install the correct library name
588+
# sudo apt-get update
589+
# sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
590+
# sudo apt-get install -y wget gnupg2 software-properties-common
591+
# sudo wget -qO - https://packages.confluent.io/deb/7.2/archive.key | sudo apt-key add -
592+
# sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
593+
# sudo apt-get update
594+
# sudo apt-get install -y librdkafka-dev/$(lsb_release -c | cut -f 2)
595+
596+
# - name: Get Environments
597+
# id: get-envs
598+
# run: |
599+
# echo "::set-output name=envs::$(tox -l | grep "^${{ github.job }}\-" | ./.github/workflows/get-envs.py)"
600+
# env:
601+
# GROUP_NUMBER: ${{ matrix.group-number }}
602+
603+
# - name: Test
604+
# run: |
605+
# tox -vv -e ${{ steps.get-envs.outputs.envs }}
606+
# env:
607+
# TOX_PARALLEL_NO_SPINNER: 1
608+
# PY_COLORS: 0
609+
610+
# - name: Upload Coverage Artifacts
611+
# uses: actions/upload-artifact@v3
612+
# with:
613+
# name: coverage-${{ github.job }}-${{ strategy.job-index }}
614+
# path: ./**/.coverage.*
615+
# retention-days: 1
608616

609617
mongodb:
610618
env:

codecov.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ignore:
2+
- "newrelic/packages/**/*"
3+
- "newrelic/packages/*"
4+
- "newrelic/hooks/adapter_meinheld.py"
5+
- "newrelic/hooks/adapter_flup.py"
6+
- "newrelic/hooks/component_piston.py"
7+
- "newrelic/hooks/datastore_pyelasticsearch.py"
8+
- "newrelic/hooks/external_pywapi.py"
9+
- "newrelic/hooks/external_dropbox.py"
10+
- "newrelic/hooks/external_facepy.py"
11+
- "newrelic/hooks/external_xmlrpclib.py"
12+
- "newrelic/hooks/framework_pylons.py"
13+
- "newrelic/hooks/framework_web2py.py"
14+
- "newrelic/hooks/middleware_weberror.py"
15+
- "newrelic/hooks/framework_webpy.py"
16+
- "newrelic/hooks/database_oursql.py"
17+
- "newrelic/hooks/database_psycopg2ct.py"
18+
- "newrelic/hooks/datastore_umemcache.py"
19+
# Temporarily disable kafka
20+
- "newrelic/hooks/messagebroker_kafkapython.py"
21+
- "newrelic/hooks/messagebroker_confluentkafka.py"

newrelic/hooks/adapter_waitress.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import newrelic.api.wsgi_application
16-
import newrelic.api.in_function
15+
from newrelic.api.in_function import wrap_in_function
16+
from newrelic.api.wsgi_application import WSGIApplicationWrapper
17+
from newrelic.common.package_version_utils import get_package_version
1718

18-
def instrument_waitress_server(module):
1919

20-
def wrap_wsgi_application_entry_point(server, application,
21-
*args, **kwargs):
22-
application = newrelic.api.wsgi_application.WSGIApplicationWrapper(
23-
application)
20+
def instrument_waitress_server(module):
21+
def wrap_wsgi_application_entry_point(server, application, *args, **kwargs):
22+
dispatcher_details = ("Waitress", get_package_version("waitress"))
23+
application = WSGIApplicationWrapper(application, dispatcher=dispatcher_details)
2424
args = [server, application] + list(args)
2525
return (args, kwargs)
2626

27-
newrelic.api.in_function.wrap_in_function(module,
28-
'WSGIServer.__init__', wrap_wsgi_application_entry_point)
27+
wrap_in_function(module, "WSGIServer.__init__", wrap_wsgi_application_entry_point)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2010 New Relic, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from threading import Thread
16+
from time import sleep
17+
18+
from testing_support.sample_applications import (
19+
raise_exception_application,
20+
raise_exception_finalize,
21+
raise_exception_response,
22+
simple_app_raw,
23+
)
24+
from testing_support.util import get_open_port
25+
26+
27+
def sample_application(environ, start_response):
28+
path_info = environ.get("PATH_INFO")
29+
30+
if path_info.startswith("/raise-exception-application"):
31+
return raise_exception_application(environ, start_response)
32+
elif path_info.startswith("/raise-exception-response"):
33+
return raise_exception_response(environ, start_response)
34+
elif path_info.startswith("/raise-exception-finalize"):
35+
return raise_exception_finalize(environ, start_response)
36+
37+
return simple_app_raw(environ, start_response)
38+
39+
40+
def setup_application():
41+
port = get_open_port()
42+
43+
def run_wsgi():
44+
from waitress import serve
45+
46+
serve(sample_application, host="127.0.0.1", port=port)
47+
48+
wsgi_thread = Thread(target=run_wsgi)
49+
wsgi_thread.daemon = True
50+
wsgi_thread.start()
51+
52+
sleep(1)
53+
54+
return port

tests/adapter_waitress/conftest.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2010 New Relic, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
import webtest
17+
from testing_support.fixtures import ( # noqa: F401; pylint: disable=W0611
18+
collector_agent_registration_fixture,
19+
collector_available_fixture,
20+
)
21+
22+
_default_settings = {
23+
"transaction_tracer.explain_threshold": 0.0,
24+
"transaction_tracer.transaction_threshold": 0.0,
25+
"transaction_tracer.stack_trace_threshold": 0.0,
26+
"debug.log_data_collector_payloads": True,
27+
"debug.record_transaction_failure": True,
28+
}
29+
30+
collector_agent_registration = collector_agent_registration_fixture(
31+
app_name="Python Agent Test (Waitress)", default_settings=_default_settings
32+
)
33+
34+
35+
@pytest.fixture(autouse=True, scope="session")
36+
def target_application():
37+
import _application
38+
39+
port = _application.setup_application()
40+
return webtest.TestApp("http://localhost:%d" % port)

0 commit comments

Comments
 (0)