Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foo #35

Closed
wants to merge 7 commits into from
Closed

Foo #35

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/placement/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,16 @@ func (p *Service) ReportDaprStatus(stream placementv1pb.Placement_ReportDaprStat
// We need to use a background context here so dissemination isn't tied to the context of this stream
placementTable := p.raftNode.FSM().PlacementState(p.minAPILevel < NoVirtualNodesInPlacementTablesAPILevel)

err = p.performTablesUpdate(context.Background(), []placementGRPCStream{stream}, placementTable)
ctx, cancel := context.WithCancel(context.Background())
go func() {
select {
case <-ctx.Done():
case <-p.closedCh:
cancel()
}
}()
err = p.performTablesUpdate(ctx, []placementGRPCStream{stream}, placementTable)
cancel()
if err != nil {
return err
}
Expand Down
25 changes: 4 additions & 21 deletions tests/integration/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ type options struct {
// Option is a function that configures the Framework's options.
type Option func(*options)

type Framework struct {
procs []process.Interface
}

func Run(t *testing.T, ctx context.Context, opts ...Option) *Framework {
func Run(t *testing.T, ctx context.Context, opts ...Option) {
t.Helper()

o := options{}
Expand All @@ -41,22 +37,9 @@ func Run(t *testing.T, ctx context.Context, opts ...Option) *Framework {

t.Logf("starting %d processes", len(o.procs))

for _, proc := range o.procs {
for i, proc := range o.procs {
i := i
proc.Run(t, ctx)
}

return &Framework{
procs: o.procs,
}
}

func (f *Framework) Cleanup(t *testing.T) {
t.Helper()

t.Logf("stopping %d processes", len(f.procs))

// Cleanup processes in reverse order in a stack fashion (same as t.Cleanup).
for i := len(f.procs) - 1; i >= 0; i-- {
f.procs[i].Cleanup(t)
t.Cleanup(func() { o.procs[i].Cleanup(t) })
}
}
1 change: 1 addition & 0 deletions tests/integration/framework/process/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (e *exec) Run(t *testing.T, ctx context.Context) {
for k, v := range e.envs {
e.cmd.Env = append(e.cmd.Env, k+"="+v)
}
e.cmd.Env = append(e.cmd.Env, "DAPR_HOST_IP=127.0.0.1")

require.NoError(t, e.cmd.Start())
}
Expand Down
8 changes: 1 addition & 7 deletions tests/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ func RunIntegrationTests(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
t.Cleanup(cancel)

f := framework.Run(t, ctx, options...)

t.Cleanup(func() {
t.Log("cleaning up framework")
f.Cleanup(t)
t.Log("done")
})
framework.Run(t, ctx, options...)

t.Run("run", func(t *testing.T) {
t.Log("running test case")
Expand Down
Loading