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 26, 2024
1 parent 5e34e95 commit fdf4e6b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 31 deletions.
30 changes: 15 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
- store-pytest-results
- store-coverage-report

py311-googlecloud:
py311googlecloud:
docker:
- image: cimg/python:3.11.4
- image: vanmoof/pubsub-emulator
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
- store-pytest-results
- store-coverage-report

py312-googlecloud:
py312googlecloud:
docker:
- image: cimg/python:3.12.0
- image: vanmoof/pubsub-emulator
Expand Down Expand Up @@ -294,7 +294,7 @@ jobs:
- store-pytest-results
- store-coverage-report

py39-couchbase:
py39couchbase:
docker:
- image: cimg/python:3.9.17
- image: couchbase/server-sandbox:5.5.0
Expand All @@ -310,7 +310,7 @@ jobs:
- store-pytest-results
- store-coverage-report

py39-cassandra:
py39cassandra:
docker:
- image: cimg/python:3.9.17
- image: cassandra:3.11
Expand Down Expand Up @@ -339,7 +339,7 @@ jobs:
- store-pytest-results
- run_sonarqube

py39-gevent_starlette:
py39gevent_starlette:
docker:
- image: cimg/python:3.9.17
working_directory: ~/repo
Expand All @@ -363,11 +363,11 @@ workflows:
- python311
- python312
- python313
- py39-cassandra
- py39-couchbase
- py39-gevent_starlette
- py311-googlecloud
- py312-googlecloud
- py39cassandra
- py39couchbase
- py39gevent_starlette
- py311googlecloud
- py312googlecloud
- final_job:
requires:
- python38
Expand All @@ -376,8 +376,8 @@ workflows:
- python311
- python312
- python313
- py39-cassandra
- py39-couchbase
- py39-gevent_starlette
- py311-googlecloud
- py312-googlecloud
- py39cassandra
- py39couchbase
- py39gevent_starlette
- py311googlecloud
- py312googlecloud
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
16 changes: 16 additions & 0 deletions .tekton/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,19 @@ spec:
workspaces:
- name: task-pvc
workspace: python-tracer-ci-pipeline-pvc
- name: unittest-googlecloud
runAfter:
- clone
matrix:
params:
- name: imageDigest
value:
# 3.11.9-bookworm
- "sha256:0c2928128a96e544a1ee248e50ee8ecbe840bf48ef5a49065812e3d06b6e1bcc"
# 3.12.4-bookworm
- "sha256:83f5f8714b6881d3e0e91023d9fe9e43aa6ad5a04e9f9a94ee180b18b021c72a"
taskRef:
name: python-tracer-unittest-googlecloud-task
workspaces:
- name: task-pvc
workspace: python-tracer-ci-pipeline-pvc
6 changes: 5 additions & 1 deletion .tekton/run_unittests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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
24 changes: 23 additions & 1 deletion .tekton/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,34 @@ spec:
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: python-tracer-unittest-default-task
name: python-tracer-unittest-googlecloud-task
spec:
sidecars:
- name: google-cloud-pubsub
# vanmoof/pubsub-emulator:latest
image: vanmoof/pubsub-emulator@sha256:ff71206d65589b58a8b6928c35349a58dbfd7f20eb2dc7822e0f32e5c40791c8
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:
sidecars:
- name: mariadb
# mariadb:11.3.2
image: mariadb@sha256:851f05fe1e4cb290442c1b12b7108436a33fd8f6a733d4989950322d06d45c65
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 fdf4e6b

Please sign in to comment.