Skip to content

Commit

Permalink
use Docker to run integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Feb 18, 2024
1 parent 6fc0cdc commit 6cd38e4
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 37 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ jobs:
with:
submodules: recursive

- name: Run server and tests
- name: Build and run chat server and tests in Docker
run: |
docker build -t chat-server .
docker run -d --name chat-server -p 8080:8080 -p 3478-3495:3478-3495/udp chat-server
- name: Wait for docker container to exit
run: |
cargo run --release --package sfu --example chat -- -d --level info > sfu.log 2>&1 & echo $! > server_pid.txt
cargo test --release --no-fail-fast -- --show-output > test.log 2>&1 || true
while docker ps | grep chat-server >/dev/null; do
echo "chat-server is still running, waiting..."
sleep 5
done
- name: Shutdown server
run: kill -INT $(cat server_pid.txt) || true
- name: Copy logs from container to host
run: |
docker cp chat-server:/usr/src/app/logs/. .
- name: Upload logs as artifact
uses: actions/upload-artifact@v2
Expand All @@ -39,5 +47,8 @@ jobs:
sfu.log
test.log
- name: Shutdown chat server
run: docker stop chat-server && docker rm chat-server

- name: Parse test results
run: ./scripts/parse_test_results.sh test.log
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use rust image as base
FROM rust:latest

# Set working directory inside the container
WORKDIR /usr/src/app

# Copy the Rust project files into the container
COPY . .

# Build the Rust project
RUN cargo build --release --package sfu --example chat

# Expose the TCP port the signal server will listen on
EXPOSE 8080
# Expose the UDP ports the media server will listen on
EXPOSE 3478-3495/udp

RUN mkdir -p logs

# Command to run the server
CMD ./target/release/examples/chat -d --level info > ./logs/sfu.log 2>&1 & echo $! > server_pid.txt & cargo test --release --no-fail-fast -- --show-output > ./logs/test.log 2>&1
2 changes: 1 addition & 1 deletion examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::str::FromStr;
use std::sync::Arc;
use waitgroup::WaitGroup;

mod signal;
pub mod signal;

extern crate num_cpus;

Expand Down
7 changes: 7 additions & 0 deletions scripts/parse_test_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ if [[ $total_failed -gt 0 ]]; then
else
exit 0
fi

# Return non-zero exit code if there are zero passed tests
if [[ $total_passed -eq 0 ]]; then
exit 1
else
exit 0
fi
File renamed without changes.
11 changes: 0 additions & 11 deletions tests/rtcp_test.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/rtp_test.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/signaling_test.rs

This file was deleted.

0 comments on commit 6cd38e4

Please sign in to comment.