Skip to content

Commit 05e1738

Browse files
committed
Add full test for all APIs.
1 parent d3c5d8e commit 05e1738

File tree

6 files changed

+363
-83
lines changed

6 files changed

+363
-83
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Checkout repository
3737
uses: actions/checkout@v3
3838
- name: Setup the npm node
39-
uses: actions/setup-node@v2
39+
uses: actions/setup-node@v3
4040
with:
4141
node-version: '18'
4242
cache: 'npm'
@@ -64,9 +64,9 @@ jobs:
6464
uses: actions/checkout@v3
6565
- name: Build image for platform
6666
run: |
67-
docker build -t platform:latest -f Dockerfile . &&
68-
docker tag platform:latest ossrs/srs-cloud:$SRS_TAG &&
69-
docker tag platform:latest registry.cn-hangzhou.aliyuncs.com/ossrs/srs-cloud:$SRS_TAG &&
67+
docker build -t platform:latest -f Dockerfile .
68+
docker tag platform:latest ossrs/srs-cloud:$SRS_TAG
69+
docker tag platform:latest registry.cn-hangzhou.aliyuncs.com/ossrs/srs-cloud:$SRS_TAG
7070
docker images
7171
- name: Build package
7272
run: |
@@ -75,30 +75,35 @@ jobs:
7575
du -sh build/*
7676
- name: Install package
7777
run: |
78-
sudo bash build/srs-cloud/scripts/setup-ubuntu/install.sh --verbose &&
79-
du -sh /usr/local/srs-cloud/*
78+
sudo bash build/srs-cloud/scripts/setup-ubuntu/install.sh --verbose
79+
echo "" && echo "/usr/local/srs-cloud/" && du -sh /usr/local/srs-cloud/*
80+
echo "" && ls -lha /data /data/config
8081
- name: Check service
8182
run: |
82-
# Wait for service ready.
83+
echo "Wait for service ready."
8384
make -j -C test
84-
./test/srs-cloud.test -test.v -srs-log -endpoint http://localhost:2022 \
85-
-wait-ready -check-api-secret=false \
86-
-test.run TestApi_Empty
85+
./test/srs-cloud.test -test.v -endpoint http://localhost:2022 \
86+
-srs-log=true -wait-ready=true -init-password=true \
87+
-check-api-secret=false -test.run TestApi_Empty
8788
88-
echo "Record log of services."
89-
docker ps -a
89+
echo "Show service status."
9090
systemctl status srs-cloud
91-
journalctl -u srs-cloud -f >journalctl.log 2>&1 & pid_journalctl=$!
92-
docker logs -f srs-cloud >docker.log 2>&1 & pid_docker=$!
91+
docker ps -a
92+
93+
echo "Record log of services."
94+
journalctl -u srs-cloud > journalctl.log
95+
journalctl -u srs-cloud -f >>journalctl.log 2>&1 & pid_journalctl=$!
96+
docker logs srs-cloud >docker.log
97+
docker logs -f srs-cloud >>docker.log 2>&1 & pid_docker=$!
9398
- name: Test service
9499
run: |
95100
# We will handle the error by ourselves.
96101
set +e
97102
98103
SRS_PLATFORM_SECRET=$(docker exec srs-cloud redis-cli hget SRS_PLATFORM_SECRET token)
99-
./test/srs-cloud.test -test.v -wait-ready -srs-log -endpoint http://localhost:2022 \
100-
-wait-ready -check-api-secret=true -api-secret=$SRS_PLATFORM_SECRET \
101-
-init-password
104+
./test/srs-cloud.test -test.v -wait-ready -endpoint http://localhost:2022 \
105+
-srs-log=true -wait-ready=true -init-password=false \
106+
-check-api-secret=true -api-secret=$SRS_PLATFORM_SECRET \
102107
ret=$?; echo "Test with ${SRS_PLATFORM_SECRET} result: $ret"
103108
104109
echo "Stop service"

DEVELOPER.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,19 @@ resources, and ports, as well as development on Mac or using Docker.
55

66
## Develop All in macOS
77

8-
Start redis by docker:
9-
10-
```bash
11-
docker run --name redis --rm -it -v $HOME/db/redis:/data -p 6379:6379 -d redis
12-
```
13-
14-
Start SRS in macOS:
8+
Start redis and SRS by docker:
159

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

19+
> Note: Stop service by `docker rm -f redis srs`
20+
2421
> Note: Also, you can run SRS by `(cd platform && ~/git/srs/trunk/objs/srs -c containers/conf/srs.release-local.conf)`
2522
2623
Run the platform backend, or run in GoLand:

platform/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ func handleDockerHTTPService(ctx context.Context, handler *http.ServeMux) error
277277
if err := func() error {
278278
ohttp.WriteData(ctx, w, r, &struct {
279279
Secret bool `json:"secret"`
280-
HTTPS string `json:"https"`
280+
HTTPS bool `json:"https"`
281281
MgmtDocker bool `json:"mgmtDocker"`
282282
}{
283283
Secret: os.Getenv("SRS_PLATFORM_SECRET") != "",
284-
HTTPS: os.Getenv("SRS_HTTPS"),
284+
HTTPS: os.Getenv("SRS_HTTPS") != "off",
285285
MgmtDocker: true,
286286
})
287287
return nil

scripts/setup-ubuntu/install.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,9 @@ fi
118118

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

0 commit comments

Comments
 (0)