@@ -13,20 +13,25 @@ limitations under the License.
1313
1414import { CommunicationProtocolEnum , DaprClient , DaprServer } from '../../src' ;
1515
16+ import * as NodeJSUtil from '../../src/utils/NodeJS.util' ;
17+ import ActorId from '../../src/actors/ActorId' ;
18+ import ActorProxyBuilder from '../../src/actors/client/ActorProxyBuilder' ;
1619import DemoActorActivateImpl from '../actor/DemoActorActivateImpl' ;
1720import DemoActorCounterImpl from '../actor/DemoActorCounterImpl' ;
21+ import DemoActorCounterInterface from '../actor/DemoActorCounterInterface' ;
1822import DemoActorReminderImpl from '../actor/DemoActorReminderImpl' ;
1923import DemoActorReminder2Impl from '../actor/DemoActorReminder2Impl' ;
24+ import DemoActorReminderInterface from '../actor/DemoActorReminderInterface' ;
2025import DemoActorSayImpl from '../actor/DemoActorSayImpl' ;
26+ import DemoActorSayInterface from '../actor/DemoActorSayInterface' ;
2127import 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' ;
2529
2630const serverHost = "127.0.0.1" ;
2731const serverPort = "50001" ;
2832const sidecarHost = "127.0.0.1" ;
2933const sidecarPort = "50000" ;
34+ const serverStartWaitTimeMs = 5 * 1000 ;
3035
3136describe ( 'http/actors' , ( ) => {
3237 let server : DaprServer ;
@@ -59,6 +64,10 @@ describe('http/actors', () => {
5964
6065 // Start server
6166 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 ) ;
6271 } , 30 * 1000 ) ;
6372
6473 afterAll ( async ( ) => {
@@ -68,13 +77,13 @@ describe('http/actors', () => {
6877
6978 describe ( 'actorProxy' , ( ) => {
7079 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 ) ;
7281 const actor = builder . build ( ActorId . createRandomId ( ) ) ;
7382
7483 const c1 = await actor . getCounter ( ) ;
7584 expect ( c1 ) . toEqual ( 0 ) ;
7685
77- await actor . countBy ( 1 ) ;
86+ await actor . countBy ( 1 , 1 ) ;
7887 const c2 = await actor . getCounter ( ) ;
7988 expect ( c2 ) . toEqual ( 1 ) ;
8089
@@ -98,36 +107,36 @@ describe('http/actors', () => {
98107 } ) ;
99108
100109 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 ) ;
102111 const actor = builder . build ( ActorId . createRandomId ( ) ) ;
103112 const res = await actor . sayString ( "Hello World" ) ;
104113 expect ( res ) . toEqual ( `Actor said: "Hello World"` )
105114 } ) ;
106115
107116 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 ) ;
109118 const actor = builder . build ( ActorId . createRandomId ( ) ) ;
110119 const res = await actor . sayObject ( { hello : "world" } ) ;
111120 expect ( JSON . stringify ( res ) ) . toEqual ( `{"said":{"hello":"world"}}` )
112121 } ) ;
113122
114123 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 ) ;
116125 const actor = builder . build ( ActorId . createRandomId ( ) ) ;
117126 const res = await actor . sayMulti ( 123 , "123" , { hello : "world 123" } , [ 1 , 2 , 3 ] ) ;
118127 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"}}` )
119128 } ) ;
120129
121130 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 ) ;
123132 const res = await actor . sayMulti ( 123 , "123" , { hello : "world 123" } , [ 1 , 2 , 3 ] ) ;
124133 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"}}` )
125134 } ) ;
126135 } ) ;
127136
128137 describe ( 'timers' , ( ) => {
129138 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 ) ;
131140 const actor = builder . build ( ActorId . createRandomId ( ) ) ;
132141
133142 // Activate our actor
@@ -166,7 +175,7 @@ describe('http/actors', () => {
166175
167176 describe ( 'reminders' , ( ) => {
168177 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 ) ;
170179 const actor = builder . build ( ActorId . createRandomId ( ) ) ;
171180
172181 // Activate our actor
@@ -195,7 +204,7 @@ describe('http/actors', () => {
195204 } ) ;
196205
197206 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 ) ;
199208 const actorId = ActorId . createRandomId ( ) ;
200209 const actor = builder . build ( actorId ) ;
201210
0 commit comments