mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
Add GitHub Docker action for testing UDP and HTTP file transfers
The Dockerfile works when run locally. The GitHub action plumbing may or not work in this state.
This commit is contained in:
parent
a2eff88bcb
commit
de2b7cb187
5 changed files with 159 additions and 0 deletions
8
.github/actions/test-transfer-udp-http/Dockerfile
vendored
Normal file
8
.github/actions/test-transfer-udp-http/Dockerfile
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Container image that runs your code
|
||||||
|
FROM rust:latest
|
||||||
|
|
||||||
|
# Copies your code file from your action repository to the filesystem path `/` of the container
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
# Code file to execute when the docker container starts up (`entrypoint.sh`)
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
10
.github/actions/test-transfer-udp-http/action.yml
vendored
Normal file
10
.github/actions/test-transfer-udp-http/action.yml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
name: 'test-transfer-udp-http'
|
||||||
|
description: 'test aquatic udp and http file transfer'
|
||||||
|
outputs:
|
||||||
|
http_ipv4:
|
||||||
|
description: 'HTTP IPv4 status'
|
||||||
|
udp_ipv4:
|
||||||
|
description: 'UDP IPv4 status'
|
||||||
|
runs:
|
||||||
|
using: 'docker'
|
||||||
|
image: 'Dockerfile'
|
||||||
119
.github/actions/test-transfer-udp-http/entrypoint.sh
vendored
Executable file
119
.github/actions/test-transfer-udp-http/entrypoint.sh
vendored
Executable file
|
|
@ -0,0 +1,119 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# IPv6 is unfortunately disabled by default in Docker
|
||||||
|
# (see sysctl net.ipv6.conf.lo.disable_ipv6)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Install programs and build dependencies
|
||||||
|
|
||||||
|
if command -v sudo; then
|
||||||
|
SUDO="sudo "
|
||||||
|
else
|
||||||
|
SUDO=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y cmake libssl-dev screen rtorrent mktorrent
|
||||||
|
|
||||||
|
rtorrent -h
|
||||||
|
|
||||||
|
# Build and start tracker
|
||||||
|
|
||||||
|
if [[ -z "${GITHUB_WORKSPACE}" ]]; then
|
||||||
|
cd "$HOME"
|
||||||
|
|
||||||
|
git clone https://github.com/greatest-ape/aquatic.git
|
||||||
|
|
||||||
|
cd aquatic
|
||||||
|
else
|
||||||
|
cd "$GITHUB_WORKSPACE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cargo build --bin aquatic
|
||||||
|
|
||||||
|
echo "log_level = 'debug'
|
||||||
|
|
||||||
|
[network]
|
||||||
|
address = '127.0.0.1:3000'" > http.toml
|
||||||
|
./target/debug/aquatic http -c http.toml &
|
||||||
|
|
||||||
|
echo "[network]
|
||||||
|
address = '127.0.0.1:3000'" > udp.toml
|
||||||
|
screen -dmS aquatic-udp ./target/debug/aquatic udp -c udp.toml
|
||||||
|
|
||||||
|
# Setup directories
|
||||||
|
|
||||||
|
cd "$HOME"
|
||||||
|
|
||||||
|
mkdir seed
|
||||||
|
mkdir leech
|
||||||
|
mkdir torrents
|
||||||
|
|
||||||
|
# Create torrents
|
||||||
|
|
||||||
|
echo "http-test-ipv4" > seed/http-test-ipv4
|
||||||
|
echo "udp-test-ipv4" > seed/udp-test-ipv4
|
||||||
|
|
||||||
|
mktorrent -p -o "torrents/http-ipv4.torrent" -a "http://127.0.0.1:3000/announce" "seed/http-test-ipv4"
|
||||||
|
mktorrent -p -o "torrents/udp-ipv4.torrent" -a "udp://127.0.0.1:3000" "seed/udp-test-ipv4"
|
||||||
|
|
||||||
|
cp -r torrents torrents-seed
|
||||||
|
cp -r torrents torrents-leech
|
||||||
|
|
||||||
|
# Start seeding client
|
||||||
|
|
||||||
|
echo "directory.default.set = $HOME/seed
|
||||||
|
schedule2 = watch_directory,5,5,load.start=$HOME/torrents-seed/*.torrent" > ~/.rtorrent.rc
|
||||||
|
|
||||||
|
echo "Starting seeding client"
|
||||||
|
screen -dmS rtorrent-seed rtorrent
|
||||||
|
|
||||||
|
sleep 10 # Give seeding rtorrent time to load its config file
|
||||||
|
|
||||||
|
# Start leeching client
|
||||||
|
|
||||||
|
echo "directory.default.set = $HOME/leech
|
||||||
|
schedule2 = watch_directory,5,5,load.start=$HOME/torrents-leech/*.torrent" > ~/.rtorrent.rc
|
||||||
|
|
||||||
|
echo "Starting leeching client.."
|
||||||
|
screen -dmS rtorrent-leech rtorrent
|
||||||
|
|
||||||
|
# Check for completion
|
||||||
|
|
||||||
|
HTTP_IPv4="Failed"
|
||||||
|
UDP_IPv4="Failed"
|
||||||
|
|
||||||
|
i="0"
|
||||||
|
|
||||||
|
echo "Watching for finished files.."
|
||||||
|
|
||||||
|
while [ $i -lt 300 ]
|
||||||
|
do
|
||||||
|
if test -f "leech/http-test-ipv4"; then
|
||||||
|
if grep -q "http-test-ipv4" "leech/http-test-ipv4"; then
|
||||||
|
HTTP_IPv4="Ok"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test -f "leech/udp-test-ipv4"; then
|
||||||
|
if grep -q "udp-test-ipv4" "leech/udp-test-ipv4"; then
|
||||||
|
UDP_IPv4="Ok"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$HTTP_IPv4" = "Ok" ] && [ "$UDP_IPv4" = "Ok" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
i=$[$i+1]
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Waited for $i seconds"
|
||||||
|
|
||||||
|
echo "::set-output name=http_ipv4::$HTTP_IPv4"
|
||||||
|
echo "::set-output name=udp_ipv4::$UDP_IPv4"
|
||||||
|
|
||||||
|
if [ "$HTTP_IPv4" != "Ok" ] || [ "$UDP_IPv4" != "Ok" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
18
.github/workflows/test-transfer-udp-http.yml
vendored
Normal file
18
.github/workflows/test-transfer-udp-http.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
name: "Test UDP and HTTP file transfer"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-transfer-http:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test BitTorrent file transfer over UDP and HTTP
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Test file transferS
|
||||||
|
uses: ../actions/test-transfer-udp-http/action@v1
|
||||||
|
id: test_transfer_udp_http
|
||||||
4
scripts/test-transfers.sh
Normal file
4
scripts/test-transfers.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker build -t aquatic-test-transfers .github/actions/test-transfers
|
||||||
|
docker run -it aquatic-test-transfers bash
|
||||||
Loading…
Add table
Add a link
Reference in a new issue