File tree Expand file tree Collapse file tree 5 files changed +28
-8
lines changed Expand file tree Collapse file tree 5 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 4
4
release :
5
5
types : [created]
6
6
workflow_dispatch :
7
+ inputs :
8
+ base_url :
9
+ description : ' Base URL for performance tests'
10
+ required : false
11
+ default : ' https://cal.com'
7
12
8
13
jobs :
9
14
performance-tests :
10
15
runs-on : ubuntu-latest
11
16
env :
12
- BASE_URL : http ://localhost:3000
17
+ BASE_URL : ${{ github.event.inputs.base_url || 'https ://cal.com' }}
13
18
steps :
14
19
- name : Checkout
15
20
uses : actions/checkout@v4
57
62
with :
58
63
path : tests/performance/spike/*.js
59
64
cloud-run-locally : true
60
- fail-fast : true
65
+ fail-fast : true
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ The test suite is organized into the following directories:
24
24
By default, tests will run against ` http://localhost:3000 ` . To test against a different environment, set the ` BASE_URL ` environment variable:
25
25
26
26
``` bash
27
- BASE_URL=https://your-cal-instance.com k6 run tests/performance/smoke/booking_flow .js
27
+ BASE_URL=https://your-cal-instance.com k6 run tests/performance/smoke/booking .js
28
28
```
29
29
30
30
### Running Smoke Tests
@@ -78,6 +78,16 @@ Performance thresholds are defined in `utils/config.js` and vary by test type:
78
78
- ** Stress Tests** : More lenient thresholds for heavy load conditions
79
79
- ** Spike Tests** : Most lenient thresholds for sudden traffic spikes
80
80
81
+ ## Environment Variables
82
+
83
+ The following environment variables can be used to configure the tests:
84
+
85
+ - ` BASE_URL ` : Base URL for the application (default: ` http://localhost:3000 ` )
86
+ - ` TEST_USER_FREE ` : Username for free tier testing (default: ` free ` )
87
+ - ` TEST_PASSWORD_FREE ` : Password for free tier testing (default: ` free ` )
88
+ - ` TEST_USER_PRO ` : Username for pro tier testing (default: ` pro ` )
89
+ - ` TEST_PASSWORD_PRO ` : Password for pro tier testing (default: ` pro ` )
90
+
81
91
## Adding New Tests
82
92
83
93
To add a new test:
Original file line number Diff line number Diff line change @@ -20,5 +20,5 @@ export const options = {
20
20
export default function ( ) {
21
21
viewBookingPage ( "pro" , "30min" ) ;
22
22
23
- sleep ( 0.01 ) ;
23
+ sleep ( 0.1 ) ;
24
24
}
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ export const THRESHOLDS = {
34
34
35
35
export const TEST_USERS = new SharedArray ( "users" , function ( ) {
36
36
return [
37
- { username : "free" , password : "free" } ,
38
- { username : "pro" , password : "pro" } ,
37
+ { username : __ENV . TEST_USER_FREE || "free" , password : __ENV . TEST_PASSWORD_FREE || "free" } ,
38
+ { username : __ENV . TEST_USER_PRO || "pro" , password : __ENV . TEST_PASSWORD_PRO || "pro" } ,
39
39
] ;
40
40
} ) ;
41
41
@@ -44,10 +44,13 @@ export function getRandomUser() {
44
44
}
45
45
46
46
export function randomQueryParam ( ) {
47
- return `nocache=${ new Date ( ) . getTime ( ) } ` ;
47
+ return `nocache=${ Date . now ( ) } ` ;
48
48
}
49
49
50
50
export function randomSleep ( min = SLEEP_DURATION . SHORT , max = SLEEP_DURATION . MEDIUM ) {
51
+ if ( min > max ) {
52
+ throw new Error ( "min cannot be greater than max" ) ;
53
+ }
51
54
const sleepTime = Math . random ( ) * ( max - min ) + min ;
52
55
sleep ( sleepTime ) ;
53
56
}
Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ export function viewBookingPage(username, eventSlug) {
9
9
10
10
const response = http . get ( url , {
11
11
tags : { name : "Booking Page" } ,
12
+ timeout : "30s" ,
12
13
} ) ;
13
14
14
15
check ( response , {
15
16
"Booking page loaded" : ( r ) => r . status === 200 ,
16
- "Has booking form" : ( r ) => r . body . includes ( 'data-testid="day"' ) ,
17
+ "Has booking form" : ( r ) => r . body . includes ( 'data-testid="day"' ) || r . body . includes ( 'booking' ) ,
18
+ "Response time acceptable" : ( r ) => r . timings . duration < 5000 ,
17
19
} ) ;
18
20
19
21
randomSleep ( ) ;
You can’t perform that action at this time.
0 commit comments