go.etcd.io/etcd@v3.3.27+incompatible/functional/tester/case_no_fail.go (about)

     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  
    15  package tester
    16  
    17  import (
    18  	"time"
    19  
    20  	"github.com/coreos/etcd/functional/rpcpb"
    21  
    22  	"go.uber.org/zap"
    23  )
    24  
    25  type caseNoFailWithStress caseByFunc
    26  
    27  func (c *caseNoFailWithStress) Inject(clus *Cluster) error {
    28  	return nil
    29  }
    30  
    31  func (c *caseNoFailWithStress) Recover(clus *Cluster) error {
    32  	return nil
    33  }
    34  
    35  func (c *caseNoFailWithStress) Desc() string {
    36  	if c.desc != "" {
    37  		return c.desc
    38  	}
    39  	return c.rpcpbCase.String()
    40  }
    41  
    42  func (c *caseNoFailWithStress) TestCase() rpcpb.Case {
    43  	return c.rpcpbCase
    44  }
    45  
    46  func new_Case_NO_FAIL_WITH_STRESS(clus *Cluster) Case {
    47  	c := &caseNoFailWithStress{
    48  		rpcpbCase: rpcpb.Case_NO_FAIL_WITH_STRESS,
    49  	}
    50  	return &caseDelay{
    51  		Case:          c,
    52  		delayDuration: clus.GetCaseDelayDuration(),
    53  	}
    54  }
    55  
    56  type caseNoFailWithNoStressForLiveness caseByFunc
    57  
    58  func (c *caseNoFailWithNoStressForLiveness) Inject(clus *Cluster) error {
    59  	clus.lg.Info(
    60  		"extra delay for liveness mode with no stresser",
    61  		zap.Int("round", clus.rd),
    62  		zap.Int("case", clus.cs),
    63  		zap.String("desc", c.Desc()),
    64  	)
    65  	time.Sleep(clus.GetCaseDelayDuration())
    66  
    67  	clus.lg.Info(
    68  		"wait health in liveness mode",
    69  		zap.Int("round", clus.rd),
    70  		zap.Int("case", clus.cs),
    71  		zap.String("desc", c.Desc()),
    72  	)
    73  	return clus.WaitHealth()
    74  }
    75  
    76  func (c *caseNoFailWithNoStressForLiveness) Recover(clus *Cluster) error {
    77  	return nil
    78  }
    79  
    80  func (c *caseNoFailWithNoStressForLiveness) Desc() string {
    81  	if c.desc != "" {
    82  		return c.desc
    83  	}
    84  	return c.rpcpbCase.String()
    85  }
    86  
    87  func (c *caseNoFailWithNoStressForLiveness) TestCase() rpcpb.Case {
    88  	return c.rpcpbCase
    89  }
    90  
    91  func new_Case_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS(clus *Cluster) Case {
    92  	c := &caseNoFailWithNoStressForLiveness{
    93  		rpcpbCase: rpcpb.Case_NO_FAIL_WITH_NO_STRESS_FOR_LIVENESS,
    94  	}
    95  	return &caseDelay{
    96  		Case:          c,
    97  		delayDuration: clus.GetCaseDelayDuration(),
    98  	}
    99  }