failure_case_sigterm.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_LEADER(clus *Cluster) Failure {
  35. ff := failureByFunc{
  36. failureCase: rpcpb.FailureCase_SIGTERM_LEADER,
  37. injectMember: inject_SIGTERM_ETCD,
  38. recoverMember: recover_SIGTERM_ETCD,
  39. }
  40. f := &failureLeader{ff, -1, -1}
  41. return &failureDelay{
  42. Failure: f,
  43. delayDuration: clus.GetFailureDelayDuration(),
  44. }
  45. }
  46. func new_FailureCase_SIGTERM_QUORUM(clus *Cluster) Failure {
  47. f := &failureQuorum{
  48. failureCase: rpcpb.FailureCase_SIGTERM_QUORUM,
  49. injectMember: inject_SIGTERM_ETCD,
  50. recoverMember: recover_SIGTERM_ETCD,
  51. }
  52. return &failureDelay{
  53. Failure: f,
  54. delayDuration: clus.GetFailureDelayDuration(),
  55. }
  56. }
  57. func new_FailureCase_SIGTERM_ALL(clus *Cluster) Failure {
  58. f := &failureAll{
  59. failureCase: rpcpb.FailureCase_SIGTERM_ALL,
  60. injectMember: inject_SIGTERM_ETCD,
  61. recoverMember: recover_SIGTERM_ETCD,
  62. }
  63. return &failureDelay{
  64. Failure: f,
  65. delayDuration: clus.GetFailureDelayDuration(),
  66. }
  67. }
  68. func new_FailureCase_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Failure {
  69. return &failureUntilSnapshot{
  70. failureCase: rpcpb.FailureCase_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT,
  71. Failure: new_FailureCase_SIGTERM_ONE_FOLLOWER(clus),
  72. }
  73. }
  74. func new_FailureCase_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Failure {
  75. return &failureUntilSnapshot{
  76. failureCase: rpcpb.FailureCase_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT,
  77. Failure: new_FailureCase_SIGTERM_LEADER(clus),
  78. }
  79. }