1
- import { CommunicationProtocolEnum , DaprClient , DaprServer , HttpMethod } from '../../src' ;
1
+ import { CommunicationProtocolEnum , DaprClient } from '../../src' ;
2
2
3
- const serverHost = '127.0.0.1' ;
4
- const serverPort = '50001' ;
5
3
const daprHost = '127.0.0.1' ;
6
4
const daprPort = '50000' ; // Dapr Sidecar Port of this Example Server
7
- const daprAppId = 'test-suite' ;
8
5
9
6
describe ( 'load/http' , ( ) => {
10
- let server : DaprServer ;
11
7
let client : DaprClient ;
12
- // const mockBindingReceive = jest.fn(async (data: object) => console.log('mockBindingReceive'));
13
- // const mockPubSubSubscribe = jest.fn(async (data: object) => console.log('mockPubSubSubscribe'));
14
8
15
9
// We need to start listening on some endpoints already
16
10
// this because Dapr is not dynamic and registers endpoints on boot
17
11
beforeAll ( async ( ) => {
18
- server = new DaprServer ( serverHost , serverPort , daprHost , daprPort , CommunicationProtocolEnum . HTTP ) ;
19
12
client = new DaprClient ( daprHost , daprPort , CommunicationProtocolEnum . HTTP ) ;
20
-
21
- // await server.binding.receive('binding-mqtt', mockBindingReceive);
22
-
23
- // Start server
24
- await server . startServer ( ) ;
25
13
} ) ;
26
14
27
- afterAll ( async ( ) => {
28
- await server . stopServer ( ) ;
29
- } )
30
-
31
15
describe ( 'pubsub' , ( ) => {
32
- it ( 'should be able to send 500 events as quickly as possible without errors' , async ( ) => {
33
- const amountOfCalls = 1 ;
16
+ it ( 'should be able to send 2500 events as quickly as possible without errors' , async ( ) => {
17
+ const amountOfCalls = 2500 ;
34
18
35
19
// Create the promises
36
20
let promises = [ ] ;
@@ -40,17 +24,13 @@ describe('load/http', () => {
40
24
}
41
25
42
26
// Await the promises
27
+ const tStart = Date . now ( ) ;
43
28
const res = await Promise . all ( promises ) ;
44
- console . log ( res ) ;
45
-
46
- // Delay a bit for event to arrive
47
- // await new Promise((resolve, reject) => setTimeout(resolve, 250));
48
-
49
- // expect(mockPubSubSubscribe.mock.calls.length).toBe(1);
29
+ const tEnd = Date . now ( ) ;
50
30
51
- // Also test for receiving data
52
- // @ts -ignore
53
- // expect(mockPubSubSubscribe.mock.calls[0][0]['hello']).toEqual('world');
54
- } ) ;
31
+ expect ( res . filter ( i => i === true ) . length ) . toEqual ( amountOfCalls ) ;
32
+ console . log ( `Execution time: ${ tEnd - tStart } ms` ) ;
33
+ // @todo : do we add an execution time test?
34
+ } , 30 * 1000 ) ;
55
35
} ) ;
56
36
} ) ;
0 commit comments