Skip to content

Commit

Permalink
chore: skip u\0000 when generating model random data (#169)
Browse files Browse the repository at this point in the history
* chore: use `Alphanumeric.sample_string` to generate random data

getting u\0000 codepoints in the data, that crashes the postgres indexer because it's not allowed in jsonb data

* chore: keep using unicode for emojis etc but skip 0000

* chore: clippy
  • Loading branch information
dav1do authored May 3, 2024
1 parent 71f1413 commit e44cfee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion operator/src/network/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4459,7 +4459,6 @@ mod tests {
// Override one existing var
("APP_PORT".to_string(), "8080".to_string()),
])),
..Default::default()
}),
..Default::default()
}),
Expand Down
12 changes: 7 additions & 5 deletions operator/src/network/stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ impl WithStatus for Network {
}
}

type PodMonitorStub = (
(ExpectFile, bool),
Option<(ExpectFile, bool)>,
Option<ExpectFile>,
);

/// Stub of expected requests during reconciliation.
///
/// ```no_run
Expand All @@ -59,11 +65,7 @@ pub struct Stub {
pub namespace: ExpectPatch<ExpectFile>,
pub status: ExpectPatch<ExpectFile>,
pub monitoring: Vec<ExpectFile>,
pub pod_monitor: Vec<(
(ExpectFile, bool),
Option<(ExpectFile, bool)>,
Option<ExpectFile>,
)>,
pub pod_monitor: Vec<PodMonitorStub>,
pub cas_postgres_auth_secret: (ExpectPatch<ExpectFile>, Secret, bool),
pub ceramic_postgres_auth_secret: (ExpectPatch<ExpectFile>, Secret),
pub ceramic_admin_secret_missing: (ExpectPatch<ExpectFile>, Option<Secret>),
Expand Down
7 changes: 5 additions & 2 deletions runner/src/scenario/ceramic/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ impl LargeModel {
impl RandomModelInstance for LargeModel {
fn random() -> Self {
let mut rng = thread_rng();
let name: String = (1..100).map(|_| rng.gen::<char>()).collect();
let name = Alphanumeric.sample_string(&mut rand::thread_rng(), 100);
Self {
creator: "keramik".to_string(),
name: format!("keramik-large-model-{}", name),
description: (1..1_000).map(|_| rng.gen::<char>()).collect(),
description: (0..1_000)
.map(|_| rng.gen::<char>())
.filter(|c| *c != '\u{0000}')
.collect(),
tpe: rng.gen_range(0..100),
}
}
Expand Down

0 comments on commit e44cfee

Please sign in to comment.