Skip to content

Commit

Permalink
Test Integration: speed up tests 10% (dapr#7528)
Browse files Browse the repository at this point in the history
* Test Integration: speed up tests 10%

Speed up integration tests by changing poll intervals
`100*time.Millisecond` to `10*time.Millisecond`.

~4.50m to ~4.20m

Signed-off-by: joshvanl <me@joshvanl.dev>

* Wait for operator healthz before exiting to ensure no exit error

Signed-off-by: joshvanl <me@joshvanl.dev>

---------

Signed-off-by: joshvanl <me@joshvanl.dev>
  • Loading branch information
JoshVanL authored Feb 12, 2024
1 parent 2e6cc9a commit 7a2886b
Show file tree
Hide file tree
Showing 85 changed files with 232 additions and 228 deletions.
8 changes: 4 additions & 4 deletions tests/integration/framework/process/daprd/daprd.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (d *Daprd) WaitUntilTCPReady(t *testing.T, ctx context.Context) {
}
net.Close()
return true
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}

func (d *Daprd) WaitUntilRunning(t *testing.T, ctx context.Context) {
Expand All @@ -198,7 +198,7 @@ func (d *Daprd) WaitUntilRunning(t *testing.T, ctx context.Context) {
}
defer resp.Body.Close()
return http.StatusNoContent == resp.StatusCode
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}

func (d *Daprd) WaitUntilAppHealth(t *testing.T, ctx context.Context) {
Expand All @@ -216,7 +216,7 @@ func (d *Daprd) WaitUntilAppHealth(t *testing.T, ctx context.Context) {
}
defer resp.Body.Close()
return http.StatusNoContent == resp.StatusCode
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)

case "grpc":
assert.Eventually(t, func() bool {
Expand All @@ -234,7 +234,7 @@ func (d *Daprd) WaitUntilAppHealth(t *testing.T, ctx context.Context) {
out := rtv1.HealthCheckResponse{}
err = conn.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallbackHealthCheck/HealthCheck", &in, &out)
return err == nil
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/framework/process/logline/logline.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ func (l *LogLine) Stderr() io.WriteCloser {
}

func (l *LogLine) EventuallyFoundAll(t *testing.T) {
assert.Eventually(t, l.FoundAll, time.Second*20, time.Millisecond*100)
assert.Eventually(t, l.FoundAll, time.Second*20, time.Millisecond*10)
}
2 changes: 1 addition & 1 deletion tests/integration/framework/process/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (o *Operator) WaitUntilRunning(t *testing.T, ctx context.Context) {
}
defer resp.Body.Close()
return http.StatusOK == resp.StatusCode
}, time.Second*5, 100*time.Millisecond)
}, time.Second*5, 10*time.Millisecond)
}

func (o *Operator) Port() int {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/framework/process/placement/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (p *Placement) WaitUntilRunning(t *testing.T, ctx context.Context) {
}
defer resp.Body.Close()
return http.StatusOK == resp.StatusCode
}, time.Second*5, 100*time.Millisecond)
}, time.Second*5, 10*time.Millisecond)
}

func (p *Placement) ID() string {
Expand Down Expand Up @@ -201,7 +201,7 @@ func (p *Placement) RegisterHost(t *testing.T, parentCtx context.Context, msg *p
_ = stream.CloseSend()
return
}
}, time.Second*15, time.Millisecond*100)
}, time.Second*15, time.Millisecond*10)

doneCh := make(chan error)
placementUpdateCh := make(chan *placementv1pb.PlacementTables)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/framework/process/sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s *Sentry) WaitUntilRunning(t *testing.T, ctx context.Context) {
defer resp.Body.Close()
assert.Equal(c, http.StatusOK, resp.StatusCode)
}
}, time.Second*20, 100*time.Millisecond)
}, time.Second*20, 10*time.Millisecond)
}

