Skip to content

Commit

Permalink
[FAB-1785] Cleanup kafka-orderer bdd environments
Browse files Browse the repository at this point in the history
Change-Id: Ic5a491f96c471380aab05c3aac3b3cec8be65e6a
Signed-off-by: Luis Sanchez <sanchezl@us.ibm.com>
  • Loading branch information
Luis Sanchez committed Jan 26, 2017
1 parent c9242fe commit 4491654
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ unit-tests: unit-test
docker: $(patsubst %,build/image/%/$(DUMMY), $(IMAGES))
native: peer orderer

BEHAVE_ENVIRONMENTS = kafka orderer-1-kafka-1 orderer-1-kafka-3
BEHAVE_ENVIRONMENTS = kafka orderer orderer-1-kafka-1 orderer-1-kafka-3
BEHAVE_ENVIRONMENT_TARGETS = $(patsubst %,bddtests/environments/%, $(BEHAVE_ENVIRONMENTS))
.PHONY: behave-environments $(BEHAVE_ENVIRONMENT_TARGETS)
behave-environments: $(BEHAVE_ENVIRONMENT_TARGETS)
Expand Down
2 changes: 1 addition & 1 deletion bddtests/environments/orderer-1-kafka-1/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: hyperledger/fabric-zookeeper

orderer0:
image: hyperledger/fabric-orderer
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=kafka
Expand Down
2 changes: 1 addition & 1 deletion bddtests/environments/orderer-1-kafka-3/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: hyperledger/fabric-zookeeper

orderer0:
image: hyperledger/fabric-orderer
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=kafka
Expand Down
2 changes: 1 addition & 1 deletion bddtests/environments/orderer-n-kafka-n/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: hyperledger/fabric-zookeeper

orderer:
build: ./orderer
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_QUEUESIZE=1000
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
Expand Down
17 changes: 0 additions & 17 deletions bddtests/environments/orderer-n-kafka-n/orderer/Dockerfile

This file was deleted.

This file was deleted.

