Skip to content

Commit 6d52b03

Browse files
authored
fix: increase file descriptor limit in parallel test run (agntcy#1672)
# Description Local data-plane tests can fail because of exceeding the concurrent file descriptor limit of the process (on MacOS it is 256 by default). # Actions - setting fd limit to 4096 (`ulimit -n 4096`) ## Type of Change - [x] Bugfix - [ ] New Feature - [ ] Breaking Change - [ ] Refactor - [ ] Documentation - [ ] Other (please describe) ## Checklist - [x] I have read the [contributing guidelines](/agntcy/repo-template/blob/main/CONTRIBUTING.md) - [x] Existing issues have been referenced (where applicable) - [x] I have verified this change is not present in other open pull requests - [x] Functionality is documented - [x] All code style checks pass - [x] New code contribution is covered by automated tests - [x] All new and existing tests pass Signed-off-by: Mark Marton <mark.p.marton@gmail.com>
1 parent 111cc30 commit 6d52b03

5 files changed

Lines changed: 26 additions & 3 deletions

File tree

data-plane/Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data-plane/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ rand = "0.9.0"
120120
regex = "1.11.1"
121121

122122
reqwest = { version = "0.12", features = ["json", "rustls-tls-no-provider", "charset", "http2", "system-proxy", "blocking"], default-features = false }
123+
rlimit = "0.11.0"
123124
rustls = { version = "0.23.31" }
124125
rustls-native-certs = "0.8"
125126
rustls-pki-types = "1.10.0"

data-plane/control-plane/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ libsqlite3-sys = { workspace = true }
3838
parking_lot = { workspace = true }
3939
prost = { workspace = true }
4040
prost-types = { workspace = true }
41+
rlimit = { workspace = true }
4142
serde = { workspace = true, features = ["derive"] }
4243
serde_json = { workspace = true }
4344
serde_yaml = { workspace = true }
@@ -63,6 +64,7 @@ agntcy-slim-service = { workspace = true, features = ["session"] }
6364
agntcy-slim-testing = { workspace = true }
6465
agntcy-slim-tracing = { workspace = true }
6566
drain = { workspace = true }
67+
libc = "0.2"
6668
tempfile = { workspace = true }
6769
tokio-test = { workspace = true }
6870
tonic = { workspace = true }

data-plane/control-plane/tests/integration_test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright AGNTCY Contributors (https://github.com/agntcy)
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use rlimit::increase_nofile_limit;
45
use std::net::TcpListener;
56
use std::time::Duration;
67
use uuid::Uuid;
@@ -29,7 +30,15 @@ use tracing_subscriber::EnvFilter;
2930

3031
// --- Helpers ---
3132

33+
fn raise_fd_limit() {
34+
static INIT_FD_LIMIT: std::sync::Once = std::sync::Once::new();
35+
INIT_FD_LIMIT.call_once(|| {
36+
let _ = increase_nofile_limit(4096).expect("unable to raise open file descriptor limit");
37+
});
38+
}
39+
3240
fn reserve_port() -> u16 {
41+
raise_fd_limit();
3342
let listener = TcpListener::bind("127.0.0.1:0").expect("failed to bind test port");
3443
let port = listener.local_addr().expect("failed to read port").port();
3544
drop(listener);

tasks/rust.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ tasks:
186186
deps:
187187
- task: install-target
188188
cmds:
189-
- cargo test --no-run {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
189+
- ulimit -n 4096 2>/dev/null || true; cargo test --no-run {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
190190
vars:
191191
ARGS: '{{.ARGS | default "--all-targets --locked --all-features"}}'
192192

193193
test:
194194
desc: "Run the tests"
195195
cmds:
196-
- cargo test {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
196+
- ulimit -n 4096 2>/dev/null || true; cargo test {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
197197
- task: bindings:test
198198
- task: core:test
199199
vars:
@@ -206,7 +206,7 @@ tasks:
206206
vars:
207207
COMPONENTS: "cargo-llvm-cov"
208208
cmds:
209-
- cargo llvm-cov --lcov --output-path lcov.info {{.GLOBAL_ARGS}} {{.ARGS}}
209+
- ulimit -n 4096 2>/dev/null || true; cargo llvm-cov --lcov --output-path lcov.info {{.GLOBAL_ARGS}} {{.ARGS}}
210210
vars:
211211
ARGS: '{{.ARGS | default "--all-targets --locked --all-features"}}'
212212

0 commit comments

Comments
 (0)