diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/src/utils/querying.rs b/query-engine/connector-test-kit-rs/query-engine-tests/src/utils/querying.rs index eeb542659b8d..9f7cbacbeb6b 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/src/utils/querying.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/src/utils/querying.rs @@ -92,3 +92,29 @@ macro_rules! assert_error { $runner.query($q).await?.assert_failure($code, Some($msg.to_string())); }; } + +#[macro_export] +macro_rules! retry { + ($body:block, $times:expr) => {{ + use std::time::Duration; + use tokio::time::sleep; + + let mut retries = $times; + + loop { + let res = $body.await?; + + if !res.failed() { + break res; + } + + if retries > 0 { + retries -= 1; + sleep(Duration::from_millis(5)).await; + continue; + } + + break res; + } + }}; +} diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/create.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/create.rs index 1c538279321b..7e76c929d652 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/create.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/create.rs @@ -38,26 +38,32 @@ mod create { // "A Create Mutation" should "create and return item" #[connector_test] async fn create_should_work(runner: Runner) -> TestResult<()> { + // This test is flaky on CockroachDB because of a TX write conflict. + // We mitigate this issue by retrying multiple times. + let res = retry!( + { + runner.query(format!( + r#"mutation {{ + createOneScalarModel(data: {{ + id: "1", + optString: "lala{}", + optInt: 1337, + optFloat: 1.234, + optBoolean: true, + optEnum: A, + optDateTime: "2016-07-31T23:59:01.000Z" + }}) {{ + id, optString, optInt, optFloat, optBoolean, optEnum, optDateTime + }} + }}"#, + TROUBLE_CHARS + )) + }, + 5 + ); + insta::assert_snapshot!( - run_query!( - runner, - format!( - r#"mutation {{ - createOneScalarModel(data: {{ - id: "1", - optString: "lala{}", - optInt: 1337, - optFloat: 1.234, - optBoolean: true, - optEnum: A, - optDateTime: "2016-07-31T23:59:01.000Z" - }}) {{ - id, optString, optInt, optFloat, optBoolean, optEnum, optDateTime - }} - }}"#, - TROUBLE_CHARS - ) - ), + res.to_string(), @r###"{"data":{"createOneScalarModel":{"id":"1","optString":"lalaยฅเธฟ๐Ÿ˜€๐Ÿ˜๐Ÿ˜‚๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜ˆ๐Ÿ˜‰๐Ÿ˜Š๐Ÿ˜‹๐Ÿ˜Œ๐Ÿ˜๐Ÿ˜Ž๐Ÿ˜๐Ÿ˜๐Ÿ˜‘๐Ÿ˜’๐Ÿ˜“๐Ÿ˜”๐Ÿ˜•๐Ÿ˜–๐Ÿ˜—๐Ÿ˜˜๐Ÿ˜™๐Ÿ˜š๐Ÿ˜›๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ž๐Ÿ˜Ÿ๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ข๐Ÿ˜ฃ๐Ÿ˜ค๐Ÿ˜ฅ๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜จ๐Ÿ˜ฉ๐Ÿ˜ช๐Ÿ˜ซ๐Ÿ˜ฌ๐Ÿ˜ญ๐Ÿ˜ฎ๐Ÿ˜ฏ๐Ÿ˜ฐ๐Ÿ˜ฑ๐Ÿ˜ฒ๐Ÿ˜ณ๐Ÿ˜ด๐Ÿ˜ต๐Ÿ˜ถ๐Ÿ˜ท๐Ÿ˜ธ๐Ÿ˜น๐Ÿ˜บ๐Ÿ˜ป๐Ÿ˜ผ๐Ÿ˜ฝ๐Ÿ˜พ๐Ÿ˜ฟ๐Ÿ™€๐Ÿ™๐Ÿ™‚๐Ÿ™ƒ๐Ÿ™„๐Ÿ™…๐Ÿ™†๐Ÿ™‡๐Ÿ™ˆ๐Ÿ™‰๐Ÿ™Š๐Ÿ™‹๐Ÿ™Œ๐Ÿ™๐Ÿ™Ž๐Ÿ™เค€เคเค‚เคƒเค„เค…เค†เค‡เคˆเค‰เคŠเค‹เคŒเคเคŽเคเคเค‘เค’เค“เค”เค•เค–เค—เค˜เค™เคšเค›เคœเคเคžเคŸเค เคกเคขเคฃเคคเคฅเคฆเคงเคจเคฉเคชเคซเคฌเคญเคฎเคฏเคฐโ‚ฌโ‚ญโ‚ฎโ‚ฏโ‚ฐโ‚ฑโ‚ฒโ‚ณโ‚ดโ‚ตโ‚ถโ‚ทโ‚ธโ‚นโ‚บโ‚ปโ‚ผโ‚ฝโ‚พโ‚ฟโƒ€","optInt":1337,"optFloat":1.234,"optBoolean":true,"optEnum":"A","optDateTime":"2016-07-31T23:59:01.000Z"}}}"### );