Skip to content

Commit 005c023

Browse files
authored
Merge pull request #1453 from joshtriplett/internal-testing
Rename "testing" feature to "for-internal-testing-only"
2 parents e9c0ae9 + efd6303 commit 005c023

File tree

10 files changed

+33
-37
lines changed

10 files changed

+33
-37
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: cargo test
5151
run: |
5252
rustup update --no-self-update
53-
cargo test --release --no-default-features --features=testing -- --nocapture
53+
cargo test --release --no-default-features --features=for-internal-testing-only -- --nocapture
5454
- uses: actions/upload-artifact@v2
5555
if: ${{ failure() && runner.os == 'linux' }}
5656
with:

Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ overflow-checks = true
2626

2727
[features]
2828
default = []
29-
# Do not use the "testing" feature in your own testing code, this is for
30-
# internal testing use only. It injects many delays and performs several
31-
# test-only configurations that cause performance to drop significantly.
32-
# It will cause your tests to take much more time, and possibly time out etc...
33-
testing = ["event_log", "lock_free_delays", "light_testing"]
29+
for-internal-testing-only = ["event_log", "lock_free_delays", "light_testing"]
3430
light_testing = ["failpoints", "backtrace", "memshred"]
3531
lock_free_delays = []
3632
failpoints = []

scripts/cgtest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cgdelete memory:sledTest || true
55
cgcreate -g memory:sledTest
66
echo 100M > /sys/fs/cgroup/memory/sledTest/memory.limit_in_bytes
77

8-
su $SUDO_USER -c 'cargo build --release --features=testing'
8+
su $SUDO_USER -c 'cargo build --release --features=for-internal-testing-only'
99

1010
for test in target/release/deps/test*; do
1111
if [[ -x $test ]]

src/concurrency_control.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#[cfg(feature = "testing")]
1+
#[cfg(feature = "for-internal-testing-only")]
22
use std::cell::RefCell;
33
use std::sync::atomic::AtomicBool;
44

55
use parking_lot::{RwLockReadGuard, RwLockWriteGuard};
66

77
use super::*;
88

