Skip to content

Commit c8f0bc5

Browse files
committed
fix: adding ci tests
1 parent bd85b67 commit c8f0bc5

3 files changed

Lines changed: 56 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,59 @@ jobs:
187187
name: regression_logs
188188
path: /tmp/failed/*
189189

190+
- name: Upload dragonfly binary for cgroup test
191+
if: matrix.container == 'ubuntu-dev:24' && matrix.build-type == 'Release' && matrix.sanitizers == 'NoSanitizers' && matrix.compiler.cxx == 'g++'
192+
uses: actions/upload-artifact@v7
193+
with:
194+
name: dragonfly-binary
195+
path: ${{ github.workspace }}/build/dragonfly
196+
retention-days: 1
197+
198+
cgroup-thread-detection:
199+
runs-on: ubuntu-latest
200+
needs: [build]
201+
steps:
202+
- uses: actions/checkout@v6
203+
204+
- uses: actions/download-artifact@v7
205+
with:
206+
name: dragonfly-binary
207+
path: build
208+
209+
- name: Test cgroup CPU auto-detection
210+
run: |
211+
chmod +x build/dragonfly
212+
213+
# Scenario 1: --cpus=2, no flag -> should auto-detect 2 threads
214+
CID=$(docker run --rm -d --cpus=2 --security-opt seccomp=unconfined \
215+
-v "$PWD/build/dragonfly:/dragonfly" -p 16380:6379 ubuntu:24.04 \
216+
/dragonfly --port 6379 --maxmemory 1G --dbfilename "" --noversion_check)
217+
218+
for i in $(seq 1 20); do
219+
sleep 1
220+
redis-cli -p 16380 PING 2>/dev/null | grep -q PONG && break
221+
done
222+
223+
THREADS=$(redis-cli -p 16380 INFO server | grep -oP 'thread_count:\K\d+')
224+
docker rm -f "$CID"
225+
echo "Scenario 1: expected 2, got $THREADS"
226+
[ "$THREADS" -eq 2 ]
227+
228+
# Scenario 2: --cpus=2 + --proactor_threads=4 -> flag must win
229+
CID=$(docker run --rm -d --cpus=2 --security-opt seccomp=unconfined \
230+
-v "$PWD/build/dragonfly:/dragonfly" -p 16381:6379 ubuntu:24.04 \
231+
/dragonfly --port 6379 --proactor_threads 4 --maxmemory 1G --dbfilename "" --noversion_check)
232+
233+
for i in $(seq 1 20); do
234+
sleep 1
235+
redis-cli -p 16381 PING 2>/dev/null | grep -q PONG && break
236+
done
237+
238+
THREADS=$(redis-cli -p 16381 INFO server | grep -oP 'thread_count:\K\d+')
239+
docker rm -f "$CID"
240+
echo "Scenario 2: expected 4, got $THREADS"
241+
[ "$THREADS" -eq 4 ]
242+
190243
lint-test-chart:
191244
runs-on: ubuntu-latest
192245
needs: [build]

src/server/dfly_main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,8 @@ Usage: dragonfly [FLAGS]
10851085
// honor it over the cgroup-derived CPU limit. The flag defaults to 0, so any non-zero value
10861086
// means the user explicitly requested a specific thread count.
10871087
if (absl::GetFlag(FLAGS_proactor_threads) > 0) {
1088+
LOG(INFO) << "Using proactor_threads=" << absl::GetFlag(FLAGS_proactor_threads)
1089+
<< " (overriding cgroup-derived " << max_available_threads << ")";
10881090
max_available_threads = 0; // causes ProactorPool to use FLAGS_proactor_threads
10891091
}
10901092
#endif

tests/dragonfly/proactor_threads_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ async def test_proactor_threads_flag_is_respected(df_factory: DflyInstanceFactor
2626

2727

2828
@pytest.mark.asyncio
29-
async def test_proactor_threads_env_var_is_respected(
30-
df_factory: DflyInstanceFactory, monkeypatch
31-
):
29+
async def test_proactor_threads_env_var_is_respected(df_factory: DflyInstanceFactory, monkeypatch):
3230
"""DFLY_proactor_threads env var must behave identically to the CLI flag.
3331
3432
The subprocess inherits the parent environment, so setting the variable here

0 commit comments

Comments
 (0)