Skip to content

Commit

Permalink
Timeout, updated test-r, external epoch loop
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Jan 30, 2025
1 parent 48ee6a6 commit ddfe307
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ testcontainers-modules = { version = "0.11.4", features = [
"redis",
"minio",
] }
test-r = { version = "2.0.1", default-features = true }
test-r = { version = "2.1.0", default-features = true }
thiserror = "2.0.6"
tokio = { version = "1.42", features = [
"macros",
Expand Down
30 changes: 14 additions & 16 deletions golem-worker-executor-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const VERSION: &str = golem_version!();
pub struct RunDetails {
pub http_port: u16,
pub grpc_port: u16,
pub epoch_thread: std::thread::JoinHandle<()>,
}

/// The Bootstrap trait should be implemented by all Worker Executors to customize the initialization
Expand Down Expand Up @@ -249,12 +250,11 @@ pub trait Bootstrap<Ctx: WorkerCtx> {

let lazy_worker_activator = Arc::new(LazyWorkerActivator::new());

let worker_executor_impl = create_worker_executor_impl::<Ctx, Self>(
let (worker_executor_impl, epoch_thread) = create_worker_executor_impl::<Ctx, Self>(
golem_config.clone(),
self,
runtime.clone(),
&lazy_worker_activator,
join_set,
)
.await?;

Expand All @@ -272,6 +272,7 @@ pub trait Bootstrap<Ctx: WorkerCtx> {
Ok(RunDetails {
http_port,
grpc_port: addr.port(),
epoch_thread,
})
}
}
Expand All @@ -281,8 +282,7 @@ async fn create_worker_executor_impl<Ctx: WorkerCtx, A: Bootstrap<Ctx> + ?Sized>
bootstrap: &A,
runtime: Handle,
lazy_worker_activator: &Arc<LazyWorkerActivator<Ctx>>,
join_set: &mut JoinSet<Result<(), anyhow::Error>>,
) -> Result<All<Ctx>, anyhow::Error> {
) -> Result<(All<Ctx>, std::thread::JoinHandle<()>), anyhow::Error> {
let (redis, sqlite, key_value_storage): (
Option<RedisPool>,
Option<SqlitePool>,
Expand Down Expand Up @@ -473,17 +473,13 @@ async fn create_worker_executor_impl<Ctx: WorkerCtx, A: Bootstrap<Ctx> + ?Sized>
let engine = Arc::new(Engine::new(&config)?);
let linker = bootstrap.create_wasmtime_linker(&engine)?;

let mut epoch_interval = tokio::time::interval(golem_config.limits.epoch_interval);
let engine_ref: Arc<Engine> = engine.clone();
join_set.spawn(
async move {
loop {
epoch_interval.tick().await;
engine_ref.increment_epoch();
}
}
.in_current_span(),
);

let epoch_interval = golem_config.limits.epoch_interval;
let epoch_thread = std::thread::spawn(move || loop {
std::thread::sleep(epoch_interval);
engine_ref.increment_epoch();
});

let linker = Arc::new(linker);

Expand Down Expand Up @@ -539,7 +535,7 @@ async fn create_worker_executor_impl<Ctx: WorkerCtx, A: Bootstrap<Ctx> + ?Sized>
golem_config.scheduler.refresh_interval,
);

bootstrap
let all = bootstrap
.create_services(
active_workers,
engine,
Expand All @@ -564,5 +560,7 @@ async fn create_worker_executor_impl<Ctx: WorkerCtx, A: Bootstrap<Ctx> + ?Sized>
plugins,
oplog_processor_plugin,
)
.await
.await?;

Ok((all, epoch_thread))
}
3 changes: 2 additions & 1 deletion golem-worker-executor-base/tests/guest_languages2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use test_r::{inherit_test_dep, test};
use test_r::{inherit_test_dep, test, timeout};

use crate::common::{start, TestContext};
use crate::{LastUniqueId, Tracing, WorkerExecutorTestDependencies};
Expand All @@ -28,6 +28,7 @@ inherit_test_dep!(Tracing);

#[test]
#[tracing::instrument]
#[timeout(180_000)]
async fn javascript_example_3(
last_unique_id: &LastUniqueId,
deps: &WorkerExecutorTestDependencies,
Expand Down

0 comments on commit ddfe307

Please sign in to comment.