Skip to content

Commit

Permalink
Use whip-client to run integration test (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben authored May 2, 2023
1 parent f46fb18 commit 4b96b7e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "test/livekit-whip-bot"]
path = test/livekit-whip-bot
url = https://github.com/cloudwebrtc/livekit-whip-bot
branch = test_devices
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/livekit/go-rtmp v0.0.0-20230317185657-6e9cfa387c7e
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/protocol v1.5.6-0.20230428212533-59f4b6592830
github.com/livekit/protocol v1.5.6-0.20230501213748-b2974692ebfd
github.com/livekit/psrpc v0.3.0
github.com/livekit/server-sdk-go v1.0.11-0.20230428163439-17d5bea0992f
github.com/pion/interceptor v0.1.13
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ github.com/livekit/mediatransportutil v0.0.0-20230326055817-ed569ca13d26 h1:QlQF
github.com/livekit/mediatransportutil v0.0.0-20230326055817-ed569ca13d26/go.mod h1:eDA41kiySZoG+wy4Etsjb3w0jjLx69i/vAmSjG4bteA=
github.com/livekit/protocol v1.5.6-0.20230428212533-59f4b6592830 h1:nEB2JwJQ+QuV5jcsiABlmk6Pq8i3kS4XgpWjStP3qLQ=
github.com/livekit/protocol v1.5.6-0.20230428212533-59f4b6592830/go.mod h1:MBW05GWdhbl+o6u2gLLCQtDvr9EvcV4VWckpIYtoM2c=
github.com/livekit/protocol v1.5.6-0.20230501213748-b2974692ebfd h1:5gCLKGemm4JCEZvKIPpKVPOpguFt3/S2ZzYQd+4tInA=
github.com/livekit/protocol v1.5.6-0.20230501213748-b2974692ebfd/go.mod h1:MBW05GWdhbl+o6u2gLLCQtDvr9EvcV4VWckpIYtoM2c=
github.com/livekit/psrpc v0.3.0 h1:giBZsfM3CWA0oIYXofsMITbVQtyW7u/ES9sQmVspHPM=
github.com/livekit/psrpc v0.3.0/go.mod h1:n6JntEg+zT6Ji8InoyTpV7wusPNwGqqtxmHlkNhDN0U=
github.com/livekit/server-sdk-go v1.0.11-0.20230428163439-17d5bea0992f h1:qFN5FpDwzjjeSMcUJnXK0gzSOFyHGVk2zR0uQEEWG0I=
Expand Down
9 changes: 9 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func Integration(configFile string) error {
}

func Retest(configFile string) error {
err := WhipClient()
if err != nil {
return err
}

cmd := exec.Command("go", "test", "-v", "-count=1", "--tags=integration", "./test/...")

brewPrefix, err := getBrewPrefix()
Expand Down Expand Up @@ -110,6 +115,10 @@ func Publish(ingressId string) error {
return run(fmt.Sprintf("gst-launch-1.0 -v flvmux name=mux ! rtmp2sink location=rtmp://localhost:1935/live/%s audiotestsrc freq=200 ! faac ! mux. videotestsrc pattern=ball is-live=true ! video/x-raw,width=1280,height=720 ! x264enc speed-preset=3 ! mux.", ingressId))
}

func WhipClient() error {
return run("go build -C ./test/livekit-whip-bot/cmd/whip-client/ ./...")
}

// helpers

func getBrewPrefix() (string, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var (
ErrInvalidAudioPreset = psrpc.NewErrorf(psrpc.InvalidArgument, "invalid audio encoding preset")
ErrInvalidVideoPreset = psrpc.NewErrorf(psrpc.InvalidArgument, "invalid video encoding preset")
ErrSourceNotReady = psrpc.NewErrorf(psrpc.FailedPrecondition, "source encoder not ready")
ErrInvalidIngressType = psrpc.NewErrorf(psrpc.InvalidArgument, "invalid ingress type")
ErrUnsupportedDecodeFormat = psrpc.NewErrorf(psrpc.InvalidArgument, "unsupported mime type for the source media")
ErrUnsupportedEncodeFormat = psrpc.NewErrorf(psrpc.InvalidArgument, "unsupported mime type for encoder")
ErrUnableToAddPad = psrpc.NewErrorf(psrpc.Internal, "could not add pads to bin")
Expand Down
3 changes: 2 additions & 1 deletion pkg/media/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/livekit/ingress/pkg/media/whip"
"github.com/livekit/ingress/pkg/params"
"github.com/livekit/ingress/pkg/types"
"github.com/livekit/protocol/ingress"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
)
Expand Down Expand Up @@ -83,7 +84,7 @@ func CreateSource(ctx context.Context, p *params.Params) (Source, error) {
case livekit.IngressInput_WHIP_INPUT:
return whip.NewWHIPSource(ctx, p)
default:
return nil, errors.ErrInvalidIngressType
return nil, ingress.ErrInvalidIngressType
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (s *Service) handleNewPublisher(ctx context.Context, streamKey string, inpu
}

if inputType != resp.Info.InputType {
return nil, errors.ErrInvalidIngressType
return nil, ingress.ErrInvalidIngressType
}

// check cpu load
Expand Down
6 changes: 3 additions & 3 deletions test/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func RunTestSuite(t *testing.T, conf *TestConfig, bus psrpc.MessageBus) {
if !conf.WhipOnly {
RunRTMPTest(t, conf, bus)
}
// if !conf.RtmpOnly {
// RunWHIPTest(t, conf, bus)
// }
if !conf.RtmpOnly {
RunWHIPTest(t, conf, bus)
}
}
1 change: 1 addition & 0 deletions test/livekit-whip-bot
Submodule livekit-whip-bot added at 9794db
8 changes: 5 additions & 3 deletions test/whip.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os/exec"
"strings"
"syscall"
"testing"
"time"

Expand All @@ -19,9 +20,8 @@ import (
"github.com/stretchr/testify/require"
)

// TODO bundle tool
const (
whipClientPath = "whip-client"
whipClientPath = "livekit-whip-bot/cmd/whip-client/whip-client"
)

func RunWHIPTest(t *testing.T, conf *TestConfig, bus psrpc.MessageBus) {
Expand All @@ -35,7 +35,7 @@ func RunWHIPTest(t *testing.T, conf *TestConfig, bus psrpc.MessageBus) {
commandPsrpcClient, err := rpc.NewIngressHandlerClient("ingress_test_client", bus, psrpc.WithClientTimeout(5*time.Second))
require.NoError(t, err)

whipsrv := whip.NewWHIPServer()
whipsrv := whip.NewWHIPServer(commandPsrpcClient)
relay := service.NewRelay(nil, whipsrv)

err = whipsrv.Start(conf.Config, svc.HandleWHIPPublishRequest)
Expand Down Expand Up @@ -128,4 +128,6 @@ func RunWHIPTest(t *testing.T, conf *TestConfig, bus psrpc.MessageBus) {

final := <-updates
require.NotEqual(t, final.State.Status, livekit.IngressState_ENDPOINT_ERROR)

syscall.Kill(cmd.Process.Pid, syscall.SIGTERM)
}

0 comments on commit 4b96b7e

Please sign in to comment.