9-
#[cfg(feature = "testing")]
9+
#[cfg(feature = "for-internal-testing-only")]
1010
thread_local! {
1111
pub static COUNT: RefCell<u32> = RefCell::new(0);
1212
}
@@ -42,7 +42,7 @@ impl<'a> Drop for Protector<'a> {
4242
if let Protector::None(active) = self {
4343
active.fetch_sub(1, Release);
4444
}
45-
#[cfg(feature = "testing")]
45+
#[cfg(feature = "for-internal-testing-only")]
4646
COUNT.with(|c| {
4747
let mut c = c.borrow_mut();
4848
*c -= 1;
@@ -73,7 +73,7 @@ impl ConcurrencyControl {
7373
}
7474

7575
fn read(&self) -> Protector<'_> {
76-
#[cfg(feature = "testing")]
76+
#[cfg(feature = "for-internal-testing-only")]
7777
COUNT.with(|c| {
7878
let mut c = c.borrow_mut();
7979
*c += 1;
@@ -91,7 +91,7 @@ impl ConcurrencyControl {
9191
}
9292

9393
fn write(&self) -> Protector<'_> {
94-
#[cfg(feature = "testing")]
94+
#[cfg(feature = "for-internal-testing-only")]
9595
COUNT.with(|c| {
9696
let mut c = c.borrow_mut();
9797
*c += 1;

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl Default for Inner {
234234
segment_size: 512 * 1024, // 512kb in bytes
235235
flush_every_ms: Some(500),
236236
idgen_persist_interval: 1_000_000,
237-
snapshot_after_ops: if cfg!(feature = "testing") {
237+
snapshot_after_ops: if cfg!(feature = "for-internal-testing-only") {
238238
10
239239
} else {
240240
1_000_000
@@ -538,7 +538,7 @@ impl Config {
538538
use fs2::FileExt;
539539

540540
let try_lock =
541-
if cfg!(any(feature = "testing", feature = "light_testing")) {
541+
if cfg!(any(feature = "for-internal-testing-only", feature = "light_testing")) {
542542
// we block here because during testing
543543
// there are many filesystem race condition
544544
// that happen, causing locks to be held

src/ebr/internal.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl Global {
283283

284284
let global_epoch = self.try_advance(guard);
285285

286-
#[cfg(feature = "testing")]
286+
#[cfg(feature = "for-internal-testing-only")]
287287
let mut count = 0;
288288

289289
for _ in 0..steps {
@@ -295,15 +295,15 @@ impl Global {
295295
Some(sealed_bag) => {
296296
drop(sealed_bag);
297297

298-
#[cfg(feature = "testing")]
298+
#[cfg(feature = "for-internal-testing-only")]
299299
{
300300
count += 1;
301301
}
302302
}
303303
}
304304
}
305305

306-
#[cfg(feature = "testing")]
306+
#[cfg(feature = "for-internal-testing-only")]
307307
{
308308
if count > 0 && SIZE_HINT.load(Ordering::Relaxed) > 5000 {
309309
static O: std::sync::Once = std::sync::Once::new();
@@ -473,7 +473,7 @@ impl Local {
473473
pub(super) fn pin(&self) -> Guard {
474474
let guard = Guard {
475475
local: self,
476-
#[cfg(feature = "testing")]
476+
#[cfg(feature = "for-internal-testing-only")]
477477
began: std::time::Instant::now(),
478478
};
479479

src/ebr/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use internal::Local;
2525

2626
pub struct Guard {
2727
pub(super) local: *const Local,
28-
#[cfg(feature = "testing")]
28+
#[cfg(feature = "for-internal-testing-only")]
2929
pub(super) began: std::time::Instant,
3030
}
3131

@@ -68,7 +68,7 @@ impl Drop for Guard {
6868
local.unpin();
6969
}
7070

71-
#[cfg(feature = "testing")]
71+
#[cfg(feature = "for-internal-testing-only")]
7272
{
7373
if self.began.elapsed() > std::time::Duration::from_secs(1) {
7474
log::warn!("guard lived longer than allowed");

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
html_logo_url = "https://raw.githubusercontent.com/spacejam/sled/main/art/tree_face_anti-transphobia.png"
8585
)]
8686
#![cfg_attr(
87-
feature = "testing",
87+
feature = "for-internal-testing-only",
8888
deny(
8989
missing_docs,
9090
future_incompatible,
@@ -97,7 +97,7 @@
9797
unused_qualifications,
9898
)
9999
)]
100-
#![cfg_attr(feature = "testing", deny(
100+
#![cfg_attr(feature = "for-internal-testing-only", deny(
101101
// over time, consider enabling the commented-out lints below
102102
clippy::cast_lossless,
103103
clippy::cast_possible_truncation,
@@ -153,7 +153,7 @@
153153
clippy::wildcard_dependencies,
154154
))]
155155
#![cfg_attr(
156-
feature = "testing",
156+
feature = "for-internal-testing-only",
157157
warn(
158158
clippy::missing_const_for_fn,
159159
clippy::multiple_crate_versions,
@@ -177,7 +177,7 @@ macro_rules! io_fail {
177177

178178
macro_rules! testing_assert {
179179
($($e:expr),*) => {
180-
#[cfg(feature = "testing")]
180+
#[cfg(feature = "for-internal-testing-only")]
181181
assert!($($e),*)
182182
};
183183
}
@@ -401,28 +401,28 @@ pub(crate) enum Link {
401401

402402
/// A fast map that is not resistant to collision attacks. Works
403403
/// on 8 bytes at a time.
404-
#[cfg(not(feature = "testing"))]
404+
#[cfg(not(feature = "for-internal-testing-only"))]
405405
pub(crate) type FastMap8<K, V> =
406406
std::collections::HashMap<K, V, std::hash::BuildHasherDefault<fnv::Hasher>>;
407407

408-
#[cfg(feature = "testing")]
408+
#[cfg(feature = "for-internal-testing-only")]
409409
pub(crate) type FastMap8<K, V> = BTreeMap<K, V>;
410410

411411
/// A fast set that is not resistant to collision attacks. Works
412412
/// on 8 bytes at a time.
413-
#[cfg(not(feature = "testing"))]
413+
#[cfg(not(feature = "for-internal-testing-only"))]
414414
pub(crate) type FastSet8<V> =
415415
std::collections::HashSet<V, std::hash::BuildHasherDefault<fnv::Hasher>>;
416416

417-
#[cfg(feature = "testing")]
417+
#[cfg(feature = "for-internal-testing-only")]
418418
pub(crate) type FastSet8<V> = std::collections::BTreeSet<V>;
419419

420-
#[cfg(not(feature = "testing"))]
420+
#[cfg(not(feature = "for-internal-testing-only"))]
421421
use std::collections::HashMap as Map;
422422

423423
// we avoid HashMap while testing because
424424
// it makes tests non-deterministic
425-
#[cfg(feature = "testing")]
425+
#[cfg(feature = "for-internal-testing-only")]
426426
use std::collections::{BTreeMap as Map, BTreeSet as Set};
427427

428428
/// A function that may be configured on a particular shared `Tree`

src/node.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ impl Node {
757757
&items,
758758
);
759759

760-
#[cfg(feature = "testing")]
760+
#[cfg(feature = "for-internal-testing-only")]
761761
{
762762
let orig_ivec_pairs: Vec<_> = self
763763
.iter()
@@ -813,7 +813,7 @@ impl Node {
813813
inner: Arc::new(left.receive_merge(&right)),
814814
};
815815

816-
#[cfg(feature = "testing")]
816+
#[cfg(feature = "for-internal-testing-only")]
817817
{
818818
let orig_ivec_pairs: Vec<_> = self
819819
.iter()
@@ -844,7 +844,7 @@ impl Node {
844844
let rhs =
845845
Node { inner: Arc::new(rhs_inner), overlay: Default::default() };
846846

847-
#[cfg(feature = "testing")]
847+
#[cfg(feature = "for-internal-testing-only")]
848848
{
849849
let orig_ivec_pairs: Vec<_> = self
850850
.iter()
@@ -1584,7 +1584,7 @@ impl Inner {
15841584
fixed_key_stride
15851585
);
15861586

1587-
#[cfg(feature = "testing")]
1587+
#[cfg(feature = "for-internal-testing-only")]
15881588
{
15891589
for i in 0..items.len() {
15901590
if fixed_key_length.is_none() || fixed_value_length.is_none() {
@@ -2450,7 +2450,7 @@ impl Inner {
24502450
&self.lo()[..self.prefix_len as usize]
24512451
}
24522452

2453-
#[cfg(feature = "testing")]
2453+
#[cfg(feature = "for-internal-testing-only")]
24542454
fn is_sorted(&self) -> bool {
24552455
if self.fixed_key_stride.is_some() {
24562456
return true;

src/pagecache/heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use crate::{
1818
Error, Lsn, Result,
1919
};
2020

21-
#[cfg(not(feature = "testing"))]
21+
#[cfg(not(feature = "for-internal-testing-only"))]
2222
pub(crate) const MIN_SZ: u64 = 32 * 1024;
2323

24-
#[cfg(feature = "testing")]
24+
#[cfg(feature = "for-internal-testing-only")]
2525
pub(crate) const MIN_SZ: u64 = 128;
2626

2727
const MIN_TRAILING_ZEROS: u64 = MIN_SZ.trailing_zeros() as u64;

0 commit comments

Comments
 (0)