Skip to content

Commit

Permalink
allow StartEgress override in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed Jun 25, 2024
1 parent 245b072 commit e71c86d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (r *Runner) startEgress(t *testing.T, req *rpc.StartEgressRequest) string {

func (r *Runner) sendRequest(t *testing.T, req *rpc.StartEgressRequest) *livekit.EgressInfo {
// send start request
info, err := r.client.StartEgress(context.Background(), "", req)
info, err := r.start(context.Background(), req)

// check returned egress info
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ func TestEgress(t *testing.T) {
svc, err := server.NewServer(r.ServiceConfig, bus, ioClient)
require.NoError(t, err)

r.Run(t, svc, bus, rfs)
r.StartServer(t, svc, bus, rfs)
r.RunTests(t)
}
2 changes: 1 addition & 1 deletion test/room_composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (r *Runner) testRoomCompositeStream(t *testing.T) {
},
}

info, err := r.client.StartEgress(context.Background(), "", req)
info, err := r.start(context.Background(), req)
require.NoError(t, err)
require.Empty(t, info.Error)
require.NotEmpty(t, info.EgressId)
Expand Down
10 changes: 9 additions & 1 deletion test/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package test

import (
"context"
"encoding/json"
"fmt"
"io/fs"
Expand All @@ -38,6 +39,8 @@ import (
)

type Runner struct {
StartEgress func(ctx context.Context, request *rpc.StartEgressRequest) (*livekit.EgressInfo, error) `yaml:"-"`

svc Server `yaml:"-"`
client rpc.EgressClient `yaml:"-"`
room *lksdk.Room `yaml:"-"`
Expand Down Expand Up @@ -154,7 +157,7 @@ func NewRunner(t *testing.T) *Runner {
return r
}

func (r *Runner) Run(t *testing.T, svc Server, bus psrpc.MessageBus, templateFs fs.FS) {
func (r *Runner) StartServer(t *testing.T, svc Server, bus psrpc.MessageBus, templateFs fs.FS) {
lksdk.SetLogger(logger.LogRLogger(logr.Discard()))
r.svc = svc
t.Cleanup(func() {
Expand All @@ -177,6 +180,9 @@ func (r *Runner) Run(t *testing.T, svc Server, bus psrpc.MessageBus, templateFs

psrpcClient, err := rpc.NewEgressClient(rpc.ClientParams{Bus: bus})
require.NoError(t, err)
r.StartEgress = func(ctx context.Context, req *rpc.StartEgressRequest) (*livekit.EgressInfo, error) {
return psrpcClient.StartEgress(ctx, "", req)
}

// start templates handler
err = r.svc.StartTemplatesServer(templateFs)
Expand All @@ -201,7 +207,9 @@ func (r *Runner) Run(t *testing.T, svc Server, bus psrpc.MessageBus, templateFs
require.Len(t, status, 1)
require.Contains(t, status, "CpuLoad")
}
}

func (r *Runner) RunTests(t *testing.T) {
// run tests
r.testRoomComposite(t)
r.testWeb(t)
Expand Down

0 comments on commit e71c86d

Please sign in to comment.