Skip to content

Commit

Permalink
ci: added google cloud steps to tekton pipeline.
Browse files Browse the repository at this point in the history
Signed-off-by: Cagri Yonca <cagriyonca@gmail.com>
  • Loading branch information
CagriYonca committed Aug 23, 2024
1 parent 5e34e95 commit 9118791
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 16 deletions.
1 change: 1 addition & 0 deletions .tekton/github-pr-pipeline.yaml.part
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
- unittest-cassandra
- unittest-couchbase
- unittest-gevent-starlette
- unittest-googlecloud
taskRef:
kind: Task
name: github-set-status
Expand Down
14 changes: 14 additions & 0 deletions .tekton/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,17 @@ spec:
workspaces:
- name: task-pvc
workspace: python-tracer-ci-pipeline-pvc
- name: unittest-googlecloud
runAfter:
- clone
matrix:
params:
- name: imageDigest
value:
# 3.9.18-bookworm
- "sha256:530d4ba717be787c0e2d011aa107edac6d721f8c06fe6d44708d4aa5e9bc5ec9"
taskRef:
name: python-tracer-unittest-googlecloud-task
workspaces:
- name: task-pvc
workspace: python-tracer-ci-pipeline-pvc
10 changes: 8 additions & 2 deletions .tekton/run_unittests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ PYTHON_MINOR_VERSION="$(echo "${PYTHON_VERSION}" | cut -d'.' -f 2)"
case "${TEST_CONFIGURATION}" in
default)
case "${PYTHON_MINOR_VERSION}" in
10 | 11)
10)
export REQUIREMENTS='requirements-310.txt' ;;
11)
export REQUIREMENTS='requirements-311.txt' ;;
12)
export REQUIREMENTS='requirements-312.txt' ;;
13)
Expand All @@ -40,9 +42,13 @@ 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' ;;
*)
echo "ERROR \$TEST_CONFIGURATION='${TEST_CONFIGURATION}' is unsupported " \
"not in (default|cassandra|couchbase|gevent_starlette)" >&2
"not in (default|cassandra|couchbase|gevent_starlette|googlecloud)" >&2
exit 3 ;;
esac

Expand Down
21 changes: 21 additions & 0 deletions .tekton/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ spec:
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: python-tracer-unittest-googlecloud-task
spec:
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
27 changes: 15 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import sys
import pytest

if importlib.util.find_spec('celery'):
pytest_plugins = ("celery.contrib.pytest", )
if importlib.util.find_spec("celery"):
pytest_plugins = ("celery.contrib.pytest",)

# Set our testing flags
os.environ["INSTANA_TEST"] = "true"
Expand All @@ -20,7 +20,7 @@

# Cassandra and gevent tests are run in dedicated jobs on CircleCI and will
# be run explicitly. (So always exclude them here)
if not os.environ.get("CASSANDRA_TEST" ):
if not os.environ.get("CASSANDRA_TEST"):
collect_ignore_glob.append("*test_cassandra*")

if not os.environ.get("COUCHBASE_TEST"):
Expand All @@ -38,6 +38,10 @@
# tests/opentracing/test_ot_span.py::TestOTSpan::test_stacks
# TODO: Remove that once we find a workaround or DROP opentracing!

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*")
Expand All @@ -64,22 +68,21 @@
collect_ignore_glob.append("*test_grpcio*")
collect_ignore_glob.append("*test_sanic*")

@pytest.fixture(scope='session')

@pytest.fixture(scope="session")
def celery_config():
return {
'broker_connection_retry_on_startup': True,
'broker_url': 'redis://localhost:6379',
'result_backend': 'redis://localhost:6379'
"broker_connection_retry_on_startup": True,
"broker_url": "redis://localhost:6379",
"result_backend": "redis://localhost:6379",
}


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def celery_enable_logging():
return True


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def celery_includes():
return {
'tests.frameworks.test_celery'
}
return {"tests.frameworks.test_celery"}
2 changes: 0 additions & 2 deletions tests/requirements-312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ fastapi>=0.92.0
flask>=2.3.2
markupsafe>=2.1.0
grpcio>=1.37.1
google-cloud-pubsub>=2.0.0
google-cloud-storage<=2.14.0
lxml>=4.9.2
mock>=4.0.3
moto>=4.1.2
Expand Down

0 comments on commit 9118791

Please sign in to comment.