Skip to content

Commit

Permalink
fix(ci): run entire snapshot in main, pr and main-cron workflows (
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel authored Mar 14, 2023
1 parent d06674b commit eb56b9f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ci/scripts/deterministic-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,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 64 | parallel MADSIM_TEST_SEED={} './risingwave_simulation --run-sqlsmith-queries ./src/tests/sqlsmith/tests/sqlsmith-query-snapshots/{} 2> $LOGDIR/fuzzing-{}.log && rm $LOGDIR/fuzzing-{}.log'
1 change: 1 addition & 0 deletions ci/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ steps:
- ./ci/plugins/upload-failure-logs
timeout_in_minutes: 15
retry: *auto-retry
soft_fail: true

- label: "check"
command: "ci/scripts/check.sh"
Expand Down
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

0 comments on commit eb56b9f

Please sign in to comment.