go.etcd.io/etcd@v3.3.27+incompatible/functional/tester/case_sigterm.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 "github.com/coreos/etcd/functional/rpcpb" 18 19 func inject_SIGTERM_ETCD(clus *Cluster, idx int) error { 20 return clus.sendOp(idx, rpcpb.Operation_SIGTERM_ETCD) 21 } 22 23 func recover_SIGTERM_ETCD(clus *Cluster, idx int) error { 24 return clus.sendOp(idx, rpcpb.Operation_RESTART_ETCD) 25 } 26 27 func new_Case_SIGTERM_ONE_FOLLOWER(clus *Cluster) Case { 28 cc := caseByFunc{ 29 rpcpbCase: rpcpb.Case_SIGTERM_ONE_FOLLOWER, 30 injectMember: inject_SIGTERM_ETCD, 31 recoverMember: recover_SIGTERM_ETCD, 32 } 33 c := &caseFollower{cc, -1, -1} 34 return &caseDelay{ 35 Case: c, 36 delayDuration: clus.GetCaseDelayDuration(), 37 } 38 } 39 40 func new_Case_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Case { 41 return &caseUntilSnapshot{ 42 rpcpbCase: rpcpb.Case_SIGTERM_ONE_FOLLOWER_UNTIL_TRIGGER_SNAPSHOT, 43 Case: new_Case_SIGTERM_ONE_FOLLOWER(clus), 44 } 45 } 46 47 func new_Case_SIGTERM_LEADER(clus *Cluster) Case { 48 cc := caseByFunc{ 49 rpcpbCase: rpcpb.Case_SIGTERM_LEADER, 50 injectMember: inject_SIGTERM_ETCD, 51 recoverMember: recover_SIGTERM_ETCD, 52 } 53 c := &caseLeader{cc, -1, -1} 54 return &caseDelay{ 55 Case: c, 56 delayDuration: clus.GetCaseDelayDuration(), 57 } 58 } 59 60 func new_Case_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT(clus *Cluster) Case { 61 return &caseUntilSnapshot{ 62 rpcpbCase: rpcpb.Case_SIGTERM_LEADER_UNTIL_TRIGGER_SNAPSHOT, 63 Case: new_Case_SIGTERM_LEADER(clus), 64 } 65 } 66 67 func new_Case_SIGTERM_QUORUM(clus *Cluster) Case { 68 c := &caseQuorum{ 69 caseByFunc: caseByFunc{ 70 rpcpbCase: rpcpb.Case_SIGTERM_QUORUM, 71 injectMember: inject_SIGTERM_ETCD, 72 recoverMember: recover_SIGTERM_ETCD, 73 }, 74 injected: make(map[int]struct{}), 75 } 76 return &caseDelay{ 77 Case: c, 78 delayDuration: clus.GetCaseDelayDuration(), 79 } 80 } 81 82 func new_Case_SIGTERM_ALL(clus *Cluster) Case { 83 c := &caseAll{ 84 rpcpbCase: rpcpb.Case_SIGTERM_ALL, 85 injectMember: inject_SIGTERM_ETCD, 86 recoverMember: recover_SIGTERM_ETCD, 87 } 88 return &caseDelay{ 89 Case: c, 90 delayDuration: clus.GetCaseDelayDuration(), 91 } 92 }