failure_case_network_blackhole.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2018 The etcd Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package tester
  15. import (
  16. "github.com/coreos/etcd/tools/functional-tester/rpcpb"
  17. )
  18. func injectBlackholePeerPortTxRx(clus *Cluster, idx int) error {
  19. return clus.sendOperation(idx, rpcpb.Operation_BlackholePeerPortTxRx)
  20. }
  21. func recoverBlackholePeerPortTxRx(clus *Cluster, idx int) error {
  22. return clus.sendOperation(idx, rpcpb.Operation_UnblackholePeerPortTxRx)
  23. }
  24. func newFailureBlackholePeerPortTxRxOneFollower(clus *Cluster) Failure {
  25. ff := failureByFunc{
  26. failureCase: rpcpb.FailureCase_BLACKHOLE_PEER_PORT_TX_RX_ONE_FOLLOWER,
  27. injectMember: injectBlackholePeerPortTxRx,
  28. recoverMember: recoverBlackholePeerPortTxRx,
  29. }
  30. f := &failureFollower{ff, -1, -1}
  31. return &failureDelay{
  32. Failure: f,
  33. delayDuration: clus.GetFailureDelayDuration(),
  34. }
  35. }
  36. func newFailureBlackholePeerPortTxRxLeader(clus *Cluster) Failure {
  37. ff := failureByFunc{
  38. failureCase: rpcpb.FailureCase_BLACKHOLE_PEER_PORT_TX_RX_LEADER,
  39. injectMember: injectBlackholePeerPortTxRx,
  40. recoverMember: recoverBlackholePeerPortTxRx,
  41. }
  42. f := &failureLeader{ff, -1, -1}
  43. return &failureDelay{
  44. Failure: f,
  45. delayDuration: clus.GetFailureDelayDuration(),
  46. }
  47. }
  48. func newFailureBlackholePeerPortTxRxAll(clus *Cluster) Failure {
  49. f := &failureAll{
  50. failureCase: rpcpb.FailureCase_BLACKHOLE_PEER_PORT_TX_RX_ALL,
  51. injectMember: injectBlackholePeerPortTxRx,
  52. recoverMember: recoverBlackholePeerPortTxRx,
  53. }
  54. return &failureDelay{
  55. Failure: f,
  56. delayDuration: clus.GetFailureDelayDuration(),
  57. }
  58. }