add stress tests

This commit is contained in:
aler9 2020-09-18 19:59:07 +02:00
parent 249607ee33
commit 05140a5cd5
7 changed files with 154 additions and 2 deletions

View file

@ -11,6 +11,7 @@ help:
@echo " mod-tidy run go mod tidy"
@echo " format format source files"
@echo " test run available tests"
@echo " stress NAME=n run stress environment"
@echo " run run app"
@echo " release build release assets"
@echo " dockerhub build and push docker hub images"
@ -52,6 +53,10 @@ test-nodocker:
docker build -q test-images/$(IMG) -t rtsp-simple-server-test-$(IMG)$(NL))
go test -race -v .
stress:
docker build -q . -f stress/$(NAME)/Dockerfile -t temp
docker run --rm -it --network=host temp
define DOCKERFILE_RUN
FROM amd64/$(BASE_IMAGE)
RUN apk add --no-cache git ffmpeg
@ -68,14 +73,14 @@ define CONFIG_RUN
#rtpPort: 8002
#rtcpPort: 8003
#metrics: yes
pprof: yes
#pprof: yes
paths:
all:
# runOnPublish: ffmpeg -i rtsp://localhost:8554/$$RTSP_SERVER_PATH -c copy -f mpegts myfile_$$RTSP_SERVER_PATH.ts
# readUser: test
# readPass: tast
runOnDemand: ffmpeg -re -stream_loop -1 -i test-images/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:8554/$$RTSP_SERVER_PATH
# runOnDemand: ffmpeg -re -stream_loop -1 -i test-images/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:8554/$$RTSP_SERVER_PATH
# proxied:
# source: rtsp://192.168.2.198:8554/stream

19
stress/proxy/Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM golang:1.14-alpine3.12
RUN apk add --no-cache \
ffmpeg
RUN wget -O /video.mkv http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
RUN go build -o /rtsp-simple-server .
COPY stress/proxy/start.sh /
RUN chmod +x /start.sh
ENTRYPOINT [ "/start.sh" ]

37
stress/proxy/start.sh Normal file
View file

@ -0,0 +1,37 @@
#!/bin/sh -e
PROXY_COUNT=10
PROXY_PROTOCOL=tcp
#####################################################
# source
CONF=""
CONF="${CONF}rtspPort: 8555\n"
CONF="${CONF}rtpPort: 8002\n"
CONF="${CONF}rtcpPort: 8003\n"
echo -e "$CONF" > /source.conf
/rtsp-simple-server /source.conf &
sleep 1
ffmpeg -hide_banner -loglevel error \
-re -stream_loop -1 -i /video.mkv -c copy -f rtsp rtsp://localhost:8555/source &
sleep 1
#####################################################
# proxy
CONF=""
CONF="${CONF}pprof: yes\n"
CONF="${CONF}paths:\n"
for i in $(seq 1 $PROXY_COUNT); do
CONF="${CONF} proxy$i:\n"
CONF="${CONF} source: rtsp://localhost:8555/source\n"
CONF="${CONF} sourceProtocol: $PROXY_PROTOCOL\n"
done
echo -e "$CONF" > /proxy.conf
/rtsp-simple-server /proxy.conf

19
stress/publish/Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM golang:1.14-alpine3.12
RUN apk add --no-cache \
ffmpeg
RUN wget -O /video.mkv http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
RUN go build -o /rtsp-simple-server .
COPY stress/publish/start.sh /
RUN chmod +x /start.sh
ENTRYPOINT [ "/start.sh" ]

23
stress/publish/start.sh Normal file
View file

@ -0,0 +1,23 @@
#!/bin/sh -e
PUBLISHER_COUNT=10
PUBLISHER_PROTOCOL=tcp
#####################################################
# publishers
CONF=""
CONF="${CONF}pprof: yes\n"
echo -e "$CONF" > /source.conf
/rtsp-simple-server /source.conf &
sleep 1
for i in $(seq 1 $PUBLISHER_COUNT); do
ffmpeg -hide_banner -loglevel error \
-re -stream_loop -1 -i /video.mkv -c copy -f rtsp \
-rtsp_transport $PUBLISHER_PROTOCOL rtsp://localhost:8554/source$i &
done
wait

19
stress/read/Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM golang:1.14-alpine3.12
RUN apk add --no-cache \
ffmpeg
RUN wget -O /video.mkv http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
RUN go build -o /rtsp-simple-server .
COPY stress/read/start.sh /
RUN chmod +x /start.sh
ENTRYPOINT [ "/start.sh" ]

30
stress/read/start.sh Normal file
View file

@ -0,0 +1,30 @@
#!/bin/sh -e
READER_COUNT=10
READER_PROTOCOL=tcp
#####################################################
# source
CONF=""
CONF="${CONF}pprof: yes\n"
echo -e "$CONF" > /source.conf
/rtsp-simple-server /source.conf &
sleep 1
ffmpeg -re -stream_loop -1 -i /video.mkv -c copy -f rtsp rtsp://localhost:8554/source &
sleep 1
#####################################################
# readers
for i in $(seq 1 $READER_COUNT); do
ffmpeg -hide_banner -loglevel error \
-rtsp_transport $READER_PROTOCOL \
-i rtsp://localhost:8554/source -c copy -f mpegts -y /dev/null &
done
wait