github.com/IBM-Blockchain/fabric-operator@v1.0.4/integration/operatorrestart/operatorrestart_test.go (about) 1 /* 2 * Copyright contributors to the Hyperledger Fabric Operator project 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package operatorrestart_test 20 21 import ( 22 "fmt" 23 "time" 24 25 "github.com/IBM-Blockchain/fabric-operator/integration/helper" 26 . "github.com/onsi/ginkgo/v2" 27 . "github.com/onsi/gomega" 28 ) 29 30 var _ = Describe("operator restart", func() { 31 Context("CA", func() { 32 var ( 33 originalPodName string 34 ) 35 36 BeforeEach(func() { 37 Eventually(func() int { 38 return len(org1ca.GetRunningPods()) 39 }).Should(Equal(1)) 40 originalPodName = org1ca.GetRunningPods()[0].Name 41 }) 42 43 It("does not restart ca on operator restart", func() { 44 RestartOperator() 45 46 Consistently(func() string { 47 fmt.Fprintf(GinkgoWriter, "Making sure '%s' does not restart, original pod name '%s'\n", org1ca.Name, originalPodName) 48 49 if len(org1ca.GetRunningPods()) != 1 { 50 return "incorrect number of running pods" 51 } 52 53 return org1ca.GetRunningPods()[0].Name 54 }, 5*time.Second, time.Second).Should(Equal(originalPodName)) 55 }) 56 }) 57 58 Context("Peer", func() { 59 var ( 60 originalPodName string 61 ) 62 63 BeforeEach(func() { 64 Eventually(func() int { 65 return len(org1peer.GetRunningPods()) 66 }).Should(Equal(1)) 67 originalPodName = org1peer.GetRunningPods()[0].Name 68 }) 69 70 It("does not restart peer on operator restart", func() { 71 RestartOperator() 72 73 Consistently(func() string { 74 fmt.Fprintf(GinkgoWriter, "Making sure '%s' does not restart, original pod name '%s'\n", org1peer.Name, originalPodName) 75 76 if len(org1peer.GetRunningPods()) != 1 { 77 return "incorrect number of running pods" 78 } 79 80 return org1peer.GetRunningPods()[0].Name 81 }, 5*time.Second, time.Second).Should(Equal(originalPodName)) 82 }) 83 }) 84 85 Context("Orderer Node", func() { 86 var ( 87 node helper.Orderer 88 originalPodName string 89 ) 90 91 BeforeEach(func() { 92 node = orderer.Nodes[0] 93 94 Eventually(func() int { 95 return len(node.GetRunningPods()) 96 }).Should(Equal(1)) 97 originalPodName = node.GetRunningPods()[0].Name 98 }) 99 100 It("does not restart orderer node on operator restart", func() { 101 RestartOperator() 102 103 Consistently(func() string { 104 fmt.Fprintf(GinkgoWriter, "Making sure '%s' does not restart, original pod name '%s'\n", node.Name, originalPodName) 105 106 if len(org1peer.GetRunningPods()) != 1 { 107 return "incorrect number of running pods" 108 } 109 110 return node.GetRunningPods()[0].Name 111 }, 5*time.Second, time.Second).Should(Equal(originalPodName)) 112 }) 113 }) 114 })