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 36095ce
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 39 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,27 @@ jobs:
with:
submodules: recursive

- name: Run server and tests
- name: Build and run chat server in Docker
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
docker build -t chat-server .
docker run -d --name chat-server -p 8081:8081 -p 3478-3495:3478-3495/udp chat-server
sleep 5
docker logs chat-server > sfu.log
- name: Shutdown server
run: kill -INT $(cat server_pid.txt) || true
- name: Check TCP Port 8081
run: nc -zv 127.0.0.1 8081 || echo "TCP port 8081 is not accessible"

- name: Check UDP Port 3478
run: nc -zv 127.0.0.1 -u 3478 || echo "UDP port 3478 is not accessible"

- name: Check UDP Port 3495
run: nc -zv 127.0.0.1 -u 3495 || echo "UDP port 3495 is not accessible"

- name: Run integration tests
run: cargo test --release --no-fail-fast -- --show-output > test.log 2>&1 || true

- name: Shutdown chat server
run: docker stop chat-server && docker rm chat-server

- name: Upload logs as artifact
uses: actions/upload-artifact@v2
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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

# Command to run the server
CMD ["./target/release/examples/chat", "-d", "--level", "info"]
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
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 36095ce

Please sign in to comment.