Compare commits

..

2 Commits

Author SHA1 Message Date
Prabhpreet Dua
43cfd9a6f0 Prettier 2024-06-14 15:53:46 +05:30
Prabhpreet Dua
4558555153 feat: Regression CI based on misc/generate_configs.py 2024-06-14 15:25:42 +05:30
11 changed files with 109 additions and 89 deletions

33
.ci/run-regression.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
iterations=$1
sleep_time=$2
PWD=$(pwd)
EXEC=$PWD/target/release/rosenpass
LOGS=$PWD/output/logs
mkdir -p output/logs
run_command() {
local file=$1
local log_file="$2"
($EXEC exchange-config $file 2>&1 | sed "s/^/[$2] /" | tee -a $log_file) &
echo $!
}
pids=()
(cd output/dut && run_command "configs/dut-$iterations.toml" "dut.log") & piddut=$!
for (( x=0; x<$iterations; x++ )); do
(cd output/ate && run_command "configs/ate-$x.toml" "ate-$x.log") & pids+=($!)
done
sleep $sleep_time
lsof -i :9999 | awk 'NR!=1 {print $2}' | xargs kill
for (( x=0; x<$iterations; x++ )); do
port=$((x + 50000))
lsof -i :$port | awk 'NR!=1 {print $2}' | xargs kill
done

View File

@@ -110,12 +110,7 @@ jobs:
- run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items
cargo-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13]
# - ubuntu is x86-64
# - macos-13 is also x86-64 architecture
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3

19
.github/workflows/regressions.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: QC
on:
pull_request:
push:
branches: [main]
permissions:
checks: write
contents: read
jobs:
multi-peer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo build --bin rosenpass --release
- run: python misc/generate_configs.py
- run: chmod +x .ci/run-regression.sh
- run: .ci/run-regression.sh 100 20

2
.gitignore vendored
View File

@@ -20,3 +20,5 @@ _markdown_*
**/result
**/result-*
.direnv
/output

14
Cargo.lock generated
View File

@@ -1066,12 +1066,6 @@ version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.9"
@@ -2331,12 +2325,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "take-until"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4e17d8598067a8c134af59cd33c1c263470e089924a11ab61cf61690919fe3b"
[[package]]
name = "tempfile"
version = "3.10.1"
@@ -2869,10 +2857,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ba4e9811befc20af3b6efb15924a7238ee5e8e8706a196576462a00b9f1af1"
dependencies = [
"derive_builder 0.10.2",
"hex",
"libc",
"neli",
"take-until",
"thiserror",
]

View File

@@ -77,6 +77,6 @@ procspawn = {version = "1.0.0", features= ["test-support"]}
#Broker dependencies (might need cleanup or changes)
wireguard-uapi = { version = "3.0.0", features = ["xplatform"] }
wireguard-uapi = "3.0.0"
command-fds = "0.2.3"
rustix = { version = "0.38.27", features = ["net"] }

View File

@@ -1,14 +1,14 @@
from pathlib import Path
from subprocess import run
import os
config = dict(
peer_counts=[1, 5, 10, 50, 100, 500],
peer_count_max=100,
ate_ip="192.168.2.1",
dut_ip="192.168.2.4",
ate_ip="127.0.0.1",
dut_ip="127.0.0.1",
dut_port=9999,
path_to_rosenpass_bin="/Users/user/src/rosenppass/rosenpass/target/debug/rosenpass",
path_to_rosenpass_bin=os.getcwd() + "/target/release/rosenpass",
)
print(config)

View File

@@ -44,7 +44,6 @@ path = "src/bin/priviledged.rs"
test = false
doc = false
required-features=["enable_broker_api"]
cfg = { target_os = "linux" }
[[bin]]
name = "rosenpass-wireguard-broker-socket-handler"
@@ -52,4 +51,3 @@ test = false
path = "src/bin/socket_handler.rs"
doc = false
required-features=["enable_broker_api"]
cfg = { target_os = "linux" }

View File

