-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
functional-test: add advance network failure cases #6918
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,82 @@ func RecoverPort(port int) error { | |
return err | ||
} | ||
|
||
// SetPacketCorruption corrupts packets at p% | ||
func SetPacketCorruption(p int) error { | ||
if p < 0 || p > 100 { | ||
return fmt.Errorf("packets corruption percentage must be between 0 and 100 but got %v", p) | ||
} | ||
ifce, err := GetDefaultInterface() | ||
if err != nil { | ||
return err | ||
} | ||
cmdStr1 := fmt.Sprintf("sudo tc qdisc add dev %s root handle 1:1 netem corrupt %d%%", ifce, p) | ||
cmdStr2 := fmt.Sprintf("sudo tc qdisc add dev %s parent 1:1 handle 10:1 netem corrupt %d%%", ifce, p) | ||
cmdStrs := []string{cmdStr1, cmdStr2} | ||
|
||
for _, cmdStr := range cmdStrs { | ||
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
|
||
} | ||
|
||
// SetPacketReordering reorders packets. rp% of packets (with a correlation of cp%) gets send immediately. The rest will be delayed for ms millisecond | ||
func SetPacketReordering(rp int, cp int, ms int) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this only tests the tcp stack; etcd will still see everything in order, so why have it? |
||
ifce, err := GetDefaultInterface() | ||
if err != nil { | ||
return err | ||
} | ||
cmdStr1 := fmt.Sprintf("sudo tc qdisc add dev %s root handle 1:1 netem delay %dms reorder %d%% %d%%", ifce, ms, rp, cp) | ||
cmdStr2 := fmt.Sprintf("sudo tc qdisc add dev %s parent 1:1 handle 10:1 delay %dms reorder %d%% %d%%", ifce, ms, rp, cp) | ||
cmdStrs := []string{cmdStr1, cmdStr2} | ||
|
||
for _, cmdStr := range cmdStrs { | ||
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
|
||
} | ||
|
||
// SetPackLoss randomly drop packet at p% probability | ||
func SetPackLoss(p int) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is this any different from injecting random latencies? the tcp stack will retransmit |
||
ifce, err := GetDefaultInterface() | ||
if err != nil { | ||
return err | ||
} | ||
cmdStr := fmt.Sprintf("sudo tc qdisc add dev %s root netem loss %d%%", ifce, p) | ||
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// SetPartitioning sets a very long delay of ms scale with random variations rv to isolate this node | ||
func SetPartitioning(ms int, rv int) error { | ||
ifce, err := GetDefaultInterface() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmdStr := fmt.Sprintf("sudo tc qdisc add dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv) | ||
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// SetLatency adds latency in millisecond scale with random variations. | ||
func SetLatency(ms, rv int) error { | ||
ifce, err := GetDefaultInterface() | ||
|
@@ -64,12 +140,12 @@ func SetLatency(ms, rv int) error { | |
return nil | ||
} | ||
|
||
// RemoveLatency resets latency configurations. | ||
func RemoveLatency() error { | ||
func ResetDefaultInterface() error { | ||
ifce, err := GetDefaultInterface() | ||
if err != nil { | ||
return err | ||
} | ||
_, err = exec.Command("/bin/sh", "-c", fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce)).Output() | ||
cmdStr := fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce) | ||
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output() | ||
return err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM alpine | ||
RUN apk update | ||
RUN apk add -v iptables sudo | ||
RUN apk --update add iptables bash iproute2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why add bash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably don't need. |
||
ADD bin/etcd-agent / | ||
ADD bin/etcd / | ||
ADD bin/etcd-tester / | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,5 @@ tester: | |
- /etcd-tester | ||
- -agent-endpoints | ||
- "172.20.0.2:9027,172.20.0.3:9027,172.20.0.4:9027" | ||
- -limit | ||
- "1" | ||
- -stress-key-count | ||
- "1" | ||
- -stress-key-size | ||
- "1" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why change this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should the functional-tester run on docker image mirrors the one we run using goreman? |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of this will be corrected by tcp checksums, for the packets that aren't, I don't see how etcd would be able to pass its checks (e.g., suppose a lease key is corrupted and when the lease checker looks for the intended key, it's gone)