Skip to content

Commit

Permalink
add cloudflare worker tests for analytics-node (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisradek authored Oct 18, 2023
1 parent e01fb23 commit d8e922d
Show file tree
Hide file tree
Showing 13 changed files with 1,254 additions and 24 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
jobs:
analytics-node:
name: "analytics-node QA (Node.js v${{ matrix.node-version }})"
name: 'analytics-node QA (Node.js v${{ matrix.node-version }})'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14, 16, 18 ]
node-version: [14, 16, 18]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache: 'yarn'
- run: yarn install --immutable
- name: Turbo cache
uses: actions/cache@v3
Expand All @@ -27,6 +27,28 @@ jobs:
${{ runner.os }}-turbo-
- run: yarn turbo run --filter='./packages/node*' lint
- run: yarn turbo run --filter='./packages/node*' test
- run: yarn turbo run --filter='./packages/node-integration-tests' test:perf-and-durability
analytics-node-cf-workers:
name: 'analytics-node QA (Cloudflare Workers)'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn install --immutable
- name: Turbo cache
uses: actions/cache@v3
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- run: yarn turbo run --filter='./packages/node-integration-tests' test:cloudflare-workers
consent-intg-tests:
name: Consent Integration Tests
runs-on: ubuntu-latest
Expand All @@ -37,7 +59,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"
cache: 'yarn'
- run: yarn install --immutable
- name: Turbo cache
uses: actions/cache@v3
Expand All @@ -47,6 +69,3 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-
- run: yarn turbo run --filter='consent-tools-integration-tests' test:int



14 changes: 7 additions & 7 deletions packages/node-integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Integration Tests for @segment/analytics-node

## Tests
| Test Path | Description |
| ---- | ----------- |
| [./src/durability-tests](src/durability-tests/) | Test that all the events created by the Analytics SDK end up as HTTP Requests, and that graceful shutdown does not result in events getting lost. |
| [./src/perf-tests](src/perf-tests/) | These tests confirm that performance has not regresssed relative to the old SDK or from the baseline (which a handler _without_ analytics).

| Test Path | Description |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| [./src/durability-tests](src/durability-tests/) | Test that all the events created by the Analytics SDK end up as HTTP Requests, and that graceful shutdown does not result in events getting lost. |
| [./src/perf-tests](src/perf-tests/) | These tests confirm that performance has not regresssed relative to the old SDK or from the baseline (which a handler _without_ analytics). |
| [./src/cloudflare-tests/](src/cloudflare-tests/) | These tests confirm that the SDK runs as expected in cloudflare workers. |

Build deps and run tests:

```sh
yarn turbo run --filter=node-integration-tests test # from repo root
```



3 changes: 3 additions & 0 deletions packages/node-integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { createJestTSConfig } = require('@internal/config')

module.exports = createJestTSConfig(__dirname)
8 changes: 6 additions & 2 deletions packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
"durability": "yarn ts-node src/durability-tests/durability-tests.ts",
"concurrently": "yarn run -T concurrently",
"ts-node": "yarn run -T ts-node",
"test": "yarn perf && yarn durability"
"test:perf-and-durability": "yarn perf && yarn durability",
"test:cloudflare-workers": "yarn run -T jest src/cloudflare-tests"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20231002.0",
"@internal/config": "workspace:^",
"@internal/test-helpers": "workspace:^",
"@segment/analytics-node": "workspace:^",
"@types/analytics-node": "^3.1.9",
"@types/autocannon": "^7",
"@types/node": "^16",
"analytics-node": "^6.2.0",
"autocannon": "^7.10.0"
"autocannon": "^7.10.0",
"wrangler": "^3.11.0"
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit d8e922d

Please sign in to comment.