github.com/IBM-Blockchain/fabric-operator@v1.0.4/integration/orderer/orderer_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 orderer_test
    20  
    21  import (
    22  	"fmt"
    23  	"os"
    24  	"path/filepath"
    25  	"strings"
    26  	"testing"
    27  	"time"
    28  
    29  	"github.com/IBM-Blockchain/fabric-operator/integration"
    30  	"github.com/IBM-Blockchain/fabric-operator/integration/helper"
    31  	ibpclient "github.com/IBM-Blockchain/fabric-operator/pkg/client"
    32  	. "github.com/onsi/ginkgo/v2"
    33  	. "github.com/onsi/gomega"
    34  	"github.com/onsi/gomega/gexec"
    35  	"k8s.io/client-go/kubernetes"
    36  )
    37  
    38  func TestOrderer(t *testing.T) {
    39  	RegisterFailHandler(Fail)
    40  	RunSpecs(t, "Orderer Suite")
    41  }
    42  
    43  const (
    44  	FabricBinaryVersion   = "2.2.3"
    45  	FabricCABinaryVersion = "1.5.1"
    46  	ordererUsername       = "orderer"
    47  	ordererPassword       = "orderer"
    48  )
    49  
    50  var (
    51  	namespaceSuffix = "orderer"
    52  
    53  	namespace   string
    54  	kclient     *kubernetes.Clientset
    55  	ibpCRClient *ibpclient.IBPClient
    56  	testFailed  bool
    57  	wd          string
    58  )
    59  
    60  var _ = BeforeSuite(func() {
    61  	SetDefaultEventuallyTimeout(300 * time.Second)
    62  	SetDefaultEventuallyPollingInterval(time.Second)
    63  
    64  	var err error
    65  
    66  	wd, err = os.Getwd()
    67  	Expect(err).NotTo(HaveOccurred())
    68  	fmt.Fprintf(GinkgoWriter, "Working directory: %s\n", wd)
    69  
    70  	cfg := &integration.Config{
    71  		OperatorServiceAccount: "../../config/rbac/service_account.yaml",
    72  		OperatorRole:           "../../config/rbac/role.yaml",
    73  		OperatorRoleBinding:    "../../config/rbac/role_binding.yaml",
    74  		OperatorDeployment:     "../../testdata/deploy/operator.yaml",
    75  		OrdererSecret:          "../../testdata/deploy/orderer/secret.yaml",
    76  		PeerSecret:             "../../testdata/deploy/peer/secret.yaml",
    77  		ConsoleTLSSecret:       "../../testdata/deploy/console/tlssecret.yaml",
    78  	}
    79  
    80  	namespace, kclient, ibpCRClient, err = integration.Setup(GinkgoWriter, cfg, namespaceSuffix, "")
    81  	Expect(err).NotTo(HaveOccurred())
    82  
    83  })
    84  
    85  var _ = AfterSuite(func() {
    86  
    87  	if strings.ToLower(os.Getenv("SAVE_TEST")) == "true" {
    88  		return
    89  	}
    90  
    91  	if strings.ToLower(os.Getenv("SAVE_TEST")) == "true" {
    92  		return
    93  	}
    94  
    95  	err := integration.Cleanup(GinkgoWriter, kclient, namespace)
    96  	Expect(err).NotTo(HaveOccurred())
    97  })
    98  
    99  func downloadBinaries() {
   100  	os.Setenv("FABRIC_VERSION", FabricBinaryVersion)
   101  	os.Setenv("FABRIC_CA_VERSION", FabricCABinaryVersion)
   102  	sess, err := helper.StartSession(helper.GetCommand(filepath.Join(wd, "../../scripts/download_binaries.sh")), "Download Binaries")
   103  	Expect(err).NotTo(HaveOccurred())
   104  	Eventually(sess).Should(gexec.Exit(0))
   105  }