Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Jan 12, 2025
1 parent a4ae262 commit e96384e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 171 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ jobs:
run: ./interop/test.sh --use_tls tls_rustls
shell: bash

benchmark:
name: Benchmark Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@protoc
- uses: Swatinem/rust-cache@v2
- name: Run smoke test
run: ./benchmark/test.sh
shell: bash

semver:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ members = [
"tests/default_stubs",
"tests/deprecated_methods",
"tests/skip_debug",
"benchmark",
"benchmark", # Tests
]
resolver = "2"
8 changes: 8 additions & 0 deletions benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ edition = "2021"
publish = false
license = "MIT/Apache-2.0"

[[bin]]
name = "worker"
path = "src/bin/worker.rs"

[[bin]]
name = "tester"
path = "src/bin/tester.rs"

[dependencies]
clap = { version = "4.5.21", features = ["derive"] }
num_cpus = "1.16.0"
Expand Down
156 changes: 0 additions & 156 deletions benchmark/src/main.rs

This file was deleted.

17 changes: 3 additions & 14 deletions benchmark/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ impl BenchmarkServer {
time_elapsed: wall_time_elapsed.as_nanos() as f64 / 1e9,
time_user: user_time.num_nanoseconds() as f64 / 1e9,
time_system: system_time.num_nanoseconds() as f64 / 1e9,
// The following fields are not set by Java and Go.
idle_cpu_time: 0,
cq_poll_count: 0,
total_cpu_time: 0,
..Default::default()
});
}
}
Expand All @@ -141,11 +138,7 @@ impl crate::protobuf_benchmark_service::benchmark_service_server::BenchmarkServi
r#type: PayloadType::Compressable as i32,
body: vec![0; request.into_inner().response_size as usize],
}),
username: String::new(),
oauth_scope: String::new(),
server_id: String::new(),
grpclb_route_type: 0,
hostname: String::new(),
..Default::default()
}))
}

Expand All @@ -166,11 +159,7 @@ impl crate::protobuf_benchmark_service::benchmark_service_server::BenchmarkServi
r#type: PayloadType::Compressable as i32,
body: vec![0; request.response_size as usize],
}),
username: String::new(),
oauth_scope: String::new(),
server_id: String::new(),
grpclb_route_type: 0,
hostname: String::new(),
..Default::default()
};
}
};
Expand Down
34 changes: 34 additions & 0 deletions benchmark/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

set -x

echo "Running for OS: ${OSTYPE}"

case "$OSTYPE" in
darwin*) OS="darwin"; EXT="" ;;
linux*) OS="linux"; EXT="" ;;
msys*) OS="windows"; EXT=".exe" ;;
*) exit 2 ;;
esac

(cd benchmark && cargo build --bins)

WORKER_PORT=50056

# run the worker.
./target/debug/worker --driver_port="${WORKER_PORT}" &
WORKER_PID=$!
echo ":; started worker on port ${WORKER_PORT}."

# trap exits to make sure we kill the worker process when the script exits,
# regardless of why (errors, SIGTERM, etc).
trap 'echo ":; killing worker"; kill ${WORKER_PID};' EXIT

sleep 1

# run the tester.
echo ":; starting tester."
./target/debug/tester --worker_port="${WORKER_PORT}"

0 comments on commit e96384e

Please sign in to comment.