case_sigterm.go 2.6 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_Case_SIGTERM_ONE_FOLLOWER(clus *Cluster) Case {
  23. cc := caseByFunc{
  24. rpcpbCase: rpcpb.Case_SIGTERM_ONE_FOLLOWER,
  25. injectMember: inject_SIGTERM_ETCD,
  26. recoverMember: recover_SIGTERM_ETCD,
  27. }
  28. c := &caseFollower{cc, -1, -1}
  29. return &caseDelay{
  30. Case: c,
  31. delayDuration: clus.GetCaseDelayDuration(),
  32. }
  33. }
  34. func new_Case_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Case {
  35. return &caseUntilSnapshot{
  36. rpcpbCase: rpcpb.Case_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT,
  37. Case: new_Case_SIGTERM_ONE_FOLLOWER(clus),
  38. }
  39. }
  40. func new_Case_SIGTERM_LEADER(clus *Cluster) Case {
  41. cc := caseByFunc{
  42. rpcpbCase: rpcpb.Case_SIGTERM_LEADER,
  43. injectMember: inject_SIGTERM_ETCD,
  44. recoverMember: recover_SIGTERM_ETCD,
  45. }
  46. c := &caseLeader{cc, -1, -1}
  47. return &caseDelay{
  48. Case: c,
  49. delayDuration: clus.GetCaseDelayDuration(),
  50. }
  51. }
  52. func new_Case_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Case {
  53. return &caseUntilSnapshot{
  54. rpcpbCase: rpcpb.Case_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT,
  55. Case: new_Case_SIGTERM_LEADER(clus),
  56. }
  57. }
  58. func new_Case_SIGTERM_QUORUM(clus *Cluster) Case {
  59. c := &caseQuorum{
  60. caseByFunc: caseByFunc{
  61. rpcpbCase: rpcpb.Case_SIGTERM_QUORUM,
  62. injectMember: inject_SIGTERM_ETCD,
  63. recoverMember: recover_SIGTERM_ETCD,
  64. },
  65. injected: make(map[int]struct{}),
  66. }
  67. return &caseDelay{
  68. Case: c,
  69. delayDuration: clus.GetCaseDelayDuration(),
  70. }
  71. }
  72. func new_Case_SIGTERM_ALL(clus *Cluster) Case {
  73. c := &caseAll{
  74. rpcpbCase: rpcpb.Case_SIGTERM_ALL,
  75. injectMember: inject_SIGTERM_ETCD,
  76. recoverMember: recover_SIGTERM_ETCD,
  77. }
  78. return &caseDelay{
  79. Case: c,
  80. delayDuration: clus.GetCaseDelayDuration(),
  81. }
  82. }