Skip to content

Commit

Permalink
Add full test for all APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jul 31, 2023
1 parent d3c5d8e commit 05e1738
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 83 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup the npm node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
Expand Down Expand Up @@ -64,9 +64,9 @@ jobs:
uses: actions/checkout@v3
- name: Build image for platform
run: |
docker build -t platform:latest -f Dockerfile . &&
docker tag platform:latest ossrs/srs-cloud:$SRS_TAG &&
docker tag platform:latest registry.cn-hangzhou.aliyuncs.com/ossrs/srs-cloud:$SRS_TAG &&
docker build -t platform:latest -f Dockerfile .
docker tag platform:latest ossrs/srs-cloud:$SRS_TAG
docker tag platform:latest registry.cn-hangzhou.aliyuncs.com/ossrs/srs-cloud:$SRS_TAG
docker images
- name: Build package
run: |
Expand All @@ -75,30 +75,35 @@ jobs:
du -sh build/*
- name: Install package
run: |
sudo bash build/srs-cloud/scripts/setup-ubuntu/install.sh --verbose &&
du -sh /usr/local/srs-cloud/*
sudo bash build/srs-cloud/scripts/setup-ubuntu/install.sh --verbose
echo "" && echo "/usr/local/srs-cloud/" && du -sh /usr/local/srs-cloud/*
echo "" && ls -lha /data /data/config
- name: Check service
run: |
# Wait for service ready.
echo "Wait for service ready."
make -j -C test
./test/srs-cloud.test -test.v -srs-log -endpoint http://localhost:2022 \
-wait-ready -check-api-secret=false \
-test.run TestApi_Empty
./test/srs-cloud.test -test.v -endpoint http://localhost:2022 \
-srs-log=true -wait-ready=true -init-password=true \
-check-api-secret=false -test.run TestApi_Empty
echo "Record log of services."
docker ps -a
echo "Show service status."
systemctl status srs-cloud
journalctl -u srs-cloud -f >journalctl.log 2>&1 & pid_journalctl=$!
docker logs -f srs-cloud >docker.log 2>&1 & pid_docker=$!
docker ps -a
echo "Record log of services."
journalctl -u srs-cloud > journalctl.log
journalctl -u srs-cloud -f >>journalctl.log 2>&1 & pid_journalctl=$!
docker logs srs-cloud >docker.log
docker logs -f srs-cloud >>docker.log 2>&1 & pid_docker=$!
- name: Test service
run: |
# We will handle the error by ourselves.
set +e
SRS_PLATFORM_SECRET=$(docker exec srs-cloud redis-cli hget SRS_PLATFORM_SECRET token)
./test/srs-cloud.test -test.v -wait-ready -srs-log -endpoint http://localhost:2022 \
-wait-ready -check-api-secret=true -api-secret=$SRS_PLATFORM_SECRET \
-init-password
./test/srs-cloud.test -test.v -wait-ready -endpoint http://localhost:2022 \
-srs-log=true -wait-ready=true -init-password=false \
-check-api-secret=true -api-secret=$SRS_PLATFORM_SECRET \
ret=$?; echo "Test with ${SRS_PLATFORM_SECRET} result: $ret"
echo "Stop service"
Expand Down
11 changes: 4 additions & 7 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ resources, and ports, as well as development on Mac or using Docker.

## Develop All in macOS

Start redis by docker:

```bash
docker run --name redis --rm -it -v $HOME/db/redis:/data -p 6379:6379 -d redis
```

Start SRS in macOS:
Start redis and SRS by docker:

```bash
docker run --name redis --rm -it -v $HOME/db/redis:/data -p 6379:6379 -d redis &&
docker run --name srs --rm -it \
-v $(pwd)/platform/containers/conf/srs.release-mac.conf:/usr/local/srs/conf/srs.conf \
-v $(pwd)/platform/containers/objs/nginx:/usr/local/srs/objs/nginx \
-p 1935:1935/tcp -p 1985:1985/tcp -p 8080:8080/tcp -p 8000:8000/udp -p 10080:10080/udp \
-d ossrs/srs:5
```

> Note: Stop service by `docker rm -f redis srs`
> Note: Also, you can run SRS by `(cd platform && ~/git/srs/trunk/objs/srs -c containers/conf/srs.release-local.conf)`
Run the platform backend, or run in GoLand:
Expand Down
4 changes: 2 additions & 2 deletions platform/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ func handleDockerHTTPService(ctx context.Context, handler *http.ServeMux) error
if err := func() error {
ohttp.WriteData(ctx, w, r, &struct {
Secret bool `json:"secret"`
HTTPS string `json:"https"`
HTTPS bool `json:"https"`
MgmtDocker bool `json:"mgmtDocker"`
}{
Secret: os.Getenv("SRS_PLATFORM_SECRET") != "",
HTTPS: os.Getenv("SRS_HTTPS"),
HTTPS: os.Getenv("SRS_HTTPS") != "off",
MgmtDocker: true,
})
return nil
Expand Down
9 changes: 3 additions & 6 deletions scripts/setup-ubuntu/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,9 @@ fi

echo "Start to install files"
mkdir -p ${SRS_HOME} ${DATA_HOME} && rm -rf ${SRS_HOME}/* &&
files=$(find . -type f |grep -vE '(.git|.idea|.run|node_modules|nginx/html/live)') &&
files="${files} $(find . -name .gitkeep)"
for file in $files; do
mkdir -p ${SRS_HOME}/$(dirname ${file}) &&
cp $file ${SRS_HOME}/${file}
done
cp -r ${WORK_DIR}/usr ${SRS_HOME}/usr &&
cp -r ${WORK_DIR}/mgmt ${SRS_HOME}/mgmt &&
cp -r ${WORK_DIR}/LICENSE ${SRS_HOME}/LICENSE
ret=$?; if [[ $ret -ne 0 ]]; then echo "Copy files failed, ret=$ret"; exit $ret; fi
echo "Install files at ${SRS_HOME} ok"

Expand Down
Loading

0 comments on commit 05e1738

Please sign in to comment.