-
Notifications
You must be signed in to change notification settings - Fork 1
/
websocket-load-test.yml
87 lines (82 loc) · 2.43 KB
/
websocket-load-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
config:
# replace with actual wss provider url
target: 'WEBSOCKET_SERVER_URL'
phases:
- duration: 60
arrivalRate: 5
rampTo: 20
name: 'Ramping up the load'
- duration: 120
arrivalRate: 20
name: 'Sustained load'
ws:
# replace with actual token
headers:
Authorization: 'Bearer YOUR_ACCESS_TOKEN'
scenarios:
- name: 'WebSocket Connection and Interaction'
flow:
- loop:
- function: 'connectWebSocket'
- think: 5
- function: 'editMarkdownCell'
- think: 10
- function: 'editCodeCell'
- think: 15
- function: 'navigateDashboard'
- think: 5
count: 10
- name: 'Concurrent Editing Simulation'
flow:
- loop:
- function: 'connectWebSocket'
- think: 5
- function: 'concurrentEditCell'
- think: 10
count: 20
- name: 'Connection Stability Test'
flow:
- loop:
- function: 'connectWebSocket'
- think: 2
- function: 'disconnectWebSocket'
- think: 1
count: 30
functions:
connectWebSocket:
# establishes a WebSocket connection with the backend provider
# make sure to set real values for docID, WSS_HOST, and token when running the test
js: |
function(context, events, done) {
var docID = 'NOTEBOOK_YDOC_ID';
var url = `wss://<WSS_HOST>/collab/${docID}`;
var token = 'TEMPLATE_TOKEN';
context.ws.connect(url, {
headers: {
Authorization: `Bearer ${token}`
},
onOpen: function(socket) {
console.log('WebSocket connection opened');
// Store the WebSocket connection in the context for other functions to use
context.ws = socket;
done();
},
onClose: function() {
console.log('WebSocket connection closed');
},
onError: function(error) {
console.error('WebSocket error:', error);
done(error);
}
});
}
editMarkdownCell:
# TODO: add logic to simulate editing a markdown cell
editCodeCell:
# TODO: add logic to simulate editing a code cell
navigateDashboard:
# TODO: add logic to simulate dashboard navigation
concurrentEditCell:
# TODO: add logic to simulate concurrent editing of a cell
disconnectWebSocket:
# TODO: add logic to disconnect the WebSocket