case_network_blackhole.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/functional/rpcpb"
  16. func inject_BLACKHOLE_PEER_PORT_TX_RX(clus *Cluster, idx int) error {
  17. return clus.sendOp(idx, rpcpb.Operation_BLACKHOLE_PEER_PORT_TX_RX)
  18. }
  19. func recover_BLACKHOLE_PEER_PORT_TX_RX(clus *Cluster, idx int) error {
  20. return clus.sendOp(idx, rpcpb.Operation_UNBLACKHOLE_PEER_PORT_TX_RX)
  21. }
  22. func new_Case_BLACKHOLE_PEER_PORT_TX_RX_ONE_FOLLOWER(clus *Cluster) Case {
  23. cc := caseByFunc{
  24. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_ONE_FOLLOWER,
  25. injectMember: inject_BLACKHOLE_PEER_PORT_TX_RX,
  26. recoverMember: recover_BLACKHOLE_PEER_PORT_TX_RX,
  27. }
  28. c := &caseFollower{cc, -1, -1}
  29. return &caseDelay{
  30. Case: c,
  31. delayDuration: clus.GetCaseDelayDuration(),
  32. }
  33. }
  34. func new_Case_BLACKHOLE_PEER_PORT_TX_RX_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT() Case {
  35. cc := caseByFunc{
  36. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT,
  37. injectMember: inject_BLACKHOLE_PEER_PORT_TX_RX,
  38. recoverMember: recover_BLACKHOLE_PEER_PORT_TX_RX,
  39. }
  40. c := &caseFollower{cc, -1, -1}
  41. return &caseUntilSnapshot{
  42. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT,
  43. Case: c,
  44. }
  45. }
  46. func new_Case_BLACKHOLE_PEER_PORT_TX_RX_LEADER(clus *Cluster) Case {
  47. cc := caseByFunc{
  48. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_LEADER,
  49. injectMember: inject_BLACKHOLE_PEER_PORT_TX_RX,
  50. recoverMember: recover_BLACKHOLE_PEER_PORT_TX_RX,
  51. }
  52. c := &caseLeader{cc, -1, -1}
  53. return &caseDelay{
  54. Case: c,
  55. delayDuration: clus.GetCaseDelayDuration(),
  56. }
  57. }
  58. func new_Case_BLACKHOLE_PEER_PORT_TX_RX_LEADER_UNTIL_TRIGGER_SNAPSHOT() Case {
  59. cc := caseByFunc{
  60. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_LEADER_UNTIL_TRIGGER_SNAPSHOT,
  61. injectMember: inject_BLACKHOLE_PEER_PORT_TX_RX,
  62. recoverMember: recover_BLACKHOLE_PEER_PORT_TX_RX,
  63. }
  64. c := &caseLeader{cc, -1, -1}
  65. return &caseUntilSnapshot{
  66. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_LEADER_UNTIL_TRIGGER_SNAPSHOT,
  67. Case: c,
  68. }
  69. }
  70. func new_Case_BLACKHOLE_PEER_PORT_TX_RX_QUORUM(clus *Cluster) Case {
  71. c := &caseQuorum{
  72. caseByFunc: caseByFunc{
  73. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_QUORUM,
  74. injectMember: inject_BLACKHOLE_PEER_PORT_TX_RX,
  75. recoverMember: recover_BLACKHOLE_PEER_PORT_TX_RX,
  76. },
  77. injected: make(map[int]struct{}),
  78. }
  79. return &caseDelay{
  80. Case: c,
  81. delayDuration: clus.GetCaseDelayDuration(),
  82. }
  83. }
  84. func new_Case_BLACKHOLE_PEER_PORT_TX_RX_ALL(clus *Cluster) Case {
  85. c := &caseAll{
  86. rpcpbCase: rpcpb.Case_BLACKHOLE_PEER_PORT_TX_RX_ALL,
  87. injectMember: inject_BLACKHOLE_PEER_PORT_TX_RX,
  88. recoverMember: recover_BLACKHOLE_PEER_PORT_TX_RX,
  89. }
  90. return &caseDelay{
  91. Case: c,
  92. delayDuration: clus.GetCaseDelayDuration(),
  93. }
  94. }