Skip to content

Commit

Permalink
combined requirement files into one file and updated pipelines
Browse files Browse the repository at this point in the history
Signed-off-by: Cagri Yonca <cagri@ibm.com>
  • Loading branch information
CagriYonca committed Oct 23, 2024
1 parent b4a9ee6 commit ded1ac2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 139 deletions.
40 changes: 1 addition & 39 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ commands:
run-tests-with-coverage-report:
parameters:
googlecloud:
default: ""
type: string
cassandra:
default: ""
type: string
Expand All @@ -59,7 +56,6 @@ commands:
CASSANDRA_TEST: "<<parameters.cassandra>>"
COUCHBASE_TEST: "<<parameters.couchbase>>"
GEVENT_STARLETTE_TEST: "<<parameters.gevent>>"
GOOGLE_CLOUD_TEST: "<<parameters.googlecloud>>"
command: |
. venv/bin/activate
coverage run --source=instana -m pytest -v --junitxml=test-results <<parameters.tests>>
Expand Down Expand Up @@ -214,21 +210,6 @@ jobs:
- store-pytest-results
- store-coverage-report

py311googlecloud:
docker:
- image: cimg/python:3.11.10
- image: vanmoof/pubsub-emulator
working_directory: ~/repo
steps:
- checkout
- pip-install-deps:
requirements: "tests/requirements-googlecloud.txt"
- run-tests-with-coverage-report:
googlecloud: "true"
tests: "tests/clients/test_google-cloud-*.py"
- store-pytest-results
- store-coverage-report

python312:
docker:
- image: cimg/python:3.12
Expand All @@ -254,21 +235,6 @@ jobs:
- store-pytest-results
- store-coverage-report

py312googlecloud:
docker:
- image: cimg/python:3.12.6
- image: vanmoof/pubsub-emulator
working_directory: ~/repo
steps:
- checkout
- pip-install-deps:
requirements: "tests/requirements-googlecloud.txt"
- run-tests-with-coverage-report:
googlecloud: "true"
tests: "tests/clients/test_google-cloud-*.py"
- store-pytest-results
- store-coverage-report

py312aws:
docker:
- image: cimg/python:3.12
Expand All @@ -284,7 +250,7 @@ jobs:

