From 2eae0c889abd3629059d5a9308a0257b116281b3 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 12 Mar 2024 09:20:03 +0100 Subject: [PATCH] Remove the rest of lunatic mentions --- README.md | 6 +- service/Cargo.toml | 1 - utils/src/services/mod.rs | 2 +- worker/Cargo.lock | 347 -------------------------------------- worker/Dockerfile | 8 +- worker/src/main.rs | 22 +-- 6 files changed, 15 insertions(+), 371 deletions(-) delete mode 100644 worker/Cargo.lock diff --git a/README.md b/README.md index 2856c45..ef35f6b 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,7 @@ This should execute test instances on each of the workers #### Running locally -Running locally is possible if you have Rust installed. On top of that you need the `lunatic-runtime`: - -``` -cargo install lunatic-runtime -``` +Running locally is possible if you have Rust installed. Then you can run using cargo, for example: diff --git a/service/Cargo.toml b/service/Cargo.toml index b71d8f8..5aac59b 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -16,4 +16,3 @@ proc-macro = true [features] async = [] -lunatic = [] diff --git a/utils/src/services/mod.rs b/utils/src/services/mod.rs index caeda4d..feabc32 100644 --- a/utils/src/services/mod.rs +++ b/utils/src/services/mod.rs @@ -67,7 +67,7 @@ pub trait Worker { async fn upload_scenario(&mut self, id: ModuleId, content: Vec); async fn ping(&self) -> String; async fn prepare(&mut self, id: ModuleId, concurrency: usize, rate: Rational64) -> Result; - async fn start(&self, name: String, concurrency: usize) -> Result<(), WorkerError>; + async fn start(&self, id: ModuleId, concurrency: usize) -> Result<(), WorkerError>; async fn get_data(&self) -> WorkerData; } diff --git a/worker/Cargo.lock b/worker/Cargo.lock deleted file mode 100644 index f8397b0..0000000 --- a/worker/Cargo.lock +++ /dev/null @@ -1,347 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "libc" -version = "0.2.148" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" - -[[package]] -name = "lunatic" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe719e7cb256d07d1a0e1e4b096849a07b128bbb6c7ae8756120b650fbd151e" -dependencies = [ - "bincode", - "lunatic-macros", - "lunatic-sys", - "lunatic-test", - "paste", - "rustversion", - "serde", - "thiserror", -] - -[[package]] -name = "lunatic-macros" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a7ddb2dbdcd909a3f9667b3616d7dc103eea47a641bca1d3bb6fe11b915b798" -dependencies = [ - "convert_case", - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "lunatic-message-request" -version = "0.1.1" -dependencies = [ - "lunatic", - "serde", -] - -[[package]] -name = "lunatic-sys" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d572d8b5fa4693714650d42566863cf218bb69119d5d8514129972ee00c75ada" - -[[package]] -name = "lunatic-test" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e0c9aa5a17dba90ef8685013d28589d54f04b028f9b3f58c3223e8bf00827d" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "proc-macro2" -version = "1.0.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "serde" -version = "1.0.188" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.188" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[package]] -name = "serde_json" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "service" -version = "0.1.0" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.37", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "utils" -version = "0.1.0" -dependencies = [ - "anyhow", - "byteorder", - "lunatic", - "lunatic-message-request", - "serde", - "serde_json", - "service", - "syn 2.0.37", - "thiserror", - "uuid", -] - -[[package]] -name = "uuid" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" -dependencies = [ - "getrandom", - "serde", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "worker" -version = "0.1.0" -dependencies = [ - "anyhow", - "byteorder", - "lunatic", - "lunatic-message-request", - "serde", - "serde_json", - "service", - "thiserror", - "utils", - "uuid", -] diff --git a/worker/Dockerfile b/worker/Dockerfile index edca083..be356c9 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -9,9 +9,6 @@ COPY . . RUN cd worker && cargo build --release -RUN cargo install lunatic-runtime -RUN cp `which lunatic` /app/lunatic - FROM debian:buster RUN apt-get update \ @@ -23,11 +20,10 @@ RUN apt-get update \ RUN mkdir -p /app -COPY --from=builder /app/target/wasm32-wasi/release/worker.wasm /app/worker.wasm -COPY --from=builder /app/lunatic /app/lunatic +COPY --from=builder /app/target/release/worker /app/worker WORKDIR /app ENV WORKER_NAME=$HOST -ENTRYPOINT ["/app/lunatic", "worker.wasm"] +ENTRYPOINT ["/app/worker"] diff --git a/worker/src/main.rs b/worker/src/main.rs index 087dfe8..fd21f95 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -18,6 +18,7 @@ type ScenariosList = Arc>>>; // TODO: in the future we should probably share it with the coordinator, ie. // coordinator should prepare the defaults based on the default module settings // by examining the module +#[derive(Clone)] struct RunInfo { run_id: RunId, concurrency: usize, @@ -32,14 +33,14 @@ impl RunInfo { } #[derive(Clone)] -struct WorkerService { +struct WorkerService<'a> { scenarios: ScenariosList, hostname: String, - wasm_handles: Arc>>, + wasm_handles: Arc>>>, runs: HashMap } -impl Worker for WorkerService { +impl<'a> Worker for WorkerService<'a> { async fn upload_scenario(&mut self, id: ModuleId, content: Vec) { self.scenarios.write().await.insert(id, content); } @@ -54,12 +55,12 @@ impl Worker for WorkerService { // TODO: we should check if we have a given module available and if not ask coordinator // to send it. For now let's assume we have the module id let info = RunInfo::new(run_id.clone(), concurrency, rate, id); - self.runs.insert(run_id, info); + self.runs.insert(run_id.clone(), info); Ok(run_id) } - async fn start(&self, run_id: RunId) -> Result<(), WorkerError> { + async fn start(&self, id: ModuleId, concurrency: usize) -> Result<(), WorkerError> { let locked = self .scenarios .read() @@ -84,12 +85,12 @@ impl Worker for WorkerService { } #[derive(Clone)] -struct RuntimeHandle { - runtime: Arc>, +struct RuntimeHandle<'a> { + runtime: Arc>>, } -impl RuntimeHandle { - pub fn new(runtime: Runtime) -> Self { +impl<'a> RuntimeHandle<'a> { + pub fn new(runtime: Runtime<'a>) -> Self { Self { runtime: Arc::new(Mutex::new(runtime)) } } } @@ -119,7 +120,6 @@ fn main() -> Result<(), Box> { .enable_all() .build() .unwrap(); - let runtime = RuntimeHandle::new(Runtime::new()); rt.spawn(async move { println!("Connecting to {coordinator_address}"); @@ -145,7 +145,7 @@ fn main() -> Result<(), Box> { .enable_all() .build() .unwrap(); - let wasm_runtime = RuntimeHandle::new(Runtime::new()); + let wasm_runtime = RuntimeHandle::new(Runtime::new().expect("Couldn't create a Runtime")); rt.spawn(async move { handles.lock().await.push(wasm_runtime.clone());