@@ -1,67 +1,56 @@
fn main() {
#[cfg(target_os = "linux")]
linux::main().unwrap();
use std::io::{stdin, stdout, Read, Write};
use std::result::Result;
#[cfg(not(target_os = "linux"))]
panic!("This binary is only supported on Linux");
use rosenpass_wireguard_broker::api::msgs;
use rosenpass_wireguard_broker::api::server::BrokerServer;
use rosenpass_wireguard_broker::brokers::netlink as wg;
#[derive(thiserror::Error, Debug)]
pub enum BrokerAppError {
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
WgConnectError(#[from] wg::ConnectError),
#[error(transparent)]
WgSetPskError(#[from] wg::SetPskError),
#[error("Oversized message {}; something about the request is fatally wrong", .0)]
OversizedMessage(u64),
}
#[cfg(target_os = "linux")]
pub mod linux {
use std::io::{stdin, stdout, Read, Write};
use std::result::Result;
fn main() -> Result<(), BrokerAppError> {
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
use rosenpass_wireguard_broker::api::msgs;
use rosenpass_wireguard_broker::api::server::BrokerServer;
use rosenpass_wireguard_broker::brokers::netlink as wg;
let mut stdin = stdin().lock();
let mut stdout = stdout().lock();
loop {
// Read the message length
let mut len = [0u8; 8];
stdin.read_exact(&mut len)?;
#[derive(thiserror::Error, Debug)]
pub enum BrokerAppError {
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
WgConnectError(#[from] wg::ConnectError),
#[error(transparent)]
WgSetPskError(#[from] wg::SetPskError),
#[error("Oversized message {}; something about the request is fatally wrong", .0)]
OversizedMessage(u64),
}
pub fn main() -> Result<(), BrokerAppError> {
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
let mut stdin = stdin().lock();
let mut stdout = stdout().lock();
loop {
// Read the message length
let mut len = [0u8; 8];
stdin.read_exact(&mut len)?;
// Parse the message length
let len = u64::from_le_bytes(len);
if (len as usize) > msgs::REQUEST_MSG_BUFFER_SIZE {
return Err(BrokerAppError::OversizedMessage(len));
}
// Read the message itself
let mut req_buf = [0u8; msgs::REQUEST_MSG_BUFFER_SIZE];
let req_buf = &mut req_buf[..(len as usize)];
stdin.read_exact(req_buf)?;
// Process the message
let mut res_buf = [0u8; msgs::RESPONSE_MSG_BUFFER_SIZE];
let res = match broker.handle_message(req_buf, &mut res_buf) {
Ok(len) => &res_buf[..len],
Err(e) => {
eprintln!("Error processing message for wireguard PSK broker: {e:?}");
continue;
}
};
// Write the response
stdout.write_all(&(res.len() as u64).to_le_bytes())?;
stdout.write_all(&res)?;
stdout.flush()?;
// Parse the message length
let len = u64::from_le_bytes(len);
if (len as usize) > msgs::REQUEST_MSG_BUFFER_SIZE {
return Err(BrokerAppError::OversizedMessage(len));
}
// Read the message itself
let mut req_buf = [0u8; msgs::REQUEST_MSG_BUFFER_SIZE];
let req_buf = &mut req_buf[..(len as usize)];
stdin.read_exact(req_buf)?;
// Process the message
let mut res_buf = [0u8; msgs::RESPONSE_MSG_BUFFER_SIZE];
let res = match broker.handle_message(req_buf, &mut res_buf) {
Ok(len) => &res_buf[..len],
Err(e) => {
eprintln!("Error processing message for wireguard PSK broker: {e:?}");
continue;
}
};
// Write the response
stdout.write_all(&(res.len() as u64).to_le_bytes())?;
stdout.write_all(&res)?;
stdout.flush()?;
}
}

View File

@@ -1,6 +1,6 @@
#[cfg(feature = "enable_broker_api")]
pub mod mio_client;
#[cfg(all(feature = "enable_broker_api", target_os = "linux"))]
#[cfg(feature = "enable_broker_api")]
pub mod netlink;
pub mod native_unix;

View File

@@ -1,5 +1,3 @@
#![cfg(target_os = "linux")]
use std::fmt::Debug;
use wireguard_uapi::linux as wg;