failure_sigterm.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_SIGTERM_ETCD(clus *Cluster, idx int) error {
  17. return clus.sendOp(idx, rpcpb.Operation_SIGTERM_ETCD)
  18. }
  19. func recover_SIGTERM_ETCD(clus *Cluster, idx int) error {
  20. return clus.sendOp(idx, rpcpb.Operation_RESTART_ETCD)
  21. }
  22. func new_FailureCase_SIGTERM_ONE_FOLLOWER(clus *Cluster) Failure {
  23. ff := failureByFunc{
  24. failureCase: rpcpb.FailureCase_SIGTERM_ONE_FOLLOWER,
  25. injectMember: inject_SIGTERM_ETCD,
  26. recoverMember: recover_SIGTERM_ETCD,
  27. }
  28. f := &failureFollower{ff, -1, -1}
  29. return &failureDelay{
  30. Failure: f,
  31. delayDuration: clus.GetFailureDelayDuration(),
  32. }
  33. }
  34. func new_FailureCase_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Failure {
  35. return &failureUntilSnapshot{
  36. failureCase: rpcpb.FailureCase_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT,
  37. Failure: new_FailureCase_SIGTERM_ONE_FOLLOWER(clus),
  38. }
  39. }
  40. func new_FailureCase_SIGTERM_LEADER(clus *Cluster) Failure {
  41. ff := failureByFunc{
  42. failureCase: rpcpb.FailureCase_SIGTERM_LEADER,
  43. injectMember: inject_SIGTERM_ETCD,
  44. recoverMember: recover_SIGTERM_ETCD,
  45. }
  46. f := &failureLeader{ff, -1, -1}
  47. return &failureDelay{
  48. Failure: f,
  49. delayDuration: clus.GetFailureDelayDuration(),
  50. }
  51. }
  52. func new_FailureCase_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Failure {
  53. return &failureUntilSnapshot{
  54. failureCase: rpcpb.FailureCase_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT,
  55. Failure: new_FailureCase_SIGTERM_LEADER(clus),
  56. }
  57. }
  58. func new_FailureCase_SIGTERM_QUORUM(clus *Cluster) Failure {
  59. f := &failureQuorum{
  60. failureByFunc: failureByFunc{
  61. failureCase: rpcpb.FailureCase_SIGTERM_QUORUM,
  62. injectMember: inject_SIGTERM_ETCD,
  63. recoverMember: recover_SIGTERM_ETCD,
  64. },
  65. injected: make(map[int]struct{}),
  66. }
  67. return &failureDelay{
  68. Failure: f,
  69. delayDuration: clus.GetFailureDelayDuration(),
  70. }
  71. }
  72. func new_FailureCase_SIGTERM_ALL(clus *Cluster) Failure {
  73. f := &failureAll{
  74. failureCase: rpcpb.FailureCase_SIGTERM_ALL,
  75. injectMember: inject_SIGTERM_ETCD,
  76. recoverMember: recover_SIGTERM_ETCD,
  77. }
  78. return &failureDelay{
  79. Failure: f,
  80. delayDuration: clus.GetFailureDelayDuration(),
  81. }
  82. }