Skip to content

Commit eb229bb

Browse files
committed
ci: temporary relay loop on windows-2025
1 parent 542511e commit eb229bb

1 file changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: tmp cassandra relay loop
2+
3+
on:
4+
push:
5+
branches: [tmp/windows-cassandra-relay-loop]
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: tmp-cassandra-relay-loop
12+
cancel-in-progress: true
13+
14+
env:
15+
CARGO_PROFILE_DEV_DEBUG: line-tables-only
16+
17+
jobs:
18+
loop:
19+
runs-on: windows-2025
20+
timeout-minutes: 90
21+
env:
22+
TARGET: x86_64-pc-windows-msvc
23+
RUSTFLAGS: -D warnings
24+
AWS_LC_SYS_PREBUILT_NASM: "1"
25+
ROUNDS: "150"
26+
defaults:
27+
run:
28+
shell: bash
29+
steps:
30+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
with:
32+
persist-credentials: false
33+
fetch-depth: 0
34+
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
35+
with:
36+
toolchain: "1.98"
37+
targets: x86_64-pc-windows-msvc
38+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
39+
with:
40+
key: x86_64-pc-windows-msvc
41+
save-if: false
42+
- name: Drop the emptied DuckDB sources
43+
run: rm -rf "target/$TARGET/duckdb-sources"
44+
45+
- name: Probe whether bind(0) hands out a port just dropped
46+
run: |
47+
mkdir -p "$RUNNER_TEMP/probe/src"
48+
cat > "$RUNNER_TEMP/probe/Cargo.toml" <<'EOF'
49+
[package]
50+
name = "probe"
51+
version = "0.0.0"
52+
edition = "2024"
53+
[workspace]
54+
EOF
55+
cat > "$RUNNER_TEMP/probe/src/main.rs" <<'EOF'
56+
use std::net::TcpListener;
57+
use std::sync::{Arc, Barrier};
58+
59+
fn main() {
60+
let rounds = 2000;
61+
let mut same = 0;
62+
let mut sample = Vec::new();
63+
for round in 0..rounds {
64+
let first = TcpListener::bind("127.0.0.1:0").unwrap();
65+
let port = first.local_addr().unwrap().port();
66+
drop(first);
67+
let next = TcpListener::bind("127.0.0.1:0").unwrap();
68+
let next_port = next.local_addr().unwrap().port();
69+
same += usize::from(next_port == port);
70+
if round < 12 {
71+
sample.push((port, next_port));
72+
}
73+
}
74+
println!("same thread: the next bind(0) got the dropped port {same} of {rounds} times");
75+
println!("first rounds (dropped, next): {sample:?}");
76+
77+
let mut taken = 0;
78+
for _ in 0..rounds {
79+
let barrier = Arc::new(Barrier::new(2));
80+
let first = TcpListener::bind("127.0.0.1:0").unwrap();
81+
let port = first.local_addr().unwrap().port();
82+
let other = {
83+
let barrier = barrier.clone();
84+
std::thread::spawn(move || {
85+
barrier.wait();
86+
TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port()
87+
})
88+
};
89+
drop(first);
90+
barrier.wait();
91+
taken += usize::from(other.join().unwrap() == port);
92+
}
93+
println!("other thread: a bind(0) right after the drop got the dropped port {taken} of {rounds} times");
94+
}
95+
EOF
96+
cargo run --release --manifest-path "$RUNNER_TEMP/probe/Cargo.toml" | tee probe.log
97+
98+
- name: Loop the cassandra lib tests on main's relay.rs and on the fix
99+
run: |
100+
loop() {
101+
label=$1
102+
out=$(cargo test --locked --target "$TARGET" -p tablepro-driver-cassandra --lib --no-run 2>&1)
103+
echo "$out" | tail -3
104+
exe=$(echo "$out" | sed -n 's/.*(\(target.*tablepro_driver_cassandra-[0-9a-f]*\.exe\)).*/\1/p' | tail -1)
105+
exe=${exe//\\//}
106+
echo "binary: $exe"
107+
failed=0
108+
start=$(date +%s)
109+
for i in $(seq 1 "$ROUNDS"); do
110+
if ! "$exe" > "run-$label-$i.log" 2>&1; then
111+
failed=$((failed + 1))
112+
echo "--- $label round $i failed"
113+
grep -E "panicked|assertion|finished in" "run-$label-$i.log"
114+
else
115+
rm "run-$label-$i.log"
116+
fi
117+
done
118+
echo "$label: $failed of $ROUNDS runs failed in $(( $(date +%s) - start )) s" | tee -a summary.log
119+
}
120+
fixed=$(git rev-parse HEAD)
121+
git show origin/main:core/crates/drivers/cassandra/src/relay.rs > core/crates/drivers/cassandra/src/relay.rs
122+
git diff --stat
123+
loop main
124+
git checkout "$fixed" -- core/crates/drivers/cassandra/src/relay.rs
125+
git diff --stat
126+
loop fix
127+
cat summary.log
128+
129+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
130+
if: always()
131+
with:
132+
name: relay-loop
133+
path: |
134+
probe.log
135+
summary.log
136+
run-*.log
137+
if-no-files-found: ignore

0 commit comments

Comments
 (0)