python313:
docker:
- image: python:3.13.0rc2-bookworm
- image: cimg/python:3.13
- image: cimg/postgres:14.12
environment:
POSTGRES_USER: root
Expand Down Expand Up @@ -379,8 +345,6 @@ workflows:
- py39cassandra
- py39couchbase
# - py39gevent_starlette
- py311googlecloud
- py312googlecloud
- py312aws
- final_job:
requires:
Expand All @@ -393,6 +357,4 @@ workflows:
- py39cassandra
- py39couchbase
# - py39gevent_starlette
- py311googlecloud
- py312googlecloud
- py312aws
3 changes: 1 addition & 2 deletions .tekton/github-pr-pipeline.yaml.part
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ spec:
- unittest-default
- unittest-cassandra
- unittest-couchbase
- unittest-gevent-starlette
- unittest-googlecloud
#- unittest-gevent-starlette
taskRef:
kind: Task
name: github-set-status
Expand Down
22 changes: 3 additions & 19 deletions .tekton/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ spec:
- "sha256:3cd9b520be95c671135ea1318f32be6912876024ee16d0f472669d3878801651"
# 3.12.6-bookworm
- "sha256:af6fa5c329d6bd6dec52855ccb8bb37c30fb8f00819953a035d49499e43b2c9b"
# 3.13.0rc2-bookworm
- "sha256:3aed70fd4585395e47c6005f0082b966151561f3c4070a3ed9d2fb594bbf44b8"
# 3.13.0-bookworm
- "sha256:feee4734fdc44cc09a3c9cdb72e05bb8ff7e964f64766bc1a68638b2c667cf35"
taskRef:
name: python-tracer-unittest-default-task
workspaces:
Expand Down Expand Up @@ -85,22 +85,6 @@ spec:
# workspaces:
# - name: task-pvc
# workspace: python-tracer-ci-pipeline-pvc
- name: unittest-googlecloud
runAfter:
- clone
matrix:
params:
- name: imageDigest
value:
# 3.11.10-bookworm
- "sha256:3cd9b520be95c671135ea1318f32be6912876024ee16d0f472669d3878801651"
# 3.12.6-bookworm
- "sha256:af6fa5c329d6bd6dec52855ccb8bb37c30fb8f00819953a035d49499e43b2c9b"
taskRef:
name: python-tracer-unittest-googlecloud-task
workspaces:
- name: task-pvc
workspace: python-tracer-ci-pipeline-pvc
- name: unittest-aws
runAfter:
- clone
Expand All @@ -111,7 +95,7 @@ spec:
# 3.12.6-bookworm
- "sha256:af6fa5c329d6bd6dec52855ccb8bb37c30fb8f00819953a035d49499e43b2c9b"
taskRef:
name: python-tracer-unittest-googlecloud-task
name: python-tracer-unittest-aws-task
workspaces:
- name: task-pvc
workspace: python-tracer-ci-pipeline-pvc
6 changes: 1 addition & 5 deletions .tekton/run_unittests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ gevent_starlette)
export REQUIREMENTS='requirements-gevent-starlette.txt'
export TESTS=('tests/frameworks/test_gevent.py' 'tests/frameworks/test_starlette.py')
export GEVENT_STARLETTE_TEST='true' ;;
googlecloud)
export REQUIREMENTS='requirements-googlecloud.txt'
export TESTS=('tests/clients/test_google-cloud-storage.py' 'tests/clients/test_google-cloud-pubsub.py')
export GOOGLE_CLOUD_TEST='true' ;;
aws)
export REQUIREMENTS='requirements.txt'
export TESTS=('tests_aws') ;;
*)
echo "ERROR \$TEST_CONFIGURATION='${TEST_CONFIGURATION}' is unsupported " \
"not in (default|cassandra|couchbase|gevent_starlette|googlecloud)" >&2
"not in (default|cassandra|couchbase|gevent_starlette)" >&2
exit 3 ;;
esac

Expand Down
31 changes: 0 additions & 31 deletions .tekton/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,6 @@ spec:
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: python-tracer-unittest-googlecloud-task
spec:
sidecars:
- name: google-cloud-pubsub
# vanmoof/pubsub-emulator:latest
image: vanmoof/pubsub-emulator@sha256:ff71206d65589b58a8b6928c35349a58dbfd7f20eb2dc7822e0f32e5c40791c8
env:
- name: PUBSUB_EMULATOR_HOST
value: 0.0.0.0:8085
ports:
- containerPort: 8085
hostPort: 8085
params:
- name: imageDigest
type: string
workspaces:
- name: task-pvc
mountPath: /workspace
steps:
- name: unittest
image: python@$(params.imageDigest)
env:
- name: TEST_CONFIGURATION
value: googlecloud
workingDir: /workspace/python-sensor/
command:
- /workspace/python-sensor/.tekton/run_unittests.sh
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: python-tracer-unittest-default-task
spec:
Expand Down
39 changes: 13 additions & 26 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,9 @@
# collect_ignore_glob.append("*test_gevent*")
# collect_ignore_glob.append("*test_starlette*")

if sys.version_info >= (3, 11):
if not os.environ.get("GOOGLE_CLOUD_TEST"):
collect_ignore_glob.append("*test_google-cloud*")

if sys.version_info >= (3, 13):
# TODO: Test Case failures for unknown reason:
collect_ignore_glob.append("*test_aiohttp_server*")
collect_ignore_glob.append("*test_celery*")
collect_ignore_glob.append("*frameworks/test_tornado_server*")

# Currently there is a runtime incompatibility caused by the library:
# `undefined symbol: _PyErr_WriteUnraisableMsg`
collect_ignore_glob.append("*boto3*")

# Currently there is a runtime incompatibility caused by the library:
# `undefined symbol: _PyInterpreterState_Get`
collect_ignore_glob.append("*test_psycopg2*")
collect_ignore_glob.append("*test_pep0249*")
collect_ignore_glob.append("*test_sqlalchemy*")

