Skip to content

Commit

Permalink
Wait for kv to be primed with scope/collection before running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chvck committed Mar 14, 2023
1 parent 071a309 commit e056de2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/integration/util/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl StandaloneCluster {
});
StandaloneCluster::wait_for_scope(config.clone()).await;
StandaloneCluster::wait_for_collection(config.clone()).await;
StandaloneCluster::wait_for_kv(config.clone()).await;

Self { config }
}
Expand Down Expand Up @@ -119,6 +120,26 @@ impl StandaloneCluster {
});
}

async fn wait_for_kv(config: Arc<TestConfig>) {
playground::CBPlayground::setup("wait_for_kv", config, None, |dirs, sandbox| {
let cmd = r#"doc upsert wait_for_kv {"test": "test"} | first | to json"#;
sandbox.retry_until(
Instant::now().add(time::Duration::from_secs(30)),
time::Duration::from_millis(200),
cmd,
dirs.test(),
RetryExpectations::ExpectOut,
|json| -> TestResult<bool> {
let v = json.as_object().unwrap();
match v.get("success") {
Some(i) => Ok(i.as_i64().unwrap() == 1),
None => Ok(false),
}
},
);
});
}

async fn wait_for_collection(config: Arc<TestConfig>) {
let scope_name = match config.scope() {
None => {
Expand Down

0 comments on commit e056de2

Please sign in to comment.