github.com/IBM-Blockchain/fabric-operator@v1.0.4/integration/console/console_suite_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 console_test 20 21 import ( 22 "context" 23 "os" 24 "strings" 25 "testing" 26 27 "github.com/IBM-Blockchain/fabric-operator/integration" 28 ibpclient "github.com/IBM-Blockchain/fabric-operator/pkg/client" 29 . "github.com/onsi/ginkgo/v2" 30 . "github.com/onsi/gomega" 31 k8serrors "k8s.io/apimachinery/pkg/api/errors" 32 "k8s.io/client-go/kubernetes" 33 ) 34 35 func TestConsole(t *testing.T) { 36 RegisterFailHandler(Fail) 37 RunSpecs(t, "Console Suite") 38 } 39 40 var ( 41 namespace string 42 kclient *kubernetes.Clientset 43 ibpCRClient *ibpclient.IBPClient 44 testFailed bool 45 ) 46 47 var _ = BeforeSuite(func() { 48 var err error 49 50 cfg := &integration.Config{ 51 OperatorServiceAccount: "../../config/rbac/service_account.yaml", 52 OperatorRole: "../../config/rbac/role.yaml", 53 OperatorRoleBinding: "../../config/rbac/role_binding.yaml", 54 OperatorDeployment: "../../testdata/deploy/operator.yaml", 55 OrdererSecret: "../../testdata/deploy/orderer/secret.yaml", 56 PeerSecret: "../../testdata/deploy/peer/secret.yaml", 57 ConsoleTLSSecret: "../../testdata/deploy/console/tlssecret.yaml", 58 } 59 60 namespace, kclient, ibpCRClient, err = integration.Setup(GinkgoWriter, cfg, "console", "") 61 Expect(err).NotTo(HaveOccurred()) 62 63 console = GetConsole() 64 result := ibpCRClient.Post().Namespace(namespace).Resource("ibpconsoles").Body(console.CR).Do(context.TODO()) 65 err = result.Error() 66 if !k8serrors.IsAlreadyExists(err) { 67 Expect(result.Error()).NotTo(HaveOccurred()) 68 } 69 70 // Disabled as it consumes too many resources on the GHA executor to reliably launch console1 71 //console2 = GetConsole2() 72 //result = ibpCRClient.Post().Namespace(namespace).Resource("ibpconsoles").Body(console2.CR).Do(context.TODO()) 73 //err = result.Error() 74 //if !k8serrors.IsAlreadyExists(err) { 75 // Expect(err).NotTo(HaveOccurred()) 76 //} 77 78 console3 = GetConsole3() 79 result = ibpCRClient.Post().Namespace(namespace).Resource("ibpconsoles").Body(console3.CR).Do(context.TODO()) 80 err = result.Error() 81 if !k8serrors.IsAlreadyExists(err) { 82 Expect(err).NotTo(HaveOccurred()) 83 } 84 }) 85 86 var _ = AfterSuite(func() { 87 88 if strings.ToLower(os.Getenv("SAVE_TEST")) == "true" { 89 return 90 } 91 err := integration.Cleanup(GinkgoWriter, kclient, namespace) 92 Expect(err).NotTo(HaveOccurred()) 93 })