failure_no_fail.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 (
  16. "time"
  17. "github.com/coreos/etcd/functional/rpcpb"
  18. "go.uber.org/zap"
  19. )
  20. type failureNoFailWithStress failureByFunc
  21. func (f *failureNoFailWithStress) Inject(clus *Cluster) error {
  22. return nil
  23. }
  24. func (f *failureNoFailWithStress) Recover(clus *Cluster) error {
  25. return nil
  26. }
  27. func (f *failureNoFailWithStress) Desc() string {
  28. if f.desc != "" {
  29. return f.desc
  30. }
  31. return f.failureCase.String()
  32. }
  33. func (f *failureNoFailWithStress) FailureCase() rpcpb.FailureCase {
  34. return f.failureCase
  35. }
  36. func new_FailureCase_NO_FAIL_WITH_STRESS(clus *Cluster) Failure {
  37. f := &failureNoFailWithStress{
  38. failureCase: rpcpb.FailureCase_NO_FAIL_WITH_STRESS,
  39. }
  40. return &failureDelay{
  41. Failure: f,
  42. delayDuration: clus.GetFailureDelayDuration(),
  43. }
  44. }
  45. type failureNoFailWithNoStressForLiveness failureByFunc
  46. func (f *failureNoFailWithNoStressForLiveness) Inject(clus *Cluster) error {
  47. clus.lg.Info(
  48. "extra delay for liveness mode with no stresser",
  49. zap.Int("round", clus.rd),
  50. zap.Int("case", clus.cs),
  51. zap.String("desc", f.Desc()),
  52. )
  53. time.Sleep(clus.GetFailureDelayDuration())
  54. clus.lg.Info(
  55. "wait health in liveness mode",
  56. zap.Int("round", clus.rd),
  57. zap.Int("case", clus.cs),
  58. zap.String("desc", f.Desc()),
  59. )
  60. return clus.WaitHealth()
  61. }
  62. func (f *failureNoFailWithNoStressForLiveness) Recover(clus *Cluster) error {
  63. return nil
  64. }
  65. func (f *failureNoFailWithNoStressForLiveness) Desc() string {
  66. if f.desc != "" {
  67. return f.desc
  68. }
  69. return f.failureCase.String()
  70. }
  71. func (f *failureNoFailWithNoStressForLiveness) FailureCase() rpcpb.FailureCase {
  72. return f.failureCase
  73. }
  74. func new_FailureCase_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS(clus *Cluster) Failure {
  75. f := &failureNoFailWithNoStressForLiveness{
  76. failureCase: rpcpb.FailureCase_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS,
  77. }
  78. return &failureDelay{
  79. Failure: f,
  80. delayDuration: clus.GetFailureDelayDuration(),
  81. }
  82. }