failure_case_blackhole.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 "github.com/coreos/etcd/tools/functional-tester/rpcpb"
  16. func injectBlackholePeerPortTxRx(clus *Cluster, idx int) error {
  17. return clus.sendOperation(idx, rpcpb.Operation_BlackholePeerPortTxRx)
  18. }
  19. func recoverBlackholePeerPortTxRx(clus *Cluster, idx int) error {
  20. return clus.sendOperation(idx, rpcpb.Operation_UnblackholePeerPortTxRx)
  21. }
  22. func newFailureBlackholePeerPortTxRxOne() Failure {
  23. f := &failureOne{
  24. description: "blackhole peer port on one member",
  25. injectMember: injectBlackholePeerPortTxRx,
  26. recoverMember: recoverBlackholePeerPortTxRx,
  27. }
  28. return &failureDelay{
  29. Failure: f,
  30. delayDuration: triggerElectionDur,
  31. }
  32. }
  33. func newFailureBlackholePeerPortTxRxAll() Failure {
  34. f := &failureAll{
  35. description: "blackhole peer port on all members",
  36. injectMember: injectBlackholePeerPortTxRx,
  37. recoverMember: recoverBlackholePeerPortTxRx,
  38. }
  39. return &failureDelay{
  40. Failure: f,
  41. delayDuration: triggerElectionDur,
  42. }
  43. }