Skip to content

Commit dae72a3

Browse files
committed
Test in staging
1 parent a79b7a6 commit dae72a3

File tree

6 files changed

+222747
-2996
lines changed

6 files changed

+222747
-2996
lines changed

.github/workflows/test.yaml

+75-78
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,32 @@ on:
33
push:
44

55
jobs:
6-
7-
unit-tests:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v4
11-
- name: Setup Node.js
12-
id: setup-node
13-
uses: actions/setup-node@v4
14-
with:
15-
node-version-file: .node-version
16-
cache: npm
17-
- name: Install dependencies
18-
id: install
19-
run: npm ci
20-
- name: Run lint check
21-
id: lint
22-
run: npm run lint
23-
- name: Run format check
24-
id: format
25-
run: npm run format:check
26-
- name: Run tests
27-
id: test
28-
run: npm run test:coverage
29-
6+
# unit-tests:
7+
# runs-on: ubuntu-latest
8+
# steps:
9+
# - uses: actions/checkout@v4
10+
# - name: Setup Node.js
11+
# id: setup-node
12+
# uses: actions/setup-node@v4
13+
# with:
14+
# node-version-file: .node-version
15+
# cache: npm
16+
# - name: Install dependencies
17+
# id: install
18+
# run: npm ci
19+
# - name: Run tests
20+
# id: test
21+
# run: npm run test:coverage
3022
protocol:
31-
needs: [unit-tests]
23+
# needs: [unit-tests]
3224
runs-on: ubuntu-latest
3325
env:
34-
K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN }}
35-
K6_CLOUD_PROJECT_ID: ${{ secrets.K6_CLOUD_PROJECT_ID }}
26+
K6_CLOUD_TOKEN: ${{ secrets.AYUSH_STAGING_K6_TOKEN }}
27+
K6_CLOUD_PROJECT_ID: "16274"
28+
K6_CLOUD_BASE_URL: "https://api.staging.k6.io"
29+
K6_CLOUD_HOST: "https://ingest.staging.k6.io"
30+
K6_CLOUD_WEB_APP_URL: "https://app.staging.k6.io"
31+
K6_CLOUD_LOGS_TAIL_URL: "wss://cloudlogs.staging.k6.io/api/v1/tail"
3632
steps:
3733
- uses: actions/checkout@v4
3834
- name: Setup Grafana k6
@@ -45,55 +41,56 @@ jobs:
4541
flags: --vus 10 --duration 30s
4642
parallel: true
4743
cloud-run-locally: false
48-
protocol-without-flags:
49-
needs: [unit-tests]
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v4
53-
- name: Setup Grafana k6
54-
uses: grafana/setup-k6-action@main
55-
- uses: ./
56-
continue-on-error: true
57-
with:
58-
path: |
59-
./dev/protocol*.js
60-
show-complete-k6-output:
61-
needs: [unit-tests]
62-
runs-on: ubuntu-latest
63-
steps:
64-
- uses: actions/checkout@v4
65-
- name: Setup Grafana k6
66-
uses: grafana/setup-k6-action@main
67-
- uses: ./
68-
with:
69-
path: |
70-
./dev/protocol.js
71-
flags: --vus 10 --duration 30s
7244
debug: true
73-
verify-scripts:
74-
needs: [unit-tests]
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v4
78-
- name: Setup Grafana k6
79-
uses: grafana/setup-k6-action@main
80-
- uses: ./
81-
continue-on-error: true
82-
with:
83-
path: |
84-
./dev/verify-script-tests/**.js
85-
only-verify-scripts: true
86-
env-var-test:
87-
needs: [unit-tests]
88-
runs-on: ubuntu-latest
89-
env:
90-
TEST_SYSTEM_ENV_VAR: "test-system-env-var-value"
91-
steps:
92-
- uses: actions/checkout@v4
93-
- name: Setup Grafana k6
94-
uses: grafana/setup-k6-action@main
95-
- uses: ./
96-
with:
97-
path: |
98-
./dev/env-var-test.js
99-
flags: --vus 1 --duration 1s --env TEST_FLAG_ENV_VAR=test-flag-env-var-value -e TEST_SYSTEM_ENV_VAR_E=test-cli-e-env-var-value
45+
# protocol-without-flags:
46+
# needs: [unit-tests]
47+
# runs-on: ubuntu-latest
48+
# steps:
49+
# - uses: actions/checkout@v4
50+
# - name: Setup Grafana k6
51+
# uses: grafana/setup-k6-action@main
52+
# - uses: ./
53+
# continue-on-error: true
54+
# with:
55+
# path: |
56+
# ./dev/protocol*.js
57+
# show-complete-k6-output:
58+
# needs: [unit-tests]
59+
# runs-on: ubuntu-latest
60+
# steps:
61+
# - uses: actions/checkout@v4
62+
# - name: Setup Grafana k6
63+
# uses: grafana/setup-k6-action@main
64+
# - uses: ./
65+
# with:
66+
# path: |
67+
# ./dev/protocol.js
68+
# flags: --vus 10 --duration 30s
69+
# debug: true
70+
# verify-scripts:
71+
# needs: [unit-tests]
72+
# runs-on: ubuntu-latest
73+
# steps:
74+
# - uses: actions/checkout@v4
75+
# - name: Setup Grafana k6
76+
# uses: grafana/setup-k6-action@main
77+
# - uses: ./
78+
# continue-on-error: true
79+
# with:
80+
# path: |
81+
# ./dev/verify-script-tests/**.js
82+
# only-verify-scripts: true
83+
# env-var-test:
84+
# needs: [unit-tests]
85+
# runs-on: ubuntu-latest
86+
# env:
87+
# TEST_SYSTEM_ENV_VAR: "test-system-env-var-value"
88+
# steps:
89+
# - uses: actions/checkout@v4
90+
# - name: Setup Grafana k6
91+
# uses: grafana/setup-k6-action@main
92+
# - uses: ./
93+
# with:
94+
# path: |
95+
# ./dev/env-var-test.js
96+
# flags: --vus 1 --duration 1s --env TEST_FLAG_ENV_VAR=test-flag-env-var-value -e TEST_SYSTEM_ENV_VAR_E=test-cli-e-env-var-value

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
npx lint-staged
2+
npm run package && git add ./dist/index.js

dev/protocol4.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { check, group, sleep } from 'k6'
2+
import http from 'k6/http'
3+
4+
export const options = {
5+
scenarios: {
6+
normal_users: {
7+
executor: 'constant-vus',
8+
vus: 5,
9+
duration: '30s',
10+
},
11+
spike_users: {
12+
executor: 'ramping-vus',
13+
stages: [
14+
{ duration: '10s', target: 10 },
15+
{ duration: '10s', target: 20 },
16+
{ duration: '10s', target: 5 },
17+
],
18+
},
19+
},
20+
}
21+
22+
export default function () {
23+
group('Always Passing Check', function () {
24+
let res = http.get('https://test-api.k6.io/public/crocodiles/')
25+
26+
check(res, {
27+
'Response status is 200': (r) => r.status === 200, // ✅ Always passes
28+
})
29+
30+
sleep(1)
31+
})
32+
33+
group('Partially Failing Check', function () {
34+
let res = http.get('https://test-api.k6.io/public/does-not-exist/')
35+
36+
check(res, {
37+
'Response status is 200 or 404': (r) =>
38+
r.status === 200 || r.status === 404, // ⚠️ Partially fails
39+
})
40+
41+
sleep(1)
42+
})
43+
44+
group('Completely Failing Check', function () {
45+
let res = http.get('https://test-api.k6.io/internal/secret')
46+
47+
check(res, {
48+
'Response status is 200': (r) => r.status === 200, // ❌ Always fails (Expected 403/500)
49+
})
50+
51+
sleep(1)
52+
})
53+
}

0 commit comments

Comments
 (0)