func (s *Sentry) TrustAnchorsFile(t *testing.T) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *StateStore) Run(t *testing.T, ctx context.Context) {
_, err = client.Ping(ctx, new(compv1pb.PingRequest))
//nolint:testifylint
assert.NoError(c, err)
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
require.NoError(t, conn.Close())
}

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/suite/actors/grpc/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) {
})
//nolint:testifylint
assert.NoError(c, err)
}, time.Second*20, time.Millisecond*100, "actor not ready")
}, time.Second*20, time.Millisecond*10, "actor not ready")

now := time.Now()

Expand Down Expand Up @@ -174,6 +174,6 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) {
require.NoError(c, err)
assert.Empty(c, resp.GetData())
assert.Empty(c, resp.GetMetadata())
}, 5*time.Second, 100*time.Millisecond)
}, 5*time.Second, 10*time.Millisecond)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (h *deactivateOnPlacementFail) Run(t *testing.T, ctx context.Context) {
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
assert.Equalf(t, http.StatusOK, resp.StatusCode, "Response body: %v", string(body))
}, 10*time.Second, 100*time.Millisecond, "actor not ready")
}, 10*time.Second, 10*time.Millisecond, "actor not ready")
}

// Validate invocations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (a *allenabled) Run(t *testing.T, ctx context.Context) {
assert.Len(c, meta.GetActorRuntime().GetActiveActors(), 1)
assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus())
assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement())
}, time.Second*30, time.Millisecond*100)
}, time.Second*30, time.Millisecond*10)

select {
case <-a.healthzCalled:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/suite/actors/healthz/endpoint/noapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (n *noapp) Run(t *testing.T, ctx context.Context) {
assert.Len(c, meta.GetActorRuntime().GetActiveActors(), 1)
assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus())
assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement())
}, time.Second*30, time.Millisecond*100)
}, time.Second*30, time.Millisecond*10)

select {
case <-n.healthzCalled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (n *noappentities) Run(t *testing.T, ctx context.Context) {
assert.Equal(c, tv.activeActors, meta.GetActorRuntime().GetActiveActors())
assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus())
assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement())
}, time.Second*30, time.Millisecond*100)
}, time.Second*30, time.Millisecond*10)
}

select {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (n *noentities) Run(t *testing.T, ctx context.Context) {
assert.Equal(c, tv.activeActors, meta.GetActorRuntime().GetActiveActors())
assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus())
assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement())
}, time.Second*30, time.Millisecond*100)
}, time.Second*30, time.Millisecond*10)
}

select {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/suite/actors/healthz/endpoint/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (p *path) Run(t *testing.T, ctx context.Context) {
assert.Len(c, meta.GetActorRuntime().GetActiveActors(), 1)
assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus())
assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement())
}, time.Second*30, time.Millisecond*100)
}, time.Second*30, time.Millisecond*10)

select {
case <-p.customHealthz:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/suite/actors/http/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) {
require.NoError(c, resp.Body.Close())
assert.Equal(c, http.StatusOK, resp.StatusCode)
}
}, time.Second*20, time.Millisecond*100, "actor not ready")
}, time.Second*20, time.Millisecond*10, "actor not ready")

now := time.Now()

Expand Down Expand Up @@ -181,6 +181,6 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) {
require.NoError(c, resp.Body.Close())
assert.Empty(c, string(body))
assert.Equal(c, http.StatusNoContent, resp.StatusCode)
}, 5*time.Second, 100*time.Millisecond)
}, 5*time.Second, 10*time.Millisecond)
})
}
2 changes: 1 addition & 1 deletion tests/integration/suite/actors/metadata/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ func (m *client) Run(t *testing.T, ctx context.Context) {
assert.False(t, res.ActorRuntime.HostReady)
assert.Equal(t, "placement: connected", res.ActorRuntime.Placement)
assert.Empty(t, res.ActorRuntime.ActiveActors, 0)
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}
2 changes: 1 addition & 1 deletion tests/integration/suite/actors/metadata/disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ func (m *disabled) Run(t *testing.T, ctx context.Context) {
assert.False(t, res.ActorRuntime.HostReady)
assert.Empty(t, res.ActorRuntime.Placement)
assert.Empty(t, res.ActorRuntime.ActiveActors)
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}
2 changes: 1 addition & 1 deletion tests/integration/suite/actors/metadata/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ func (m *host) Run(t *testing.T, ctx context.Context) {
assert.Equal(t, "myactortype", res.ActorRuntime.ActiveActors[0].Type)
assert.Equal(t, 0, res.ActorRuntime.ActiveActors[0].Count)
}
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ func (m *hostNoPlacement) Run(t *testing.T, ctx context.Context) {
assert.Equal(t, "myactortype", res.ActorRuntime.ActiveActors[0].Type)
assert.Equal(t, 0, res.ActorRuntime.ActiveActors[0].Count)
}
}, 10*time.Second, 100*time.Millisecond)
}, 10*time.Second, 10*time.Millisecond)
}
6 changes: 3 additions & 3 deletions tests/integration/suite/actors/reminders/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (b *basic) Run(t *testing.T, ctx context.Context) {
assert.NoError(c, resp.Body.Close())
assert.Equal(c, http.StatusOK, resp.StatusCode)
}
}, time.Second*10, time.Millisecond*100, "actor not ready in time")
}, time.Second*10, time.Millisecond*10, "actor not ready in time")

