github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/integration/kafka/kafka_suite_test.go (about)

     1  /*
     2  Copyright hechain All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package kafka
     8  
     9  import (
    10  	"encoding/json"
    11  	"runtime"
    12  	"testing"
    13  
    14  	"github.com/hechain20/hechain/integration"
    15  	"github.com/hechain20/hechain/integration/nwo"
    16  	"github.com/hechain20/hechain/integration/nwo/runner"
    17  	. "github.com/onsi/ginkgo"
    18  	. "github.com/onsi/gomega"
    19  )
    20  
    21  func TestKafka(t *testing.T) {
    22  	RegisterFailHandler(Fail)
    23  	if runtime.GOARCH != "amd64" {
    24  		t.Skip("Kafka and ZooKeeper images may not be available for this platform")
    25  	}
    26  	RunSpecs(t, "Kafka Suite")
    27  }
    28  
    29  var (
    30  	buildServer *nwo.BuildServer
    31  	components  *nwo.Components
    32  )
    33  
    34  var _ = SynchronizedBeforeSuite(func() []byte {
    35  	nwo.RequiredImages = append(
    36  		nwo.RequiredImages,
    37  		runner.KafkaDefaultImage,
    38  		runner.ZooKeeperDefaultImage,
    39  	)
    40  	buildServer = nwo.NewBuildServer()
    41  	buildServer.Serve()
    42  
    43  	components = buildServer.Components()
    44  	payload, err := json.Marshal(components)
    45  	Expect(err).NotTo(HaveOccurred())
    46  
    47  	return payload
    48  }, func(payload []byte) {
    49  	err := json.Unmarshal(payload, &components)
    50  	Expect(err).NotTo(HaveOccurred())
    51  })
    52  
    53  var _ = SynchronizedAfterSuite(func() {
    54  }, func() {
    55  	buildServer.Shutdown()
    56  })
    57  
    58  func StartPort() int {
    59  	return integration.KafkaBasePort.StartPortForNode()
    60  }