Skip to content

Commit

Permalink
move clockabilly to an external crate
Browse files Browse the repository at this point in the history
  • Loading branch information
drmorr0 committed Jul 17, 2024
1 parent ea445bc commit 76ab54d
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 101 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

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

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = [
"clockabilly",
"sk-api",
"sk-cli",
"sk-core",
Expand All @@ -26,16 +25,14 @@ debug = false
sk-api.path = "sk-api"
sk-core.path = "sk-core"
sk-store.path = "sk-store"
testutils.path = "testutils"
clockabilly.path = "clockabilly"

anyhow = { version = "1.0.75", features = ["backtrace"] }
async-recursion = "1.0.5"
async-trait = "0.1.80"
bytes = "1.5.0"
chrono = "0.4.26"
clap = { version = "4.3.21", features = ["cargo", "derive", "string"] }
clap_complete = "4.5.6"
clockabilly = "0.1.0"
dirs = "5.0.1"
either = "1.12.0"
futures = "0.3.28"
Expand Down
10 changes: 0 additions & 10 deletions clockabilly/Cargo.toml

This file was deleted.

69 changes: 0 additions & 69 deletions clockabilly/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions sk-core/src/k8s/lease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn try_claim_lease(
metaroot: &SimulationRoot,
lease_ns: &str,
) -> anyhow::Result<LeaseState> {
try_claim_lease_with_clock(client, sim, metaroot, lease_ns, UtcClock::new()).await
try_claim_lease_with_clock(client, sim, metaroot, lease_ns, UtcClock::boxed()).await
}

pub(super) async fn try_claim_lease_with_clock(
Expand Down Expand Up @@ -103,7 +103,7 @@ pub async fn try_update_lease(
lease_ns: &str,
lease_duration: i64,
) -> EmptyResult {
try_update_lease_with_clock(client, sim, lease_ns, lease_duration, UtcClock::new()).await
try_update_lease_with_clock(client, sim, lease_ns, lease_duration, UtcClock::boxed()).await
}

pub(super) async fn try_update_lease_with_clock(
Expand Down
14 changes: 7 additions & 7 deletions sk-core/src/k8s/tests/lease_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn lease_other_holder() -> coordinationv1::Lease {
#[traced_test]
#[tokio::test]
async fn test_try_claim_lease_with_clock_already_owned_by_us(test_sim: Simulation, test_sim_root: SimulationRoot) {
let clock = MockUtcClock::new(NOW);
let clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
let lease_obj = build_lease(&test_sim, &test_sim_root, TEST_CTRL_NAMESPACE, clock.now());
fake_apiserver
Expand All @@ -52,7 +52,7 @@ async fn test_try_claim_lease_with_clock_already_owned_by_us(test_sim: Simulatio
#[traced_test]
#[tokio::test]
async fn test_try_claim_lease_with_clock_other_lease_unowned(test_sim: Simulation, test_sim_root: SimulationRoot) {
let clock = MockUtcClock::new(NOW);
let clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
let other_lease: coordinationv1::Lease = Default::default();
let lease_obj = build_lease(&test_sim, &test_sim_root, TEST_CTRL_NAMESPACE, clock.now());
Expand Down Expand Up @@ -83,7 +83,7 @@ async fn test_try_claim_lease_with_clock_already_owned_by_other(
test_sim_root: SimulationRoot,
lease_other_holder: coordinationv1::Lease,
) {
let clock = MockUtcClock::new(NOW);
let clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
fake_apiserver
.handle(move |when, then| {
Expand All @@ -103,7 +103,7 @@ async fn test_try_claim_lease_with_clock_already_owned_by_other(
#[traced_test]
#[tokio::test]
async fn test_try_claim_lease_with_clock(test_sim: Simulation, test_sim_root: SimulationRoot) {
let clock = MockUtcClock::new(NOW);
let clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
let lease_obj = build_lease(&test_sim, &test_sim_root, TEST_CTRL_NAMESPACE, clock.now());
fake_apiserver
Expand All @@ -125,7 +125,7 @@ async fn test_try_claim_lease_with_clock(test_sim: Simulation, test_sim_root: Si
#[traced_test]
#[tokio::test]
async fn test_try_update_lease_with_clock_no_lease_found(test_sim: Simulation) {
let clock = MockUtcClock::new(NOW);
let clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
fake_apiserver
.handle_not_found(format!("/apis/coordination.k8s.io/v1/namespaces/{TEST_LEASE_NS}/leases/{SK_LEASE_NAME}"))
Expand All @@ -142,7 +142,7 @@ async fn test_try_update_lease_with_clock_no_lease_found(test_sim: Simulation) {
#[traced_test]
#[tokio::test]
async fn test_try_update_lease_with_clock_wrong_owner(test_sim: Simulation, lease_other_holder: coordinationv1::Lease) {
let clock = MockUtcClock::new(NOW);
let clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
fake_apiserver
.handle(move |when, then| {
Expand All @@ -163,7 +163,7 @@ async fn test_try_update_lease_with_clock_wrong_owner(test_sim: Simulation, leas
#[traced_test]
#[tokio::test]
async fn test_try_update_lease_with_clock(test_sim: Simulation, test_sim_root: SimulationRoot) {
let mut clock = MockUtcClock::new(NOW);
let mut clock = MockUtcClock::boxed(NOW);
let (mut fake_apiserver, client) = make_fake_apiserver();
let lease_obj = build_lease(&test_sim, &test_sim_root, TEST_CTRL_NAMESPACE, clock.now());
let mut patched_lease_obj = build_lease(&test_sim, &test_sim_root, TEST_CTRL_NAMESPACE, clock.now());
Expand Down
2 changes: 1 addition & 1 deletion sk-driver/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub async fn run_trace(ctx: DriverContext, client: kube::Client) -> EmptyResult
}
}

let clock = UtcClock::new();
let clock = UtcClock::boxed();
let timeout = clock.now_ts() + DRIVER_CLEANUP_TIMEOUT_SECONDS;
cleanup_trace(&ctx, roots_api, clock, timeout).await
}
Expand Down
6 changes: 3 additions & 3 deletions sk-driver/src/tests/runner_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn test_cleanup_trace_error() {
let store = Arc::new(TraceStore::new(Default::default()));
let ctx = build_driver_context(cache, store);

let clock = MockUtcClock::new(0);
let clock = MockUtcClock::boxed(0);

fake_apiserver
.handle(|when, then| {
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn test_cleanup_trace_timeout() {
let store = Arc::new(TraceStore::new(Default::default()));
let ctx = build_driver_context(cache, store);

let clock = MockUtcClock::new(DRIVER_CLEANUP_TIMEOUT_SECONDS + 10);
let clock = MockUtcClock::boxed(DRIVER_CLEANUP_TIMEOUT_SECONDS + 10);

let res = cleanup_trace(&ctx, roots_api, clock, DRIVER_CLEANUP_TIMEOUT_SECONDS)
.await
Expand All @@ -79,7 +79,7 @@ async fn test_cleanup_trace() {
let store = Arc::new(TraceStore::new(Default::default()));
let ctx = build_driver_context(cache, store);

let clock = MockUtcClock::new(0);
let clock = MockUtcClock::boxed(0);

fake_apiserver
.handle(|when, then| {
Expand Down
2 changes: 1 addition & 1 deletion sk-store/src/tests/import_export_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn test_stream(clock: MockUtcClock) -> KubeObjectStream {
#[traced_test]
#[tokio::test]
async fn itest_export(#[case] duration: Option<String>) {
let clock = MockUtcClock::new(0);
let clock = MockUtcClock::boxed(0);

// Since we're just generating the results from the stream and not actually querying any
// Kubernetes internals or whatever, the TracerConfig is empty.
Expand Down
2 changes: 1 addition & 1 deletion sk-store/src/watchers/dyn_obj_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl DynObjWatcher {

Ok((
DynObjWatcher {
clock: UtcClock::new(),
clock: UtcClock::boxed(),
obj_stream: select_all(apis),
store,

Expand Down
2 changes: 1 addition & 1 deletion sk-store/src/watchers/pod_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl PodWatcher {
owners_cache: OwnersCache::new(apiset),
store,

clock: UtcClock::new(),
clock: UtcClock::boxed(),
is_ready: false,
ready_tx: tx,
},
Expand Down
2 changes: 1 addition & 1 deletion sk-store/src/watchers/tests/pod_watcher_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const END_TS: i64 = 5678;

#[fixture]
fn clock() -> Box<MockUtcClock> {
MockUtcClock::new(START_TS)
MockUtcClock::boxed(START_TS)
}

fn make_pod_watcher(
Expand Down

0 comments on commit 76ab54d

Please sign in to comment.