Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Elena Kolevska <elena@kolevska.com>
  • Loading branch information
elena-kolevska committed Jan 16, 2024
1 parent 8a63d68 commit f7adb0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/actors/placement/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestConnectToServer(t *testing.T) {
// All keys in the returned MD are lowercase, as per the http spec for header fields
// https://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2
apiLevelValues := md["apilevel"]
require.Len(t, len(apiLevelValues), 1)
require.Len(t, apiLevelValues, 1)

apiLevelStr := apiLevelValues[0]
require.Equal(t, "10", apiLevelStr)
Expand Down
14 changes: 14 additions & 0 deletions pkg/actors/placement/placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
"github.com/dapr/kit/logger"
)

var apiLevel atomic.Uint32

func TestAddDNSResolverPrefix(t *testing.T) {
testCases := []struct {
addr []string
Expand Down Expand Up @@ -69,6 +71,7 @@ func TestPlacementStream_RoundRobin(t *testing.T) {
address[i], testSrv[i], cleanup[i] = newTestServer()
}

apiLevel.Store(1)
testPlacement := NewActorPlacement(internal.ActorsProviderOptions{
Config: internal.Config{
PlacementAddresses: address,
Expand All @@ -81,6 +84,7 @@ func TestPlacementStream_RoundRobin(t *testing.T) {
AppHealthFn: func(ctx context.Context) <-chan bool { return nil },
Security: testSecurity(t),
Resiliency: resiliency.New(logger.NewLogger("test")),
APILevel: &apiLevel,
}).(*actorPlacement)

t.Run("found leader placement in a round robin way", func(t *testing.T) {
Expand Down Expand Up @@ -129,6 +133,7 @@ func TestAppHealthyStatus(t *testing.T) {

appHealthCh := make(chan bool)

apiLevel.Store(1)
testPlacement := NewActorPlacement(internal.ActorsProviderOptions{
Config: internal.Config{
PlacementAddresses: []string{address},
Expand All @@ -141,6 +146,7 @@ func TestAppHealthyStatus(t *testing.T) {
AppHealthFn: func(ctx context.Context) <-chan bool { return appHealthCh },
Security: testSecurity(t),
Resiliency: resiliency.New(logger.NewLogger("test")),
APILevel: &apiLevel,
}).(*actorPlacement)

// act
Expand All @@ -165,6 +171,7 @@ func TestAppHealthyStatus(t *testing.T) {
func TestOnPlacementOrder(t *testing.T) {
tableUpdateCount := atomic.Int64{}
tableUpdateFunc := func() { tableUpdateCount.Add(1) }
apiLevel.Store(1)
testPlacement := NewActorPlacement(internal.ActorsProviderOptions{
Config: internal.Config{
PlacementAddresses: []string{},
Expand All @@ -177,6 +184,7 @@ func TestOnPlacementOrder(t *testing.T) {
AppHealthFn: func(ctx context.Context) <-chan bool { return nil },
Security: testSecurity(t),
Resiliency: resiliency.New(logger.NewLogger("test")),
APILevel: &apiLevel,
}).(*actorPlacement)
testPlacement.SetOnTableUpdateFn(tableUpdateFunc)

Expand Down Expand Up @@ -234,6 +242,7 @@ func TestOnPlacementOrder(t *testing.T) {
}

func TestWaitUntilPlacementTableIsReady(t *testing.T) {
apiLevel.Store(1)
testPlacement := NewActorPlacement(internal.ActorsProviderOptions{
Config: internal.Config{
PlacementAddresses: []string{},
Expand All @@ -246,6 +255,7 @@ func TestWaitUntilPlacementTableIsReady(t *testing.T) {
AppHealthFn: func(ctx context.Context) <-chan bool { return nil },
Security: testSecurity(t),
Resiliency: resiliency.New(logger.NewLogger("test")),
APILevel: &apiLevel,
}).(*actorPlacement)

// Set the hasPlacementTablesCh channel to nil for the first tests, indicating that the placement tables already exist
Expand Down Expand Up @@ -373,6 +383,7 @@ func TestWaitUntilPlacementTableIsReady(t *testing.T) {
}

func TestLookupActor(t *testing.T) {
apiLevel.Store(1)
testPlacement := NewActorPlacement(internal.ActorsProviderOptions{
Config: internal.Config{
PlacementAddresses: []string{},
Expand All @@ -385,6 +396,7 @@ func TestLookupActor(t *testing.T) {
AppHealthFn: func(ctx context.Context) <-chan bool { return nil },
Security: testSecurity(t),
Resiliency: resiliency.New(logger.NewLogger("test")),
APILevel: &apiLevel,
}).(*actorPlacement)

t.Run("Placement table is unset", func(t *testing.T) {
Expand Down Expand Up @@ -430,6 +442,7 @@ func TestLookupActor(t *testing.T) {
}

func TestConcurrentUnblockPlacements(t *testing.T) {
apiLevel.Store(1)
testPlacement := NewActorPlacement(internal.ActorsProviderOptions{
Config: internal.Config{
PlacementAddresses: []string{},
Expand All @@ -442,6 +455,7 @@ func TestConcurrentUnblockPlacements(t *testing.T) {
AppHealthFn: func(ctx context.Context) <-chan bool { return nil },
Security: testSecurity(t),
Resiliency: resiliency.New(logger.NewLogger("test")),
APILevel: &apiLevel,
}).(*actorPlacement)

// Set the hasPlacementTablesCh channel to nil for the first tests, indicating that the placement tables already exist
Expand Down

0 comments on commit f7adb0f

Please sign in to comment.