Skip to content

Commit c446e29

Browse files
committed
add missed updates from the merge
1 parent ecb0f78 commit c446e29

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

simulator/generation/plan.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use crate::{
1212

1313
use crate::generation::{frequency, Arbitrary, ArbitraryFrom};
1414

15-
use super::{pick, property::Property};
15+
use super::{
16+
pick,
17+
property::{remaining, Property},
18+
};
1619

1720
pub(crate) type ResultSet = Result<Vec<Vec<Value>>>;
1821

@@ -470,38 +473,39 @@ impl ArbitraryFrom<(&SimulatorEnv, InteractionStats)> for Interactions {
470473
rng: &mut R,
471474
(env, stats): (&SimulatorEnv, InteractionStats),
472475
) -> Self {
473-
let remaining_read = ((env.opts.max_interactions as f64 * env.opts.read_percent / 100.0)
474-
- (stats.read_count as f64))
475-
.max(0.0);
476-
let remaining_write = ((env.opts.max_interactions as f64 * env.opts.write_percent / 100.0)
477-
- (stats.write_count as f64))
478-
.max(0.0);
479-
let remaining_create = ((env.opts.max_interactions as f64 * env.opts.create_percent
480-
/ 100.0)
481-
- (stats.create_count as f64))
482-
.max(0.0);
483-
476+
let remaining_ = remaining(env, &stats);
477+
println!(
478+
"remaining: {} {} {}",
479+
remaining_.read, remaining_.write, remaining_.create
480+
);
484481
frequency(
485482
vec![
486483
(
487-
f64::min(remaining_read, remaining_write) + remaining_create,
484+
f64::min(remaining_.read, remaining_.write) + remaining_.create,
488485
Box::new(|rng: &mut R| {
489486
Interactions::Property(Property::arbitrary_from(rng, (env, &stats)))
490487
}),
491488
),
492489
(
493-
remaining_read,
490+
remaining_.read,
494491
Box::new(|rng: &mut R| random_read(rng, env)),
495492
),
496493
(
497-
remaining_write,
494+
remaining_.write,
498495
Box::new(|rng: &mut R| random_write(rng, env)),
499496
),
500497
(
501-
remaining_create,
498+
remaining_.create,
502499
Box::new(|rng: &mut R| create_table(rng, env)),
503500
),
504-
(1.0, Box::new(|rng: &mut R| random_fault(rng, env))),
501+
(
502+
remaining_
503+
.read
504+
.min(remaining_.write)
505+
.min(remaining_.create)
506+
.max(1.0),
507+
Box::new(|rng: &mut R| random_fault(rng, env)),
508+
),
505509
],
506510
rng,
507511
)

simulator/generation/property.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub(crate) struct Remaining {
174174
pub(crate) create: f64,
175175
}
176176

177-
fn remaining(env: &SimulatorEnv, stats: &InteractionStats) -> Remaining {
177+
pub(crate) fn remaining(env: &SimulatorEnv, stats: &InteractionStats) -> Remaining {
178178
let remaining_read = ((env.opts.max_interactions as f64 * env.opts.read_percent / 100.0)
179179
- (stats.read_count as f64))
180180
.max(0.0);

simulator/shrink/plan.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{
22
generation::plan::{InteractionPlan, Interactions},
3+
model::query::Query,
34
runner::execution::Execution,
45
};
56

@@ -35,6 +36,10 @@ impl InteractionPlan {
3536
}
3637
}
3738
}
39+
40+
plan.plan
41+
.retain(|p| !matches!(p, Interactions::Query(Query::Select(_))));
42+
3843
let after = plan.plan.len();
3944

4045
log::info!(

0 commit comments

Comments
 (0)