@@ -30,11 +30,10 @@ import (
3030
3131// seedActor stores a running actor with all worker-binding fields populated, so
3232// tests can assert they are cleared when the actor crashes.
33- func seedActor (t * testing.T , ctx context.Context , st store.Interface , atespace , id string ) {
33+ func seedActor (t * testing.T , ctx context.Context , st store.Interface , atespace , actorName string ) {
3434 t .Helper ()
35- if err := st .CreateActor (ctx , & ateapipb.Actor {
36- ActorId : id ,
37- Atespace : atespace ,
35+ if _ , err := st .CreateActor (ctx , & ateapipb.Actor {
36+ Metadata : & ateapipb.ResourceMetadata {Name : actorName , Atespace : atespace },
3837 Status : ateapipb .Actor_STATUS_RUNNING ,
3938 AteomPodNamespace : "ns" ,
4039 AteomPodName : "pod" ,
@@ -47,11 +46,11 @@ func seedActor(t *testing.T, ctx context.Context, st store.Interface, atespace,
4746}
4847
4948// assertCrashed reloads the actor and verifies it is CRASHED.
50- func assertCrashed (t * testing.T , ctx context.Context , st store.Interface , atespace , id string ) {
49+ func assertCrashed (t * testing.T , ctx context.Context , st store.Interface , atespace , actorName string ) {
5150 t .Helper ()
52- got , err := st .GetActor (ctx , atespace , id )
51+ got , err := st .GetActor (ctx , atespace , actorName )
5352 if err != nil {
54- t .Fatalf ("GetActor(%q, %q) = %v, want nil" , atespace , id , err )
53+ t .Fatalf ("GetActor(%q, %q) = %v, want nil" , atespace , actorName , err )
5554 }
5655 if got .GetStatus () != ateapipb .Actor_STATUS_CRASHED {
5756 t .Errorf ("status = %v, want %v" , got .GetStatus (), ateapipb .Actor_STATUS_CRASHED )
@@ -60,8 +59,8 @@ func assertCrashed(t *testing.T, ctx context.Context, st store.Interface, atespa
6059
6160func TestCrashActor (t * testing.T ) {
6261 const (
63- atespace = "team-a"
64- actorID = "actor-1"
62+ atespace = "team-a"
63+ actorName = "actor-1"
6564 )
6665
6766 tests := []struct {
@@ -77,7 +76,7 @@ func TestCrashActor(t *testing.T) {
7776 if err != nil {
7877 t .Fatalf ("crashActor() = %v, want nil" , err )
7978 }
80- assertCrashed (t , ctx , st , atespace , actorID )
79+ assertCrashed (t , ctx , st , atespace , actorName )
8180 },
8281 },
8382 {
@@ -104,20 +103,20 @@ func TestCrashActor(t *testing.T) {
104103 defer cleanup ()
105104
106105 if tt .seed {
107- seedActor (t , ctx , st , atespace , actorID )
106+ seedActor (t , ctx , st , atespace , actorName )
108107 }
109108
110- err := crashActor (ctx , st , atespace , actorID )
109+ err := crashActor (ctx , st , atespace , actorName )
111110 tt .check (t , ctx , st , err )
112111 })
113112 }
114113}
115114
116115func TestMaybeCrashActor (t * testing.T ) {
117116 const (
118- atespace = "team-a"
119- actorID = "actor-1"
120- wrapMsg = "calling atelet"
117+ atespace = "team-a"
118+ actorName = "actor-1"
119+ wrapMsg = "calling atelet"
121120 )
122121
123122 crashErr := ateerrors .NewGRPCError (context .Background (), codes .NotFound , ateerrors .ReasonTerminalFileSystemError , ateerrors .ActorCrashedMetadata (), errors .New ("boom" ))
@@ -154,7 +153,7 @@ func TestMaybeCrashActor(t *testing.T) {
154153 if got := status .Code (err ); got != codes .DataLoss {
155154 t .Errorf ("status code = %v, want %v" , got , codes .DataLoss )
156155 }
157- assertCrashed (t , ctx , st , atespace , actorID )
156+ assertCrashed (t , ctx , st , atespace , actorName )
158157 },
159158 },
160159 {
@@ -188,7 +187,7 @@ func TestMaybeCrashActor(t *testing.T) {
188187 t .Errorf ("maybeCrashActor() error = %q, want prefix %q" , err , wrapMsg )
189188 }
190189 // The actor must not have been crashed.
191- got , gerr := st .GetActor (ctx , atespace , actorID )
190+ got , gerr := st .GetActor (ctx , atespace , actorName )
192191 if gerr != nil {
193192 t .Fatalf ("GetActor() = %v, want nil" , gerr )
194193 }
@@ -212,7 +211,7 @@ func TestMaybeCrashActor(t *testing.T) {
212211 t .Errorf ("maybeCrashActor() error = %q, want prefix %q" , err , wrapMsg )
213212 }
214213 // The actor must not have been crashed.
215- got , gerr := st .GetActor (ctx , atespace , actorID )
214+ got , gerr := st .GetActor (ctx , atespace , actorName )
216215 if gerr != nil {
217216 t .Fatalf ("GetActor() = %v, want nil" , gerr )
218217 }
@@ -230,10 +229,10 @@ func TestMaybeCrashActor(t *testing.T) {
230229 defer cleanup ()
231230
232231 if tt .seed {
233- seedActor (t , ctx , st , atespace , actorID )
232+ seedActor (t , ctx , st , atespace , actorName )
234233 }
235234
236- err := maybeCrashActor (ctx , st , atespace , actorID , tt .err , wrapMsg )
235+ err := maybeCrashActor (ctx , st , atespace , actorName , tt .err , wrapMsg )
237236 tt .check (t , ctx , st , err )
238237 })
239238 }
0 commit comments