github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/orderer/kafka/config_test.go (about)

     1  /*
     2  Copyright IBM Corp. 2016 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8                   http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package kafka
    18  
    19  import (
    20  	"testing"
    21  	"time"
    22  
    23  	"github.com/Shopify/sarama"
    24  	genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
    25  	"github.com/hyperledger/fabric/orderer/localconfig"
    26  	cb "github.com/hyperledger/fabric/protos/common"
    27  )
    28  
    29  var (
    30  	testBrokerID     = int32(0)
    31  	testOldestOffset = int64(100)                                    // The oldest block available on the broker
    32  	testNewestOffset = int64(1100)                                   // The offset that will be assigned to the next block
    33  	testMiddleOffset = (testOldestOffset + testNewestOffset - 1) / 2 // Just an offset in the middle
    34  
    35  	// Amount of time to wait for block processing when doing time-based tests
    36  	// We generally want this value to be as small as possible so as to make tests execute faster
    37  	// But this may have to be bumped up in slower machines
    38  	testTimePadding = 200 * time.Millisecond
    39  )
    40  
    41  var testGenesisConf = &genesisconfig.TopLevel{
    42  	Orderer: &genesisconfig.Orderer{
    43  		Kafka: genesisconfig.Kafka{
    44  			Brokers: []string{"127.0.0.1:9092"},
    45  		},
    46  	},
    47  }
    48  
    49  var testConf = &config.TopLevel{
    50  	Kafka: config.Kafka{
    51  		Retry: config.Retry{
    52  			Period: 3 * time.Second,
    53  			Stop:   60 * time.Second,
    54  		},
    55  		Verbose: false,
    56  		Version: sarama.V0_9_0_1,
    57  	},
    58  }
    59  
    60  func testClose(t *testing.T, x Closeable) {
    61  	if err := x.Close(); err != nil {
    62  		t.Fatal("Cannot close mock resource:", err)
    63  	}
    64  }
    65  
    66  func newTestEnvelope(content string) *cb.Envelope {
    67  	return &cb.Envelope{Payload: []byte(content)}
    68  }