Skip to content

Commit

Permalink
Addind e2e tests for python (#1564)
Browse files Browse the repository at this point in the history
Co-authored-by: Tamir David <tamirdavid@Tamirs-MacBook-Pro.local>
  • Loading branch information
tamirdavid1 and Tamir David authored Oct 6, 2024
1 parent 0c36e06 commit a1c85a9
Show file tree
Hide file tree
Showing 42 changed files with 1,467 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules
.DS_Store
go.work.sum
cli/odigos
.venv
.venv
**/__pycache__/
**/*.pyc
1 change: 1 addition & 0 deletions docs/instrumentations/python/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The following Python modules will be auto instrumented by Odigos:
### HTTP Frameworks
- [`asgi`](https://pypi.org/project/asgiref/) versions `asgiref >= 3.0.0, < 4.0.0`
- [`django`](https://pypi.org/project/Django/) versions `django >= 1.10.0`
<Info>Please note that for Django instrumentation to work, you need to set the [DJANGO_SETTINGS_MODULE](https://docs.djangoproject.com/en/5.1/topics/settings/#envvar-DJANGO_SETTINGS_MODULE) environment variable. Make sure to set this in your Kubernetes manifest or Dockerfile to ensure proper configuration.</Info>
- [`fastapi`](https://pypi.org/project/fastapi/) versions `fastapi >= 0.58.0, < 0.59.0`, `fastapi-slim >= 0.111.0, < 0.112.0`
- [`flask`](https://pypi.org/project/Flask/) versions `flask >= 1.0.0`
- [`pyramid`](https://pypi.org/project/pyramid/) versions `pyramid >= 1.7.0`
Expand Down
1 change: 0 additions & 1 deletion tests/common/traceql_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function process_yaml_file() {
# if num_of_traces not equal to expected_count
if [ "$num_of_traces" -ne "$expected_count" ]; then
echo "Test FAILED: expected $expected_count got $num_of_traces"
echo "$response" | jq
exit 1
else
echo "Test PASSED"
Expand Down
17 changes: 11 additions & 6 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,25 @@ When tests fail, and it's related to some traceql query not succeeding, it can b
- Install grafana with helm:
```bash
helm install -n traces grafana grafana/grafana --set adminPassword='odigos'
```
helm install -n traces grafana grafana/grafana \
--set "env.GF_AUTH_ANONYMOUS_ENABLED=true" \
--set "env.GF_AUTH_ANONYMOUS_ORG_ROLE=Admin" \
--set "datasources.datasources\.yaml.apiVersion=1" \
--set "datasources.datasources\.yaml.datasources[0].name=Tempo" \
--set "datasources.datasources\.yaml.datasources[0].type=tempo" \
--set "datasources.datasources\.yaml.datasources[0].url=http://e2e-tests-tempo:3100" \
--set "datasources.datasources\.yaml.datasources[0].access=proxy" \
--set "datasources.datasources\.yaml.datasources[0].isDefault=true"```
- Port forward to the grafana service:
```bash
kubectl port-forward svc/grafana 3080:80 -n traces
```
- Browse to `http://localhost:3080` and login with `admin` and `odigos`.
- Add tempo as a datasource, by going to `Connections -> Data Sources -> Add data source` and selecting `Tempo` as the type. Set the URL to `http://e2e-tests-tempo:3100` and save.
- Browse to `http://localhost:3080/explore`.
- In grafana left side menu, go to `Explore` and select the tempo datasource. You can now write queries, run them, and see the traces that are stored in tempo to troubleshoot your test issues. example query:
- You can now write queries, run them, and see the traces that are stored in tempo to troubleshoot your test issues. example query:
```
{resource.service.name = "coupon"}
Expand Down
78 changes: 78 additions & 0 deletions tests/e2e/workload-lifecycle/01-assert-apps-installed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,82 @@ status:
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: python-latest-version
namespace: default
spec:
containers:
- env:
- name: DJANGO_SETTINGS_MODULE
(value != null): true
status:
containerStatuses:
- name: python-latest-version
ready: true
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: python-alpine
namespace: default
spec:
containers:
- env:
- name: DJANGO_SETTINGS_MODULE
(value != null): true
- name: PYTHONPATH
(value != null): true
status:
containerStatuses:
- name: python-alpine
ready: true
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: python-min-version
namespace: default
spec:
containers:
- env:
- name: DJANGO_SETTINGS_MODULE
(value != null): true
status:
containerStatuses:
- name: python-min-version
ready: true
restartCount: 0
started: true
phase: Running
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: python-not-supported
namespace: default
spec:
containers:
- env:
- name: DJANGO_SETTINGS_MODULE
(value != null): true
status:
containerStatuses:
- name: python-not-supported
ready: true
restartCount: 0
started: true
phase: Running
---
106 changes: 105 additions & 1 deletion tests/e2e/workload-lifecycle/01-assert-instrumented.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,108 @@ status:
reason: InstrumentationDeviceApplied
status: "True"
type: AppliedInstrumentationDevice
---
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
namespace: default
name: deployment-python-alpine
spec:
runtimeDetails:
- containerName: python-alpine
status:
conditions:
- message: "Instrumentation device applied successfully"
observedGeneration: 1
reason: InstrumentationDeviceApplied
status: "True"
type: AppliedInstrumentationDevice
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
namespace: default
name: deployment-python-latest-version
status:
conditions:
- message: "Instrumentation device applied successfully"
observedGeneration: 1
reason: InstrumentationDeviceApplied
status: "True"
type: AppliedInstrumentationDevice
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
namespace: default
name: deployment-python-min-version
status:
conditions:
- message: "Instrumentation device applied successfully"
observedGeneration: 1
reason: InstrumentationDeviceApplied
status: "True"
type: AppliedInstrumentationDevice
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
namespace: default
name: deployment-python-not-supported
status:
conditions:
- message: "python runtime version not supported by OpenTelemetry SDK. Found: 3.6.15, supports: 3.8.0"
observedGeneration: 1
reason: RuntimeVersionNotSupported
status: "False"
type: AppliedInstrumentationDevice


---
apiVersion: odigos.io/v1alpha1
kind: InstrumentationInstance
metadata:
namespace: default
labels:
instrumented-app: deployment-python-alpine
status:
healthy: true
identifyingAttributes:
- key: service.instance.id
(value != null): true
- key: process.pid
(value != null): true
- key: telemetry.sdk.language
value: python
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentationInstance
metadata:
namespace: default
labels:
instrumented-app: deployment-python-latest-version
status:
healthy: true
identifyingAttributes:
- key: service.instance.id
(value != null): true
- key: process.pid
(value != null): true
- key: telemetry.sdk.language
value: python
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentationInstance
metadata:
namespace: default
labels:
instrumented-app: deployment-python-min-version
status:
healthy: true
identifyingAttributes:
- key: service.instance.id
(value != null): true
- key: process.pid
(value != null): true
- key: telemetry.sdk.language
value: python
73 changes: 72 additions & 1 deletion tests/e2e/workload-lifecycle/01-assert-runtime-detected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,75 @@ spec:
runtimeDetails:
- containerName: java-old-version
language: java
---
---
## Python
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-python-alpine
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: python-alpine
spec:
runtimeDetails:
- containerName: python-alpine
envVars:
- name: PYTHONPATH
value: "/app"
language: python
runtimeVersion: 3.10.15
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-python-latest-version
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: python-latest-version
spec:
runtimeDetails:
- containerName: python-latest-version
language: python
(runtimeVersion != null): true
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-python-min-version
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: python-min-version
spec:
runtimeDetails:
- containerName: python-min-version
language: python
runtimeVersion: 3.8.0
---
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-python-not-supported
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: python-not-supported
spec:
runtimeDetails:
- containerName: python-not-supported
language: python
runtimeVersion: 3.6.15
Loading

0 comments on commit a1c85a9

Please sign in to comment.