Skip to content

fix(ci): run entire snapshot in main, pr and main-cron workflows #8523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ci/scripts/deterministic-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ popd
echo "--- Extract data for SqlSmith"
pushd ./src/tests/sqlsmith/tests
git clone https://"$GITHUB_TOKEN"@github.com/risingwavelabs/sqlsmith-query-snapshots.git
pushd sqlsmith-query-snapshots && git checkout stage && popd
popd

export RUST_LOG=info
Expand All @@ -45,4 +46,4 @@ echo "--- deterministic simulation e2e, ci-3cn-2fe, parallel, batch"
seq $TEST_NUM | parallel MADSIM_TEST_SEED={} './risingwave_simulation -j 16 ./e2e_test/batch/\*\*/\*.slt 2> $LOGDIR/parallel-batch-{}.log && rm $LOGDIR/parallel-batch-{}.log'

echo "--- deterministic simulation e2e, ci-3cn-2fe, fuzzing (pre-generated-queries)"
seq $TEST_NUM | parallel MADSIM_TEST_SEED={} './risingwave_simulation --run-sqlsmith-queries ./src/tests/sqlsmith/tests/sqlsmith-query-snapshots/{} 2> $LOGDIR/fuzzing-{}.log && rm $LOGDIR/fuzzing-{}.log'
seq 100 | parallel MADSIM_TEST_SEED={} './risingwave_simulation --run-sqlsmith-queries ./src/tests/sqlsmith/tests/sqlsmith-query-snapshots/{} 2> $LOGDIR/fuzzing-{}.log && rm $LOGDIR/fuzzing-{}.log'
22 changes: 21 additions & 1 deletion src/tests/sqlsmith/scripts/gen_queries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,25 @@ check_failed_to_generate_queries() {
fi
}

# sync step
# Some queries maybe be added
sync_queries() {
set +x
pushd $OUTDIR
git checkout main
git pull
set +e
git branch -D stage
set -e
git checkout -b stage
popd
set -x
}

# Upload step
upload_queries() {
set +x
pushd "$OUTDIR"
git checkout -b stage
git add .
git commit -m 'update queries'
git push -f origin stage
Expand Down Expand Up @@ -209,6 +223,11 @@ validate() {
echo_err "[INFO] Passed checks"
}

sync() {
sync_queries
echo_err "[INFO] Synced"
}

upload() {
upload_queries
echo_err "[INFO] Uploaded"
Expand All @@ -223,6 +242,7 @@ main() {
setup

build
sync
generate
validate
upload
Expand Down
14 changes: 9 additions & 5 deletions src/tests/sqlsmith/src/sql_gen/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,19 @@ impl<'a, R: Rng> SqlGenerator<'a, R> {
fn gen_temporal_scalar(&mut self, typ: &DataType) -> String {
use DataType as T;

let rand_secs = self.rng.gen_range(2..1000000) as u64;
let minute = 60;
let hour = 60 * minute;
let day = 24 * hour;
let week = 7 * day;
let choices = [0, 1, minute, hour, day, week, rand_secs];
let secs = choices.choose(&mut self.rng).unwrap();
let choices = [0, 1, minute, hour, day, week];

let tm = DateTime::<Utc>::from(SystemTime::now() - Duration::from_secs(*secs));
let secs = match self.rng.gen_range(1..=100) {
1..=30 => *choices.choose(&mut self.rng).unwrap(),
31..=100 => self.rng.gen_range(2..100) as u64,
_ => unreachable!(),
};

let tm = DateTime::<Utc>::from(SystemTime::now() - Duration::from_secs(secs));
match typ {
T::Date => tm.format("%F").to_string(),
T::Timestamp | T::Timestamptz => tm.format("%Y-%m-%d %H:%M:%S").to_string(),
Expand All @@ -169,7 +173,7 @@ impl<'a, R: Rng> SqlGenerator<'a, R> {
T::Time => tm.format("%T").to_string(),
T::Interval => {
if self.rng.gen_bool(0.5) {
(-(*secs as i64)).to_string()
(-(secs as i64)).to_string()
} else {
secs.to_string()
}
Expand Down