failure_case_no_fail.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/tools/functional-tester/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) FailureCase() rpcpb.FailureCase {
  28. return f.failureCase
  29. }
  30. func newFailureNoFailWithStress(clus *Cluster) Failure {
  31. f := &failureNoFailWithStress{
  32. failureCase: rpcpb.FailureCase_NO_FAIL_WITH_STRESS,
  33. }
  34. return &failureDelay{
  35. Failure: f,
  36. delayDuration: clus.GetFailureDelayDuration(),
  37. }
  38. }
  39. type failureNoFailWithNoStressForLiveness failureByFunc
  40. func (f *failureNoFailWithNoStressForLiveness) Inject(clus *Cluster) error {
  41. clus.lg.Info(
  42. "extra delay for liveness mode with no stresser",
  43. zap.Int("round", clus.rd),
  44. zap.Int("case", clus.cs),
  45. zap.String("desc", f.Desc()),
  46. )
  47. time.Sleep(clus.GetFailureDelayDuration())
  48. clus.lg.Info(
  49. "wait health in liveness mode",
  50. zap.Int("round", clus.rd),
  51. zap.Int("case", clus.cs),
  52. zap.String("desc", f.Desc()),
  53. )
  54. return clus.WaitHealth()
  55. }
  56. func (f *failureNoFailWithNoStressForLiveness) Recover(clus *Cluster) error {
  57. return nil
  58. }
  59. func (f *failureNoFailWithNoStressForLiveness) FailureCase() rpcpb.FailureCase {
  60. return f.failureCase
  61. }
  62. func newFailureNoFailWithNoStressForLiveness(clus *Cluster) Failure {
  63. f := &failureNoFailWithNoStressForLiveness{
  64. failureCase: rpcpb.FailureCase_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS,
  65. }
  66. return &failureDelay{
  67. Failure: f,
  68. delayDuration: clus.GetFailureDelayDuration(),
  69. }
  70. }