body := `{"dueTime": "0ms"}`
req, err = http.NewRequestWithContext(ctx, http.MethodPost, daprdURL+"/reminders/remindermethod", strings.NewReader(body))
Expand All @@ -105,7 +105,7 @@ func (b *basic) Run(t *testing.T, ctx context.Context) {

assert.Eventually(t, func() bool {
return b.methodcalled.Load() == 1
}, time.Second*3, time.Millisecond*100)
}, time.Second*3, time.Millisecond*10)

conn, err := grpc.DialContext(ctx, b.daprd.GRPCAddress(),
grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(),
Expand All @@ -124,5 +124,5 @@ func (b *basic) Run(t *testing.T, ctx context.Context) {

assert.Eventually(t, func() bool {
return b.methodcalled.Load() == 2
}, time.Second*3, time.Millisecond*100)
}, time.Second*3, time.Millisecond*10)
}
4 changes: 2 additions & 2 deletions tests/integration/suite/actors/reminders/rebalancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (i *rebalancing) Run(t *testing.T, ctx context.Context) {
assert.Equal(c, http.StatusOK, resp.StatusCode)
}
}
}, 15*time.Second, 100*time.Millisecond, "actors not ready")
}, 15*time.Second, 10*time.Millisecond, "actors not ready")

// Do a bunch of things in parallel
errCh := make(chan error)
Expand Down Expand Up @@ -371,7 +371,7 @@ func (i *rebalancing) getPlacementStream(t *testing.T, ctx context.Context) plac
stream.CloseSend()
stream = nil
}
}, time.Second*20, time.Millisecond*100)
}, time.Second*20, time.Millisecond*10)

return stream
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func invokeActor(t *testing.T, ctx context.Context, baseURL string, client *http
assert.NoError(c, resp.Body.Close())
assert.Equal(c, http.StatusOK, resp.StatusCode)
}
}, time.Second*20, time.Millisecond*100, "actor not ready in time")
}, time.Second*20, time.Millisecond*10, "actor not ready in time")
}

func storeReminder(t *testing.T, ctx context.Context, baseURL string, client *http.Client) {
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/suite/daprd/binding/input/appready.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ func (a *appready) Run(t *testing.T, ctx context.Context) {
resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest))
require.NoError(t, err)
assert.Len(c, resp.GetRegisteredComponents(), 1)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)

called := a.healthCalled.Load()
require.Eventually(t, func() bool { return a.healthCalled.Load() > called }, time.Second*5, time.Millisecond*100)
require.Eventually(t, func() bool { return a.healthCalled.Load() > called }, time.Second*5, time.Millisecond*10)

assert.Eventually(t, func() bool {
resp, err := httpClient.Do(req)
require.NoError(t, err)
defer resp.Body.Close()
return resp.StatusCode == http.StatusInternalServerError
}, time.Second*5, 100*time.Millisecond)
}, time.Second*5, 10*time.Millisecond)

