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

fix participant tests #854

Merged
merged 2 commits into from
Feb 7, 2025
Merged
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
1 change: 0 additions & 1 deletion build/egress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ RUN useradd -ms /bin/bash -g root -G sudo,pulse,pulse-access egress
RUN mkdir -p home/egress/tmp home/egress/.cache/xdgr && \
chown -R egress /home/egress


# copy files
COPY --from=0 /workspace/egress /bin/
COPY --from=0 /tini /tini
Expand Down
11 changes: 6 additions & 5 deletions build/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then GOARCH=arm64; else GOARCH=amd
tar -C /usr/local -xzf go1.22.1.linux-${GOARCH}.tar.gz
ENV PATH="/usr/local/go/bin:${PATH}"

# download samples
RUN apt-get update && apt-get install -y git-lfs
RUN git clone --depth 1 https://github.com/livekit/media-samples.git
RUN cd media-samples && git lfs pull

# download go modules
COPY go.mod .
COPY go.sum .
Expand Down Expand Up @@ -96,13 +101,9 @@ RUN mkdir -p home/egress/tmp home/egress/.cache/xdgr && \
COPY test/ /workspace/test/
COPY --from=0 /workspace/egress /bin/
COPY --from=0 /workspace/test.test .
COPY --from=0 /workspace/media-samples /media-samples
COPY build/test/entrypoint.sh .

# download samples
RUN apt-get update && apt-get install -y git-lfs
RUN git clone --depth 1 https://github.com/livekit/media-samples.git
RUN cd media-samples && git lfs pull

# run tests
USER egress
ENV PATH=${PATH}:/chrome
Expand Down
6 changes: 5 additions & 1 deletion pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ func NewProcessLogger(handlerID, egressID string) *ProcessLogger {

func (l *ProcessLogger) Write(p []byte) (n int, err error) {
s := string(p)
if strings.HasPrefix(s, "00:00:") {
if strings.HasSuffix(s, "}\n") {
// normal handler logs
fmt.Print(s)
} else if strings.HasPrefix(s, "0:00:") {
// ignore cuda and template not mapped gstreamer warnings
} else if strings.HasPrefix(s, "turnc") {
// warn on turnc error
Expand All @@ -77,6 +80,7 @@ func (l *ProcessLogger) Write(p []byte) (n int, err error) {
// panics and unexpected errors
l.logger.Errorw(s, nil)
}

return len(p), nil
}

Expand Down
9 changes: 7 additions & 2 deletions test/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ func (r *Runner) run(t *testing.T, test *testCase, f func(*testing.T, *testCase)
func (r *Runner) awaitIdle(t *testing.T) {
r.svc.KillAll()
for i := 0; i < 30; i++ {
if r.svc.IsIdle() {
if r.svc.IsIdle() && len(r.room.LocalParticipant.TrackPublications()) == 0 {
return
}
time.Sleep(time.Second)
}
t.Fatal("service not idle after 30s")

if !r.svc.IsIdle() {
t.Fatal("service not idle after 30s")
} else if len(r.room.LocalParticipant.TrackPublications()) != 0 {
t.Fatal("room still has tracks after 30s")
}
}

func (r *Runner) startEgress(t *testing.T, req *rpc.StartEgressRequest) string {
Expand Down
9 changes: 5 additions & 4 deletions test/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ func (r *Runner) publishSample(t *testing.T, codec types.MimeType, publishAfter,
_ = r.room.LocalParticipant.UnpublishTrack(pub.SID())
}
})
} else {
t.Cleanup(func() {
_ = r.room.LocalParticipant.UnpublishTrack(pub.SID())
})
}
})

Expand Down Expand Up @@ -133,5 +129,10 @@ func (r *Runner) publish(t *testing.T, codec types.MimeType, done chan struct{})
pub, err = r.room.LocalParticipant.PublishTrack(track, &lksdk.TrackPublicationOptions{Name: filename})
require.NoError(t, err)

trackID := pub.SID()
t.Cleanup(func() {
_ = r.room.LocalParticipant.UnpublishTrack(trackID)
})

return pub
}