Skip to content

Commit 0f13f6b

Browse files
authored
Merge branch 'master' into dependabot/pip/cryptography-44.0.2
2 parents 3a8e754 + 6a7ec9e commit 0f13f6b

18 files changed

Lines changed: 382 additions & 10 deletions

File tree

‎.github/workflows/e2e-tests.yml‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# E2E Tests for analytics-python
2+
# Copy this file to: analytics-python/.github/workflows/e2e-tests.yml
3+
#
4+
# This workflow:
5+
# 1. Checks out the SDK and sdk-e2e-tests repos
6+
# 2. Installs the SDK and e2e-cli dependencies
7+
# 3. Runs the e2e test suite
8+
9+
name: E2E Tests
10+
11+
on:
12+
push:
13+
branches: [main, master]
14+
pull_request:
15+
branches: [main, master]
16+
workflow_dispatch:
17+
inputs:
18+
e2e_tests_ref:
19+
description: 'Branch or ref of sdk-e2e-tests to use'
20+
required: false
21+
default: 'main'
22+
23+
jobs:
24+
e2e-tests:
25+
# Skip on fork PRs where repo secrets aren't available
26+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout SDK
31+
uses: actions/checkout@v4
32+
with:
33+
path: sdk
34+
35+
- name: Checkout sdk-e2e-tests
36+
uses: actions/checkout@v4
37+
with:
38+
repository: segmentio/sdk-e2e-tests
39+
ref: ${{ inputs.e2e_tests_ref || 'main' }}
40+
token: ${{ secrets.E2E_TESTS_TOKEN }}
41+
path: sdk-e2e-tests
42+
43+
- name: Setup Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: '3.11'
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '20'
52+
53+
- name: Install Python SDK
54+
working-directory: sdk
55+
run: pip install -e .
56+
57+
- name: Install e2e-cli dependencies
58+
working-directory: sdk/e2e-cli
59+
run: pip install -e .
60+
61+
- name: Run E2E tests
62+
working-directory: sdk-e2e-tests
63+
run: |
64+
./scripts/run-tests.sh \
65+
--sdk-dir "${{ github.workspace }}/sdk/e2e-cli" \
66+
--cli "e2e-cli"
67+
68+
- name: Upload test results
69+
if: always()
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: e2e-test-results
73+
path: sdk-e2e-tests/test-results/
74+
if-no-files-found: ignore

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ build
1010
.vscode/
1111
.idea/
1212
.python-version
13+
.venv
14+
.DS_Store

‎HISTORY.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 2.3.5 / 2025-11-18
2+
- Fix for Github Issue #516
3+
- Fix for Github Issue #515
4+
- Fix for Github Issue #493
5+
- Updated the version to 2.3.5
6+
- Enhanced retry logic in segment/analytics/consumer.py by adding detailed debug logs for each retry attempt and logging an error when all retries are exhausted.
7+
- Moved the return success out of the finally block in segment/analytics/consumer.py at Line 84.
8+
- Removed redundant error logging in segment/analytics/request.py to avoid duplicate logs when exceptions are raised.
9+
110
# 2.3.4 / 2025-2-24
211
- Fix for proxy values not being used
312

‎e2e-cli/.env‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
APP_NAME='e2e-cli'
2+
DEBUG_MODE = False
3+
SEND_EVENTS = True
4+
LOG_FORMAT='%(asctime)s - %(name)s - %(levelname)s - %(message)s'

‎e2e-cli/README.md‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# analytics-python e2e-cli
2+
3+
E2E test CLI for the [analytics-python](https://github.com/segmentio/analytics-python) SDK. Accepts a JSON input describing events and SDK configuration, sends them through the real SDK, and outputs results as JSON.
4+
5+
## Setup
6+
7+
```bash
8+
cd e2e-cli
9+
python3 -m venv .venv
10+
source .venv/bin/activate
11+
pip install -r requirements.txt
12+
pip install -e .
13+
```
14+
15+
## Usage
16+
17+
```bash
18+
e2e-cli --input '{"writeKey":"...", ...}'
19+
```
20+
21+
Or without installing:
22+
23+
```bash
24+
python3 -m src.cli --input '{"writeKey":"...", ...}'
25+
```
26+
27+
## Input Format
28+
29+
```jsonc
30+
{
31+
"writeKey": "your-write-key", // required
32+
"apiHost": "https://...", // optional — defaults to https://api.segment.io
33+
"sequences": [ // required — event sequences to send
34+
{
35+
"delayMs": 0,
36+
"events": [
37+
{ "type": "track", "event": "Test", "userId": "user-1" }
38+
]
39+
}
40+
],
41+
"config": { // optional
42+
"flushAt": 100, // upload_size in Python SDK
43+
"flushInterval": 500, // ms (auto-converted to seconds if > 100)
44+
"maxRetries": 10,
45+
"timeout": 15
46+
}
47+
}
48+
```
49+
50+
Note: Python is a server-side SDK — there is no CDN settings fetch, so `cdnHost` does not apply.
51+
52+
## Output Format
53+
54+
```json
55+
{ "success": true, "sentBatches": 1 }
56+
```
57+
58+
On failure:
59+
60+
```json
61+
{ "success": false, "error": "description", "sentBatches": 0 }
62+
```

‎e2e-cli/__init__.py‎

Whitespace-only changes.

‎e2e-cli/e2e-config.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": "python",
3+
"test_suites": "basic",
4+
"auto_settings": false,
5+
"patch": null,
6+
"env": {}
7+
}

‎e2e-cli/main.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎e2e-cli/requirements.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
click==8.1.8
2+
python-dotenv==1.0.1
3+
python-dateutil==2.8.2
4+
requests==2.32.3
5+
PyJWT==2.12.1
6+
backoff==2.2.1

‎e2e-cli/run-e2e.sh‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
#
3+
# Run E2E tests for analytics-python
4+
#
5+
# Prerequisites: Python 3, pip, Node.js 18+
6+
#
7+
# Usage:
8+
# ./run-e2e.sh [extra args passed to run-tests.sh]
9+
#
10+
# Override sdk-e2e-tests location:
11+
# E2E_TESTS_DIR=../my-e2e-tests ./run-e2e.sh
12+
#
13+
14+
set -e
15+
16+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17+
SDK_ROOT="$SCRIPT_DIR/.."
18+
E2E_DIR="${E2E_TESTS_DIR:-$SDK_ROOT/../sdk-e2e-tests}"
19+
20+
echo "=== Building analytics-python e2e-cli ==="
21+
22+
# Install SDK
23+
cd "$SDK_ROOT"
24+
pip install -e .
25+
26+
# Install e2e-cli
27+
cd "$SCRIPT_DIR"
28+
pip install -e .
29+
30+
echo ""
31+
32+
# Run tests
33+
cd "$E2E_DIR"
34+
./scripts/run-tests.sh \
35+
--sdk-dir "$SCRIPT_DIR" \
36+
--cli "e2e-cli" \
37+
"$@"

0 commit comments

Comments
 (0)