@@ -13,20 +13,25 @@ limitations under the License.
13
13
14
14
import { CommunicationProtocolEnum , DaprClient , DaprServer } from '../../src' ;
15
15
16
+ import * as NodeJSUtil from '../../src/utils/NodeJS.util' ;
17
+ import ActorId from '../../src/actors/ActorId' ;
18
+ import ActorProxyBuilder from '../../src/actors/client/ActorProxyBuilder' ;
16
19
import DemoActorActivateImpl from '../actor/DemoActorActivateImpl' ;
17
20
import DemoActorCounterImpl from '../actor/DemoActorCounterImpl' ;
21
+ import DemoActorCounterInterface from '../actor/DemoActorCounterInterface' ;
18
22
import DemoActorReminderImpl from '../actor/DemoActorReminderImpl' ;
19
23
import DemoActorReminder2Impl from '../actor/DemoActorReminder2Impl' ;
24
+ import DemoActorReminderInterface from '../actor/DemoActorReminderInterface' ;
20
25
import DemoActorSayImpl from '../actor/DemoActorSayImpl' ;
26
+ import DemoActorSayInterface from '../actor/DemoActorSayInterface' ;
21
27
import DemoActorTimerImpl from '../actor/DemoActorTimerImpl' ;
22
- import ActorId from '../../src/actors/ActorId' ;
23
- import ActorProxyBuilder from '../../src/actors/client/ActorProxyBuilder' ;
24
- import * as NodeJSUtil from '../../src/utils/NodeJS.util' ;
28
+ import DemoActorTimerInterface from '../actor/DemoActorTimerInterface' ;
25
29
26
30
const serverHost = "127.0.0.1" ;
27
31
const serverPort = "50001" ;
28
32
const sidecarHost = "127.0.0.1" ;
29
33
const sidecarPort = "50000" ;
34
+ const serverStartWaitTimeMs = 5 * 1000 ;
30
35
31
36
describe ( 'http/actors' , ( ) => {
32
37
let server : DaprServer ;
@@ -59,6 +64,10 @@ describe('http/actors', () => {
59
64
60
65
// Start server
61
66
await server . start ( ) ; // Start the general server, this can take a while
67
+
68
+ // Wait for actor placement tables to fully start up
69
+ // TODO: Remove this once healthz is fixed (https://github.com/dapr/dapr/issues/3451)
70
+ await NodeJSUtil . sleep ( serverStartWaitTimeMs ) ;
62
71
} , 30 * 1000 ) ;
63
72
64
73
afterAll ( async ( ) => {
@@ -68,13 +77,13 @@ describe('http/actors', () => {
68
77
69
78
describe ( 'actorProxy' , ( ) => {
70
79
it ( 'should be able to create an actor object through the proxy' , async ( ) => {
71
- const builder = new ActorProxyBuilder < DemoActorCounterImpl > ( DemoActorCounterImpl , client ) ;
80
+ const builder = new ActorProxyBuilder < DemoActorCounterInterface > ( DemoActorCounterImpl , client ) ;
72
81
const actor = builder . build ( ActorId . createRandomId ( ) ) ;
73
82
74
83
const c1 = await actor . getCounter ( ) ;
75
84
expect ( c1 ) . toEqual ( 0 ) ;
76
85
77
- await actor . countBy ( 1 ) ;
86
+ await actor . countBy ( 1 , 1 ) ;
78
87
const c2 = await actor . getCounter ( ) ;
79
88
expect ( c2 ) . toEqual ( 1 ) ;
80
89
@@ -98,36 +107,36 @@ describe('http/actors', () => {
98
107
} ) ;
99
108
100
109
it ( 'should be able to invoke an actor through a text message' , async ( ) => {
101
- const builder = new ActorProxyBuilder < DemoActorSayImpl > ( DemoActorSayImpl , client ) ;
110
+ const builder = new ActorProxyBuilder < DemoActorSayInterface > ( DemoActorSayImpl , client ) ;
102
111
const actor = builder . build ( ActorId . createRandomId ( ) ) ;
103
112
const res = await actor . sayString ( "Hello World" ) ;
104
113
expect ( res ) . toEqual ( `Actor said: "Hello World"` )
105
114
} ) ;
106
115
107
116
it ( 'should be able to invoke an actor through an object message' , async ( ) => {
108
- const builder = new ActorProxyBuilder < DemoActorSayImpl > ( DemoActorSayImpl , client ) ;
117
+ const builder = new ActorProxyBuilder < DemoActorSayInterface > ( DemoActorSayImpl , client ) ;
109
118
const actor = builder . build ( ActorId . createRandomId ( ) ) ;
110
119
const res = await actor . sayObject ( { hello : "world" } ) ;
111
120
expect ( JSON . stringify ( res ) ) . toEqual ( `{"said":{"hello":"world"}}` )
112
121
} ) ;
113
122
114
123
it ( 'should be able to invoke an actor through multiple parameters' , async ( ) => {
115
- const builder = new ActorProxyBuilder < DemoActorSayImpl > ( DemoActorSayImpl , client ) ;
124
+ const builder = new ActorProxyBuilder < DemoActorSayInterface > ( DemoActorSayImpl , client ) ;
116
125
const actor = builder . build ( ActorId . createRandomId ( ) ) ;
117
126
const res = await actor . sayMulti ( 123 , "123" , { hello : "world 123" } , [ 1 , 2 , 3 ] ) ;
118
127
expect ( JSON . stringify ( res ) ) . toEqual ( `{"a":{"value":123,"type":"number"},"b":{"value":"123","type":"string"},"c":{"value":{"hello":"world 123"},"type":"object"},"d":{"value":[1,2,3],"type":"object"}}` )
119
128
} ) ;
120
129
121
130
it ( 'should be able to invoke an actor through the client which abstracts the actor proxy builder for people unaware of patterns' , async ( ) => {
122
- const actor = client . actor . create < DemoActorSayImpl > ( DemoActorSayImpl ) ;
131
+ const actor = client . actor . create < DemoActorSayInterface > ( DemoActorSayImpl ) ;
123
132
const res = await actor . sayMulti ( 123 , "123" , { hello : "world 123" } , [ 1 , 2 , 3 ] ) ;
124
133
expect ( JSON . stringify ( res ) ) . toEqual ( `{"a":{"value":123,"type":"number"},"b":{"value":"123","type":"string"},"c":{"value":{"hello":"world 123"},"type":"object"},"d":{"value":[1,2,3],"type":"object"}}` )
125
134
} ) ;
126
135
} ) ;
127
136
128
137
describe ( 'timers' , ( ) => {
129
138
it ( 'should fire a timer correctly (expected execution time > 5s)' , async ( ) => {
130
- const builder = new ActorProxyBuilder < DemoActorTimerImpl > ( DemoActorTimerImpl , client ) ;
139
+ const builder = new ActorProxyBuilder < DemoActorTimerInterface > ( DemoActorTimerImpl , client ) ;
131
140
const actor = builder . build ( ActorId . createRandomId ( ) ) ;
132
141
133
142
// Activate our actor
@@ -166,7 +175,7 @@ describe('http/actors', () => {
166
175
167
176
describe ( 'reminders' , ( ) => {
168
177
it ( 'should be able to unregister a reminder' , async ( ) => {
169
- const builder = new ActorProxyBuilder < DemoActorReminderImpl > ( DemoActorReminderImpl , client ) ;
178
+ const builder = new ActorProxyBuilder < DemoActorReminderInterface > ( DemoActorReminderImpl , client ) ;
170
179
const actor = builder . build ( ActorId . createRandomId ( ) ) ;
171
180
172
181
// Activate our actor
@@ -195,7 +204,7 @@ describe('http/actors', () => {
195
204
} ) ;
196
205
197
206
it ( 'should fire a reminder but with a warning if it\'s not implemented correctly' , async ( ) => {
198
- const builder = new ActorProxyBuilder < DemoActorReminder2Impl > ( DemoActorReminder2Impl , client ) ;
207
+ const builder = new ActorProxyBuilder < DemoActorReminderInterface > ( DemoActorReminder2Impl , client ) ;
199
208
const actorId = ActorId . createRandomId ( ) ;
200
209
const actor = builder . build ( actorId ) ;
201
210
0 commit comments