-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest-sidecar-advanced-tcp.sh
More file actions
executable file
·67 lines (55 loc) · 2.34 KB
/
test-sidecar-advanced-tcp.sh
File metadata and controls
executable file
·67 lines (55 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
./install-debugging-tools.sh test-proxy proxy-sidecar
./install-debugging-tools.sh test-proxy2 proxy-sidecar
./install-debugging-tools.sh test-proxy3 proxy-sidecar
./install-debugging-tools.sh test-proxy4 proxy-sidecar
# start the tcp listener
kubectl exec test-proxy -c proxy-sidecar -n cortexflow -- sh -c '
echo "Starting TCP listener on port 5054..."
nohup sh -c "nc -l -p 5054" >/dev/null 2>&1 &
'
kubectl exec test-proxy2 -c proxy-sidecar -n cortexflow -- sh -c '
echo "Starting TCP listener on port 5054..."
nohup sh -c "nc -l -p 5054" >/dev/null 2>&1 &
'
test_proxy_to_proxy2() {
for i in $(seq 1 300); do
sleep $((RANDOM % 5 + 1))
kubectl exec test-proxy -c proxy-sidecar -n cortexflow -- sh -c '
printf "{\"service\":\"test-proxy2.cortexflow\",\"direction\":\"Incoming\",\"payload\":\"eyJwYXlsb2FkIjogIkhlbGxvIGZyb20gcHJveHktc2lkZWNhciJ9\"}\n" | nc -w1 test-proxy2 5054
'
done
}
test_proxy2_to_proxy() {
for i in $(seq 1 300); do
sleep $((RANDOM % 5 + 1))
kubectl exec test-proxy2 -c proxy-sidecar -n cortexflow -- sh -c '
printf "{\"service\":\"test-proxy.cortexflow\",\"direction\":\"Incoming\",\"payload\":\"eyJwYXlsb2FkIjogIkhlbGxvIGZyb20gcHJveHktc2lkZWNhciJ9\"}\n" | nc -w1 test-proxy 5054
'
done
}
test_proxy3_to_proxy2() {
for i in $(seq 1 300); do
sleep $((RANDOM % 5 + 1))
kubectl exec test-proxy3 -c proxy-sidecar -n cortexflow -- sh -c '
printf "{\"service\":\"test-proxy2.cortexflow\",\"direction\":\"Incoming\",\"payload\":\"eyJwYXlsb2FkIjogIkhlbGxvIGZyb20gcHJveHktc2lkZWNhciJ9\"}\n" | nc -w1 test-proxy2 5054
'
done
}
test_proxy4_to_proxy2() {
for i in $(seq 1 300); do
sleep $((RANDOM % 5 + 1))
kubectl exec test-proxy4 -c proxy-sidecar -n cortexflow -- sh -c '
printf "{\"service\":\"test-proxy2.cortexflow\",\"direction\":\"Incoming\",\"payload\":\"eyJwYXlsb2FkIjogIkhlbGxvIGZyb20gcHJveHktc2lkZWNhciJ9\"}\n" | nc -w1 test-proxy2 5054
'
done
}
# execute the functions in background
test_proxy_to_proxy2 &
test_proxy2_to_proxy &
test_proxy3_to_proxy2 &
test_proxy4_to_proxy2 &
sleep 300
# stop the listeners
kubectl exec test-proxy -c proxy-sidecar -n cortexflow -- sh -c 'pkill nc'
kubectl exec test-proxy2 -c proxy-sidecar -n cortexflow -- sh -c 'pkill nc'