mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-20 06:30:43 +00:00
test: remove the 'magic' in the mock_statvfs calls
It was sensible in the LD_PRELOAD based impl, less so now.
This commit is contained in:
@@ -68,7 +68,7 @@ pub struct DiskUsageEvictionTaskConfig {
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub period: Duration,
|
||||
#[cfg(feature = "testing")]
|
||||
pub mock_statvfs: Option<crate::statvfs::mock::Config>,
|
||||
pub mock_statvfs: Option<crate::statvfs::mock::Behavior>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -8,7 +8,7 @@ pub enum Statvfs {
|
||||
}
|
||||
|
||||
impl Statvfs {
|
||||
pub fn get(tenants_dir: &Path, mocked: Option<&mock::Config>) -> nix::Result<Self> {
|
||||
pub fn get(tenants_dir: &Path, mocked: Option<&mock::Behavior>) -> nix::Result<Self> {
|
||||
if let Some(mocked) = mocked {
|
||||
Ok(Statvfs::Mock(mock::get(tenants_dir, mocked)?))
|
||||
} else {
|
||||
@@ -51,12 +51,6 @@ pub mod mock {
|
||||
use std::path::Path;
|
||||
use tracing::log::info;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Config {
|
||||
magic: String,
|
||||
behavior: Behavior,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Behavior {
|
||||
@@ -84,10 +78,10 @@ pub mod mock {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(tenants_dir: &Path, config: &Config) -> nix::Result<Statvfs> {
|
||||
info!("running mocked statvfs, magic: {}", config.magic);
|
||||
pub fn get(tenants_dir: &Path, behavior: &Behavior) -> nix::Result<Statvfs> {
|
||||
info!("running mocked statvfs");
|
||||
|
||||
match config.behavior {
|
||||
match behavior {
|
||||
Behavior::Success {
|
||||
blocksize,
|
||||
total_blocks,
|
||||
@@ -98,7 +92,7 @@ pub mod mock {
|
||||
// round it up to the nearest block multiple
|
||||
let used_blocks = (used_bytes + (blocksize - 1)) / blocksize;
|
||||
|
||||
if used_blocks > total_blocks {
|
||||
if used_blocks > *total_blocks {
|
||||
panic!(
|
||||
"mocking error: used_blocks > total_blocks: {used_blocks} > {total_blocks}"
|
||||
);
|
||||
@@ -107,13 +101,13 @@ pub mod mock {
|
||||
let avail_blocks = total_blocks - used_blocks;
|
||||
|
||||
Ok(Statvfs {
|
||||
blocks: total_blocks,
|
||||
blocks: *total_blocks,
|
||||
blocks_available: avail_blocks,
|
||||
fragment_size: blocksize,
|
||||
block_size: blocksize,
|
||||
fragment_size: *blocksize,
|
||||
block_size: *blocksize,
|
||||
})
|
||||
}
|
||||
Behavior::Failure { mocked_error } => Err(mocked_error.into()),
|
||||
Behavior::Failure { mocked_error } => Err((*mocked_error).into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import shutil
|
||||
import time
|
||||
import uuid
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Dict, Tuple
|
||||
@@ -98,16 +97,11 @@ class EvictionEnv:
|
||||
def pageserver_start_with_disk_usage_eviction(
|
||||
self, period, max_usage_pct, min_avail_bytes, mock_behavior
|
||||
):
|
||||
magic = str(uuid.uuid4())
|
||||
|
||||
disk_usage_config = {
|
||||
"period": period,
|
||||
"max_usage_pct": max_usage_pct,
|
||||
"min_avail_bytes": min_avail_bytes,
|
||||
"mock_statvfs": {
|
||||
"behavior": mock_behavior,
|
||||
"magic": magic,
|
||||
},
|
||||
"mock_statvfs": mock_behavior,
|
||||
}
|
||||
|
||||
enc = toml.TomlEncoder()
|
||||
@@ -120,7 +114,7 @@ class EvictionEnv:
|
||||
)
|
||||
|
||||
def statvfs_called():
|
||||
assert self.neon_env.pageserver.log_contains(".*running mocked statvfs.*" + magic)
|
||||
assert self.neon_env.pageserver.log_contains(".*running mocked statvfs.*")
|
||||
|
||||
wait_until(10, 1, statvfs_called)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user