Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E tests #504

Merged
merged 44 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8402bcb
feat: move from fake ip vars to test types vars
alexey-yarmosh Mar 1, 2024
c03d3b1
feat: add mock e2e scripts
alexey-yarmosh Mar 1, 2024
8f78c22
feat: add mocha setup
alexey-yarmosh Mar 1, 2024
aa5bc34
feat: run probe container from e2e setup
alexey-yarmosh Mar 4, 2024
877f95b
ci: trigger e2e
alexey-yarmosh Mar 4, 2024
bf434dc
feat: wait until probe connects
alexey-yarmosh Mar 4, 2024
6c69575
feat: add failing usage of matchApiSchema
alexey-yarmosh Mar 4, 2024
fd86edd
fix: matchApiSchema method
alexey-yarmosh Mar 5, 2024
1a05f08
fix: mocha throwing ERROR: null in case of ts compilation error
alexey-yarmosh Mar 5, 2024
9a1e134
feat: add util parser
alexey-yarmosh Mar 5, 2024
7dda7a4
feat: change runner
alexey-yarmosh Mar 5, 2024
c8f8ba2
feat: use got response in mocha plugin
alexey-yarmosh Mar 5, 2024
3655709
test: add measurement e2e tests
alexey-yarmosh Mar 5, 2024
b5bb6b2
feat: add e2e wallaby configuration
alexey-yarmosh Mar 6, 2024
d8559f6
feat: move e2e .mocharc
alexey-yarmosh Mar 6, 2024
1889319
feat: add e2e folder to tsconfig
alexey-yarmosh Mar 6, 2024
eadb8d2
feat: add e2e cases for all measurement types
alexey-yarmosh Mar 6, 2024
e6623d3
fix: http schema
alexey-yarmosh Mar 6, 2024
14bc185
refactor: move files
alexey-yarmosh Mar 6, 2024
962a447
feat: add locations e2e
alexey-yarmosh Mar 7, 2024
9ebbaab
fix: add missing nulls to schema
alexey-yarmosh Mar 7, 2024
bead9c7
test: add offline probes tests
alexey-yarmosh Mar 7, 2024
ef004db
test: add adopted probes tests e2e
alexey-yarmosh Mar 7, 2024
88f91d4
fix: e2e mocharc
alexey-yarmosh Mar 8, 2024
f7cb9c0
fix: tests order
alexey-yarmosh Mar 8, 2024
0d6f95a
feat: run api as docker container
alexey-yarmosh Mar 8, 2024
21ae107
fix: run api on port 3000
alexey-yarmosh Mar 8, 2024
d5802c4
fix: local run
alexey-yarmosh Mar 8, 2024
999a0b6
refactor: docker manager
alexey-yarmosh Mar 11, 2024
f87c313
fix: e2e wallaby
alexey-yarmosh Mar 11, 2024
d7cd980
fix: schema hostname format
alexey-yarmosh Mar 11, 2024
61861fe
fix: remove unused env var
alexey-yarmosh Mar 11, 2024
906c1c0
fix: add missing awaits
alexey-yarmosh Mar 11, 2024
98098f0
fix: remove manual json.parse
alexey-yarmosh Mar 14, 2024
00f3a73
Merge branch 'master' into e2e
alexey-yarmosh Mar 14, 2024
9f5777b
fix: log measurement status
alexey-yarmosh Mar 14, 2024
a31071d
feat: disable rtt null
alexey-yarmosh Mar 14, 2024
f946bae
fix: add wait for disconnect
alexey-yarmosh Mar 14, 2024
39a7a27
ci: trigger
alexey-yarmosh Mar 14, 2024
1756fea
fix: retrun rtt null back
alexey-yarmosh Mar 14, 2024
e0163ba
refactor: move e2e to test folder
alexey-yarmosh Mar 15, 2024
7ecdfe0
fix: use db urls from config
alexey-yarmosh Mar 18, 2024
8782b89
fix: build probe image from github master
alexey-yarmosh Mar 18, 2024
102383d
fix: get rtt schema back
alexey-yarmosh Mar 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted

env:
NODE_ENV: test
Expand Down Expand Up @@ -48,11 +48,14 @@ jobs:
run: |
npm ci
npm run build
- name: Test
- name: Test Unit
run: |
npm run lint
npm run coverage
npm run test:portman
- name: Test E2E
run: |
npm run test:e2e
- name: Test Dist
run: |
rm -rf node_modules
Expand Down
42 changes: 42 additions & 0 deletions .mocharc.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"exit": true,
"timeout": 20000,
"check-leaks": true,
"file": [
"test/tests/e2e/setup-api.ts",
"test/tests/e2e/setup-probe.ts"
],
"spec": [
"test/tests/e2e/**/*.test.ts"
],
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
],
"globals": [
"__extends",
"__assign",
"__rest",
"__decorate",
"__param",
"__metadata",
"__awaiter",
"__generator",
"__exportStar",
"__createBinding",
"__values",
"__read",
"__spread",
"__spreadArrays",
"__spreadArray",
"__await",
"__asyncGenerator",
"__asyncDelegator",
"__asyncValues",
"__makeTemplateObject",
"__importStar",
"__importDefault",
"__classPrivateFieldGet",
"__classPrivateFieldSet"
]
}
3 changes: 2 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"test/setup.ts"
],
"spec": [
"test/**/*.test.ts"
"test/tests/integration/**/*.test.ts",
"test/tests/unit/**/*.test.ts"
],
"node-option": [
"experimental-specifier-resolution=node",
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Once the API is live, you can spin up a probe instance by running as described a

### Environment variables
- `PORT=3000` environment variable can start the API on another port (default is 3000)
- `FAKE_PROBE_IP=api` environment variable can be used to make debug easier. When defined, every Probe
- `FAKE_PROBE_IP=1` environment variable can be used to make debug easier. When defined, every Probe
that connects to the API will get an IP address from the list of predefined "real" addresses.

### Testing
Expand All @@ -43,7 +43,7 @@ Most IDEs have plugins integrating the used linter (eslint), including support f
- `NEW_RELIC_LICENSE_KEY={value}` used in production to send APM metrics to new relic
- `NEW_RELIC_APP_NAME={value}` used in production to send APM mentrics to new relic
- `NEW_RELIC_ENABLED=false` used in development to disable newrelic monitoring
- `FAKE_PROBE_IP={api|probe}` used in development to either use a random fake ip from the API or a fake ip from Probe
- `FAKE_PROBE_IP=1` used in development to use a random fake ip assigned by the API
- `ADMIN_KEY={value}` used to access additional information over the API
- `SYSTEM_API_KEY={value}` used for integration with the dashboard
- `DB_CONNECTION_HOST`, `DB_CONNECTION_USER`, `DB_CONNECTION_PASSWORD`, and `DB_CONNECTION_DATABASE` database connection details
12 changes: 6 additions & 6 deletions docs/staging-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exit

## API

Runs 2 API instances on ports 3001 and 3002 behind the haproxy on port 80. Geoip client is mocked so all probes get same location. `FAKE_PROBE_IP=probe` makes API to use fake ip provided by the probe.
Runs 2 API instances on ports 3001 and 3002 behind the haproxy on port 80. Geoip client is mocked so all probes get same location. `TEST_MODE=perf` makes API to use fake ip provided by the probe.

```bash
# Update that variables before start
Expand Down Expand Up @@ -79,20 +79,20 @@ npm run build

# Run the app
echo 'Run 2 app instances using:
PORT=3001 HOSTNAME=3001 REDIS_URL=redis://default:$REDIS_PASSWORD@$REDIS_HOST:6379 NODE_ENV=production ADMIN_KEY=admin FAKE_PROBE_IP=probe NEW_RELIC_ENABLED=false NEW_RELIC_LOG_ENABLED=false node dist/index.js
PORT=3001 HOSTNAME=3001 REDIS_URL=redis://default:$REDIS_PASSWORD@$REDIS_HOST:6379 NODE_ENV=production ADMIN_KEY=admin TEST_MODE=perf NEW_RELIC_ENABLED=false NEW_RELIC_LOG_ENABLED=false node dist/index.js
and
PORT=3002 HOSTNAME=3002 REDIS_URL=redis://default:$REDIS_PASSWORD@$REDIS_HOST:6379 NODE_ENV=production ADMIN_KEY=admin FAKE_PROBE_IP=probe NEW_RELIC_ENABLED=false NEW_RELIC_LOG_ENABLED=false node dist/index.js
PORT=3002 HOSTNAME=3002 REDIS_URL=redis://default:$REDIS_PASSWORD@$REDIS_HOST:6379 NODE_ENV=production ADMIN_KEY=admin TEST_MODE=perf NEW_RELIC_ENABLED=false NEW_RELIC_LOG_ENABLED=false node dist/index.js
'
```

## Probe

Runs `PROBES_COUNT` number of probe processes. They all get a random fake ip which is passed to the API. Value of the `FAKE_PROBE_IP` is the first octet of the fake ip. Each probe process requires ~40mb of RAM.
Runs `PROBES_COUNT` number of probe processes. They all get a random fake ip which is passed to the API. Value of the `FAKE_IP_FIRST_OCTET` is the first octet of the fake ip. Each probe process requires ~40mb of RAM.

```bash
# Update that variables before start
API_HOST=<your_value>
FAKE_PROBE_IP=1
FAKE_IP_FIRST_OCTET=1
PROBES_COUNT=300

# Install node
Expand Down Expand Up @@ -124,6 +124,6 @@ sudo dpkg --extract "/tmp/expect.deb" /
# Auto start the probes
sudo npm i -g pm2
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
FAKE_PROBE_IP=$FAKE_PROBE_IP NODE_ENV=development PROBES_COUNT=$PROBES_COUNT API_HOST=ws://$API_HOST pm2 start dist/index.js
FAKE_IP_FIRST_OCTET=$FAKE_IP_FIRST_OCTET NODE_ENV=development PROBES_COUNT=$PROBES_COUNT API_HOST=ws://$API_HOST pm2 start dist/index.js
pm2 save
```
149 changes: 149 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading