case_no_fail.go 2.3 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 caseNoFailWithStress caseByFunc
  21. func (c *caseNoFailWithStress) Inject(clus *Cluster) error {
  22. return nil
  23. }
  24. func (c *caseNoFailWithStress) Recover(clus *Cluster) error {
  25. return nil
  26. }
  27. func (c *caseNoFailWithStress) Desc() string {
  28. if c.desc != "" {
  29. return c.desc
  30. }
  31. return c.rpcpbCase.String()
  32. }
  33. func (c *caseNoFailWithStress) TestCase() rpcpb.Case {
  34. return c.rpcpbCase
  35. }
  36. func new_Case_NO_FAIL_WITH_STRESS(clus *Cluster) Case {
  37. c := &caseNoFailWithStress{
  38. rpcpbCase: rpcpb.Case_NO_FAIL_WITH_STRESS,
  39. }
  40. return &caseDelay{
  41. Case: c,
  42. delayDuration: clus.GetCaseDelayDuration(),
  43. }
  44. }
  45. type caseNoFailWithNoStressForLiveness caseByFunc
  46. func (c *caseNoFailWithNoStressForLiveness) 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", c.Desc()),
  52. )
  53. time.Sleep(clus.GetCaseDelayDuration())
  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", c.Desc()),
  59. )
  60. return clus.WaitHealth()
  61. }
  62. func (c *caseNoFailWithNoStressForLiveness) Recover(clus *Cluster) error {
  63. return nil
  64. }
  65. func (c *caseNoFailWithNoStressForLiveness) Desc() string {
  66. if c.desc != "" {
  67. return c.desc
  68. }
  69. return c.rpcpbCase.String()
  70. }
  71. func (c *caseNoFailWithNoStressForLiveness) TestCase() rpcpb.Case {
  72. return c.rpcpbCase
  73. }
  74. func new_Case_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS(clus *Cluster) Case {
  75. c := &caseNoFailWithNoStressForLiveness{
  76. rpcpbCase: rpcpb.Case_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS,
  77. }
  78. return &caseDelay{
  79. Case: c,
  80. delayDuration: clus.GetCaseDelayDuration(),
  81. }
  82. }