8 changes: 8 additions & 0 deletions bddtests/environments/orderer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM hyperledger/fabric-testenv
WORKDIR /opt/gopath/src/github.com/hyperledger/fabric/orderer
RUN apt-get update \
&& apt-get install -y zookeeper jq \
&& rm -rf /var/lib/apt/lists/*
ADD docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["orderer"]
11 changes: 11 additions & 0 deletions bddtests/environments/orderer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '2'
services:
orderer:
build: .
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_QUEUESIZE=1000
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=solo
ports:
- '7050'
49 changes: 49 additions & 0 deletions bddtests/environments/orderer/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

# This script will either start the kafka server, or run the user
# specified command.

# Exit immediately if a pipeline returns a non-zero status.
set -e

ORDERER_EXE=orderer

# handle starting the orderer with an option
if [ "${1:0:1}" = '-' ]; then
set -- ${ORDERER_EXE} "$@"
fi

# handle default (i.e. no custom options or commands)
if [ "$1" = "${ORDERER_EXE}" ]; then

case "$ORDERER_GENESIS_ORDERERTYPE" in
solo)
;;
kafka)
# make sure at least one broker has started.
# get the broker list from zookeeper
if [ -z "$ORDERER_KAFKA_BROKERS" ] ; then
if [ -z "$ZOOKEEPER_CONNECT" ] ; then
export ZOOKEEPER_CONNECT="zookeeper:2181"
fi
ZK_CLI_EXE="/usr/share/zookeeper/bin/zkCli.sh -server ${ZOOKEEPER_CONNECT}"
until [ -n "$($ZK_CLI_EXE ls /brokers/ids | grep '^\[')" ] ; do
echo "No Kafka brokers registered in ZooKeeper. Will try again in 1 second."
sleep 1
done
ORDERER_KAFKA_BROKERS="["
ORDERER_KAFKA_BROKERS_SEP=""
for BROKER_ID in $($ZK_CLI_EXE ls /brokers/ids | grep '^\[' | sed 's/[][,]/ /g'); do
ORDERER_KAFKA_BROKERS=${ORDERER_KAFKA_BROKERS}${ORDERER_KAFKA_BROKERS_SEP}$($ZK_CLI_EXE get /brokers/ids/$BROKER_ID 2>&1 | grep '^{' | jq -j '. | .host,":",.port')
ORDERER_KAFKA_BROKERS_SEP=","
done
export ORDERER_KAFKA_BROKERS="${ORDERER_KAFKA_BROKERS}]"
fi
;;
sbft)
;;
esac

fi

exec "$@"
2 changes: 1 addition & 1 deletion common/localmsp/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
type mspSigner struct {
}

// New returns a new instance of the msp-based LocalSigner.
// NewSigner returns a new instance of the msp-based LocalSigner.
// It assumes that the local msp has been already initialized.
// Look at mspmgmt.LoadLocalMsp for further information.
func NewSigner() crypto.LocalSigner {
Expand Down
4 changes: 2 additions & 2 deletions common/localmsp/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import (
"testing"

"github.com/hyperledger/fabric/core/crypto/primitives"
"github.com/stretchr/testify/assert"
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
"github.com/stretchr/testify/assert"
)

func TestMain(m *testing.M) {
// 1. Determine MSP configuration
var mspMgrConfigDir string
var alternativeCfgPath = os.Getenv("ORDERER_CFG_PATH")
if alternativeCfgPath != "" {
mspMgrConfigDir = alternativeCfgPath + "/msp/sampleconfig/"
mspMgrConfigDir = alternativeCfgPath + "/../msp/sampleconfig/"
} else if _, err := os.Stat("./msp/sampleconfig/"); err == nil {
mspMgrConfigDir = "./msp/sampleconfig/"
} else {
Expand Down
2 changes: 1 addition & 1 deletion images/orderer/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM hyperledger/fabric-runtime:_TAG_
ENV ORDERER_CFG_PATH /etc/hyperledger/fabric/orderer
RUN mkdir -p /var/hyperledger/db /etc/hyperledger/fabric/orderer
RUN mkdir -p /var/hyperledger/production /etc/hyperledger/fabric/orderer
COPY payload/orderer /usr/local/bin
ADD payload/msp-sampleconfig.tar.bz2 $ORDERER_CFG_PATH/../
COPY payload/orderer.yaml $ORDERER_CFG_PATH/
Expand Down
2 changes: 1 addition & 1 deletion images/peer/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM hyperledger/fabric-runtime:_TAG_
ENV PEER_CFG_PATH /etc/hyperledger/fabric
RUN mkdir -p /var/hyperledger/db $PEER_CFG_PATH
RUN mkdir -p /var/hyperledger/production $PEER_CFG_PATH
COPY payload/peer /usr/local/bin
COPY payload/core.yaml $PEER_CFG_PATH
ADD payload/msp-sampleconfig.tar.bz2 $PEER_CFG_PATH
Expand Down
12 changes: 7 additions & 5 deletions images/testenv/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM hyperledger/fabric-baseimage:_BASE_TAG_

# fabric configuration file locations
RUN mkdir -p /etc/hyperledger/fabric
ENV ORDERER_CFG_PATH /etc/hyperledger/fabric
# fabric configuration locations
ENV PEER_CFG_PATH /etc/hyperledger/fabric
ENV ORDERER_CFG_PATH /etc/hyperledger/fabric/orderer

# ledger db location
RUN mkdir -p /var/hyperledger/db
# create needed directories
RUN mkdir -p \
$PEER_CFG_PATH \
$ORDERER_CFG_PATH \
/var/hyperledger/production

# install gotools
ADD payload/gotools.tar.bz2 /usr/local/bin/
Expand Down

0 comments on commit 4491654

Please sign in to comment.