# Currently not installable dependencies because of 3.13 incompatibilities
collect_ignore_glob.append("*test_fastapi*")
collect_ignore_glob.append("*test_google-cloud-pubsub*")
collect_ignore_glob.append("*test_google-cloud-storage*")
collect_ignore_glob.append("*test_grpcio*")
collect_ignore_glob.append("*test_sanic*")


Expand Down Expand Up @@ -98,9 +76,10 @@ def trace_id() -> int:
def span_id() -> int:
return 6895521157646639861


@pytest.fixture
def hex_trace_id(trace_id:int) -> str:
# Using format_span_id() to return a 16-byte hexadecimal string, instead of
def hex_trace_id(trace_id: int) -> str:
# Using format_span_id() to return a 16-byte hexadecimal string, instead of
# the 32-byte hexadecimal string from format_trace_id().
return format_span_id(trace_id)

Expand All @@ -109,6 +88,7 @@ def hex_trace_id(trace_id:int) -> str:
def hex_span_id(span_id: int) -> str:
return format_span_id(span_id)


@pytest.fixture
def span_processor() -> StanRecorder:
rec = StanRecorder(HostAgent())
Expand Down Expand Up @@ -198,27 +178,34 @@ def prepare_and_report_data(monkeypatch, request):
else:
monkeypatch.setattr(BaseCollector, "prepare_and_report_data", always_true)


# Mocking HostAgent.is_agent_listening()
@pytest.fixture(autouse=True)
def is_agent_listening(monkeypatch, request) -> None:
"""Always return `True` for `HostAgent.is_agent_listening()`"""
if "original" in request.keywords:
# If using the `@pytest.mark.original` marker before the test function,
# uses the original HostAgent.is_agent_listening()
monkeypatch.setattr(HostAgent, "is_agent_listening", HostAgent.is_agent_listening)
monkeypatch.setattr(
HostAgent, "is_agent_listening", HostAgent.is_agent_listening
)
else:
monkeypatch.setattr(HostAgent, "is_agent_listening", always_true)


@pytest.fixture(autouse=True)
def lookup_agent_host(monkeypatch, request) -> None:
"""Always return `True` for `TheMachine.lookup_agent_host()`"""
if "original" in request.keywords:
# If using the `@pytest.mark.original` marker before the test function,
# uses the original TheMachine.lookup_agent_host()
monkeypatch.setattr(TheMachine, "lookup_agent_host", TheMachine.lookup_agent_host)
monkeypatch.setattr(
TheMachine, "lookup_agent_host", TheMachine.lookup_agent_host
)
else:
monkeypatch.setattr(TheMachine, "lookup_agent_host", always_true)


@pytest.fixture(autouse=True)
def announce_sensor(monkeypatch, request) -> None:
"""Always return `True` for `TheMachine.announce_sensor()`"""
Expand Down
7 changes: 0 additions & 7 deletions tests/requirements-googlecloud.txt

This file was deleted.

16 changes: 6 additions & 10 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ coverage>=5.5
Django>=4.2.4; python_version < "3.10"
Django>=5.0; python_version >= "3.10" and python_version < "3.12"
Django>=5.0a1; python_version >= "3.12" --pre
# Dependency orjson has no 3.13 support yet:
# https://github.com/matyasrichter/fastapi-injector/pull/31
fastapi>=0.92.0; python_version < "3.13"
fastapi>=0.115.0; python_version >= "3.13"
flask>=2.3.2
# grpc is not supported on 3.13 yet:
# https://github.com/grpc/grpc/issues/34922
grpcio>=1.37.1; python_version < "3.13"
# depends grpcio on 3.13
google-cloud-pubsub>=2.0.0; python_version < "3.12"
# depends grpcio on 3.13
google-cloud-storage>=1.24.0; python_version < "3.12"
gevent>=1.4.0
grpcio<1.67.0; python_version < "3.13"
grpcio>=1.67.0; python_version >= "3.13"
google-cloud-pubsub>=2.0.0
google-cloud-storage>=1.24.0
legacy-cgi>=2.6.1; python_version == "3.13"
lxml>=4.9.2
markupsafe>=2.1.0;python_version >= "3.10"
mock>=4.0.3
moto>=4.1.2
mysqlclient>=2.0.3
Expand Down

0 comments on commit ded1ac2

Please sign in to comment.