Skip to content

Commit c9a1b82

Browse files
authored
fix participant tests (#854)
* fix participant tests * more updates
1 parent ddd2ee1 commit c9a1b82

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

build/egress/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ RUN useradd -ms /bin/bash -g root -G sudo,pulse,pulse-access egress
7979
RUN mkdir -p home/egress/tmp home/egress/.cache/xdgr && \
8080
chown -R egress /home/egress
8181

82-
8382
# copy files
8483
COPY --from=0 /workspace/egress /bin/
8584
COPY --from=0 /tini /tini

build/test/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then GOARCH=arm64; else GOARCH=amd
2525
tar -C /usr/local -xzf go1.22.1.linux-${GOARCH}.tar.gz
2626
ENV PATH="/usr/local/go/bin:${PATH}"
2727

28+
# download samples
29+
RUN apt-get update && apt-get install -y git-lfs
30+
RUN git clone --depth 1 https://github.com/livekit/media-samples.git
31+
RUN cd media-samples && git lfs pull
32+
2833
# download go modules
2934
COPY go.mod .
3035
COPY go.sum .
@@ -96,13 +101,9 @@ RUN mkdir -p home/egress/tmp home/egress/.cache/xdgr && \
96101
COPY test/ /workspace/test/
97102
COPY --from=0 /workspace/egress /bin/
98103
COPY --from=0 /workspace/test.test .
104+
COPY --from=0 /workspace/media-samples /media-samples
99105
COPY build/test/entrypoint.sh .
100106

101-
# download samples
102-
RUN apt-get update && apt-get install -y git-lfs
103-
RUN git clone --depth 1 https://github.com/livekit/media-samples.git
104-
RUN cd media-samples && git lfs pull
105-
106107
# run tests
107108
USER egress
108109
ENV PATH=${PATH}:/chrome

pkg/logging/logging.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ func NewProcessLogger(handlerID, egressID string) *ProcessLogger {
6868

6969
func (l *ProcessLogger) Write(p []byte) (n int, err error) {
7070
s := string(p)
71-
if strings.HasPrefix(s, "00:00:") {
71+
if strings.HasSuffix(s, "}\n") {
72+
// normal handler logs
73+
fmt.Print(s)
74+
} else if strings.HasPrefix(s, "0:00:") {
7275
// ignore cuda and template not mapped gstreamer warnings
7376
} else if strings.HasPrefix(s, "turnc") {
7477
// warn on turnc error
@@ -77,6 +80,7 @@ func (l *ProcessLogger) Write(p []byte) (n int, err error) {
7780
// panics and unexpected errors
7881
l.logger.Errorw(s, nil)
7982
}
83+
8084
return len(p), nil
8185
}
8286

test/integration.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ func (r *Runner) run(t *testing.T, test *testCase, f func(*testing.T, *testCase)
8282
func (r *Runner) awaitIdle(t *testing.T) {
8383
r.svc.KillAll()
8484
for i := 0; i < 30; i++ {
85-
if r.svc.IsIdle() {
85+
if r.svc.IsIdle() && len(r.room.LocalParticipant.TrackPublications()) == 0 {
8686
return
8787
}
8888
time.Sleep(time.Second)
8989
}
90-
t.Fatal("service not idle after 30s")
90+
91+
if !r.svc.IsIdle() {
92+
t.Fatal("service not idle after 30s")
93+
} else if len(r.room.LocalParticipant.TrackPublications()) != 0 {
94+
t.Fatal("room still has tracks after 30s")
95+
}
9196
}
9297

9398
func (r *Runner) startEgress(t *testing.T, req *rpc.StartEgressRequest) string {

test/publish.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ func (r *Runner) publishSample(t *testing.T, codec types.MimeType, publishAfter,
8383
_ = r.room.LocalParticipant.UnpublishTrack(pub.SID())
8484
}
8585
})
86-
} else {
87-
t.Cleanup(func() {
88-
_ = r.room.LocalParticipant.UnpublishTrack(pub.SID())
89-
})
9086
}
9187
})
9288

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

132+
trackID := pub.SID()
133+
t.Cleanup(func() {
134+
_ = r.room.LocalParticipant.UnpublishTrack(trackID)
135+
})
136+
136137
return pub
137138
}

0 commit comments

Comments
 (0)