-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
269 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[target.'cfg(unix)'] | ||
runner = 'sudo -E' | ||
[alias] | ||
xtask = "run --package xtask --" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM debian:bookworm-slim | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
iperf3 \ | ||
iproute2 \ | ||
iputils-ping \ | ||
net-tools \ | ||
wireguard-go \ | ||
wireguard-tools \ | ||
&& rm -rf /var/lib/apt/lists/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "xtask" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
clap = { version = "4.5", features = ["derive"] } | ||
xshell = "0.2.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: '3.2' | ||
|
||
services: | ||
left: | ||
hostname: left | ||
container_name: left | ||
image: neptun-runer:0.0.1 | ||
entrypoint: /neptun/config/left.sh | ||
privileged: true | ||
depends_on: | ||
right: | ||
condition: service_healthy | ||
networks: | ||
default: | ||
ipv4_address: 176.0.0.2 | ||
volumes: | ||
- ../../target/release:/neptun/current | ||
- ../../base/target/release:/neptun/base | ||
- .:/neptun/config | ||
|
||
right: | ||
hostname: right | ||
container_name: right | ||
image: neptun-runer:0.0.1 | ||
entrypoint: /neptun/config/right.sh | ||
privileged: true | ||
healthcheck: | ||
test: ["CMD-SHELL", "cat /.iperf_ready"] | ||
interval: 1s | ||
start_interval: 1s | ||
start_period: 60s | ||
networks: | ||
default: | ||
ipv4_address: 176.0.0.3 | ||
volumes: | ||
- ../../target/release:/neptun/current | ||
- ../../base/target/release:/neptun/base | ||
- .:/neptun/config | ||
|
||
networks: | ||
default: | ||
driver: bridge | ||
ipam: | ||
config: | ||
- subnet: 176.0.0.0/24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
wireguard-go wg0 | ||
wg set wg0 \ | ||
listen-port 51820 \ | ||
private-key <(echo AH7jKt6M0RS21MkRG+URrfgmwvJqdhVvqtKeF4WR+E8=) \ | ||
peer mqrc8+LD+6zvMeCtyCcIBPEYuXT74lq1Hros0Np8ZgA= \ | ||
allowed-ips 10.0.0.2/32 \ | ||
endpoint 176.0.0.3:51820 | ||
ip address add dev wg0 10.0.0.1/24 | ||
ip link set up dev wg0 | ||
|
||
/neptun/base/neptun-cli --disable-drop-privileges wg1 | ||
wg set wg1 \ | ||
listen-port 51821 \ | ||
private-key <(echo sKZoT3qgxDm1bWny+1ttoi00qS2KXvo1L4Zb265wr3c=) \ | ||
peer CMWokCGH+YPN7CL2C2aAkDlnhw1blH0tKPOnEOgzrxM= \ | ||
allowed-ips 10.0.1.2/32 \ | ||
endpoint 176.0.0.3:51821 | ||
ip address add dev wg1 10.0.1.1/24 | ||
ip link set up dev wg1 | ||
|
||
/neptun/current/neptun-cli --disable-drop-privileges wg2 | ||
wg set wg2 \ | ||
listen-port 51822 \ | ||
private-key <(echo 0Fn5JWI1QGDiaVYLDBSLklIEBUujfpX1oH/UGI2D62k=) \ | ||
peer fqrU1Wk8nuyy6phf8IUDwcKK1ElslFYDyteANr2hlgM= \ | ||
allowed-ips 10.0.2.2/32 \ | ||
endpoint 176.0.0.3:51822 | ||
ip address add dev wg2 10.0.2.1/24 | ||
ip link set up dev wg2 | ||
|
||
iperf3 -i 60 -t 120 --bidir -c 176.0.0.3 | ||
iperf3 -i 60 -t 120 --bidir -c 10.0.0.2 | ||
iperf3 -i 60 -t 120 --bidir -c 10.0.1.2 | ||
iperf3 -i 60 -t 120 --bidir -c 10.0.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
wireguard-go wg0 | ||
wg set wg0 \ | ||
listen-port 51820 \ | ||
private-key <(echo MLBFYI9O69v8WdVodp4YucqnvW+onpD/R5kF/GE18F8=) \ | ||
peer 7gr2QZyPpaIdlsPcZcQozgpjDdCkefZtxz12Dmpj/3Y= \ | ||
allowed-ips 10.0.0.1/32 \ | ||
endpoint 176.0.0.2:51820 | ||
ip address add dev wg0 10.0.0.2/24 | ||
ip link set up dev wg0 | ||
|
||
/neptun/base/neptun-cli --disable-drop-privileges wg1 | ||
wg set wg1 \ | ||
listen-port 51821 \ | ||
private-key <(echo WAoFbPJ6QaXXltwLqBADFkMG6qLZuivSlkIUv2Sc3lY=) \ | ||
peer HcDZRTIcI3Yok4XTwhAScKoNkb9MIZ2wyjS1oQvZnic= \ | ||
allowed-ips 10.0.1.1/32 \ | ||
endpoint 176.0.0.2:51821 | ||
ip address add dev wg1 10.0.1.2/24 | ||
ip link set up dev wg1 | ||
|
||
/neptun/current/neptun-cli --disable-drop-privileges wg2 | ||
wg set wg2 \ | ||
listen-port 51822 \ | ||
private-key <(echo eNOePaXKpyN9IjNEDe1a4CzBAwdbLupbF5wfdCUjS18=) \ | ||
peer zj6KZHkVw3ILScBGgUaYfuRkwhK6GgrIHmzfd4MPx1k= \ | ||
allowed-ips 10.0.2.1/32 \ | ||
endpoint 176.0.0.2:51822 | ||
ip address add dev wg2 10.0.2.2/24 | ||
ip link set up dev wg2 | ||
|
||
iperf3 -s > /dev/null & | ||
touch /.iperf_ready | ||
sleep infinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
mod perf; | ||
|
||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
enum Cmd { | ||
/// Run performance benchmark | ||
Perf(perf::Cmd), | ||
} | ||
|
||
fn main() { | ||
match Cmd::parse() { | ||
Cmd::Perf(perf) => perf.run(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Cmd { | ||
/// Git ref of the benchmark base | ||
#[arg(short, long)] | ||
base: String, | ||
} | ||
|
||
struct GitWorktree { | ||
name: String, | ||
sh: Shell, | ||
} | ||
|
||
impl GitWorktree { | ||
fn new(name: &str, base_ref: &str) -> Self { | ||
let sh = Shell::new().expect("Failed to create shell object"); | ||
cmd!(sh, "git worktree add {name} {base_ref}") | ||
.run() | ||
.expect("Failed to create base worktree"); | ||
GitWorktree { | ||
name: name.to_string(), | ||
sh: sh, | ||
} | ||
} | ||
} | ||
|
||
impl Drop for GitWorktree { | ||
fn drop(&mut self) { | ||
let name = &self.name; | ||
_ = cmd!(self.sh, "git worktree remove {name}").run(); | ||
} | ||
} | ||
|
||
fn build_neptun_cli(dir: &str) { | ||
let sh = Shell::new().expect("Failed to create shell object"); | ||
sh.change_dir(dir); | ||
cmd!(sh, "cargo build --release -p neptun-cli") | ||
.run() | ||
.expect("Failed to build base version"); | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self) { | ||
let worktree = GitWorktree::new("base", &self.base); | ||
build_neptun_cli("."); | ||
build_neptun_cli(&worktree.name); | ||
|
||
let sh = Shell::new().expect("Failed to create shell object"); | ||
cmd!(sh, "docker compose -f xtask/perf/docker-compose.yml up --abort-on-container-exit") | ||
.run() | ||
.expect("Failed to build base version"); | ||
} | ||
} |