diff --git a/actors/actor_system_test.go b/actors/actor_system_test.go index 221ffcd9..64b9974d 100644 --- a/actors/actor_system_test.go +++ b/actors/actor_system_test.go @@ -28,6 +28,7 @@ import ( "context" "net" "os" + "sort" "strconv" "testing" "time" @@ -1062,6 +1063,23 @@ func TestActorSystem(t *testing.T) { assert.Len(t, got.ScopeMetrics, 1) assert.Len(t, got.ScopeMetrics[0].Metrics, 4) + expected := []string{ + "actor_child_count", + "actor_stash_count", + "actor_restart_count", + "actors_count", + } + // sort the array + sort.Strings(expected) + // get the metric names + actual := make([]string, len(got.ScopeMetrics[0].Metrics)) + for i, metric := range got.ScopeMetrics[0].Metrics { + actual[i] = metric.Name + } + sort.Strings(actual) + + assert.ElementsMatch(t, expected, actual) + // stop the actor after some time time.Sleep(time.Second) diff --git a/actors/pid_test.go b/actors/pid_test.go index dc197129..dc71b970 100644 --- a/actors/pid_test.go +++ b/actors/pid_test.go @@ -27,6 +27,7 @@ package actors import ( "context" "os" + "sort" "sync" "testing" "time" @@ -1408,6 +1409,22 @@ func TestRegisterMetrics(t *testing.T) { assert.Len(t, got.ScopeMetrics, 1) assert.Len(t, got.ScopeMetrics[0].Metrics, 3) + expected := []string{ + "actor_child_count", + "actor_stash_count", + "actor_restart_count", + } + // sort the array + sort.Strings(expected) + // get the metric names + actual := make([]string, len(got.ScopeMetrics[0].Metrics)) + for i, metric := range got.ScopeMetrics[0].Metrics { + actual[i] = metric.Name + } + sort.Strings(actual) + + assert.ElementsMatch(t, expected, actual) + // stop the actor err = pid.Shutdown(ctx) assert.NoError(t, err)