Skip to content

Commit

Permalink
add TCP/UDP ports check in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Feb 18, 2024
1 parent 6fc0cdc commit c385b52
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 39 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 8081:8081 -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 8081
# 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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -55,7 +55,7 @@ impl From<Level> for log::LevelFilter {
struct Cli {
#[arg(long, default_value_t = format!("127.0.0.1"))]
host: String,
#[arg(short, long, default_value_t = 8080)]
#[arg(short, long, default_value_t = 8081)]
signal_port: u16,
#[arg(long, default_value_t = 3478)]
media_port_min: u16,
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
2 changes: 1 addition & 1 deletion tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use webrtc::peer_connection::sdp::session_description::RTCSessionDescription;
use webrtc::peer_connection::RTCPeerConnection;

pub const HOST: &'static str = "127.0.0.1";
pub const SIGNAL_PORT: u16 = 8080;
pub const SIGNAL_PORT: u16 = 8081;

pub async fn setup_peer_connection(
config: RTCConfiguration,
Expand Down
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 c385b52

Please sign in to comment.