time.Sleep(time.Second * 2)
assert.Equal(t, int64(0), a.bindingCalled.Load())
Expand All @@ -132,11 +132,11 @@ func (a *appready) Run(t *testing.T, ctx context.Context) {
require.NoError(t, err)
defer resp.Body.Close()
return resp.StatusCode == http.StatusOK
}, time.Second*5, 100*time.Millisecond)
}, time.Second*5, 10*time.Millisecond)

assert.Eventually(t, func() bool {
return a.bindingCalled.Load() > 0
}, time.Second*5, 100*time.Millisecond)
}, time.Second*5, 10*time.Millisecond)

// Should stop calling binding when app becomes unhealthy
a.appHealthy.Store(false)
Expand All @@ -145,7 +145,7 @@ func (a *appready) Run(t *testing.T, ctx context.Context) {
require.NoError(t, err)
defer resp.Body.Close()
return resp.StatusCode == http.StatusInternalServerError
}, time.Second*5, 100*time.Millisecond)
}, time.Second*5, 10*time.Millisecond)
called = a.bindingCalled.Load()
time.Sleep(time.Second * 2)
assert.Equal(t, called, a.bindingCalled.Load())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) {
//nolint:testifylint
assert.NoError(c, err)
assert.Len(c, resp.GetRegisteredComponents(), 1)
}, time.Second*20, time.Millisecond*100)
}, time.Second*20, time.Millisecond*10)
g.expectBinding(t, 0, "binding1")
})

Expand Down Expand Up @@ -184,7 +184,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) {
resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest))
require.NoError(t, err)
assert.Len(c, resp.GetRegisteredComponents(), 2)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
g.expectBindings(t, []bindingPair{
{0, "binding1"},
{1, "binding2"},
Expand Down Expand Up @@ -218,7 +218,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) {
resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest))
require.NoError(t, err)
assert.Len(c, resp.GetRegisteredComponents(), 3)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
g.expectBindings(t, []bindingPair{
{0, "binding1"},
{1, "binding2"},
Expand All @@ -234,7 +234,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) {
resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest))
require.NoError(t, err)
assert.Len(c, resp.GetRegisteredComponents(), 2)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
g.registered[0].Store(false)
g.expectBindings(t, []bindingPair{
{1, "binding2"},
Expand All @@ -252,7 +252,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) {
resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest))
require.NoError(c, err)
assert.Empty(c, resp.GetRegisteredComponents())
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
g.registered[1].Store(false)
g.registered[2].Store(false)
// Sleep to ensure binding is not triggered.
Expand Down Expand Up @@ -286,7 +286,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) {
resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest))
require.NoError(t, err)
assert.Len(c, resp.GetRegisteredComponents(), 1)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
g.expectBinding(t, 0, "binding1")
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) {

require.EventuallyWithT(t, func(c *assert.CollectT) {
assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
h.expectBindings(t, []bindingPair{
{0, "binding1"},
{1, "binding2"},
Expand Down Expand Up @@ -206,7 +206,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) {

require.EventuallyWithT(t, func(c *assert.CollectT) {
assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 3)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
h.expectBindings(t, []bindingPair{
{0, "binding1"},
{1, "binding2"},
Expand All @@ -221,7 +221,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) {

require.EventuallyWithT(t, func(c *assert.CollectT) {
assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
h.registered[0].Store(false)
h.expectBindings(t, []bindingPair{
{1, "binding2"},
Expand All @@ -237,7 +237,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) {
h.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp2, EventType: operatorv1.ResourceEventType_DELETED})
require.EventuallyWithT(t, func(c *assert.CollectT) {
assert.Empty(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()))
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
h.registered[1].Store(false)
h.registered[2].Store(false)
// Sleep to ensure binding is not triggered.
Expand Down Expand Up @@ -269,7 +269,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) {

require.EventuallyWithT(t, func(c *assert.CollectT) {
assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1)
}, time.Second*5, time.Millisecond*100)
}, time.Second*5, time.Millisecond*10)
h.expectBinding(t, 0, "binding1")
})
}
Expand Down
Loading

0 comments on commit 7a2886b

Please sign in to comment.