Skip to content

Commit

Permalink
[FAB-2908] Enable behave tests on macOS
Browse files Browse the repository at this point in the history
- rely on published ports instead of direct access
  to the container network.
- speed up the startup of the couchdb containers

Change-Id: If49d08ab1356379e4ebb4e63f10e6d4957970e65
Signed-off-by: Luis Sanchez <sanchezl@us.ibm.com>
  • Loading branch information
Luis Sanchez committed Mar 29, 2017
1 parent e75e4ef commit b45abc4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
8 changes: 4 additions & 4 deletions bddtests/docker-compose-next-4-couchdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
couchdb0:
image: hyperledger/fabric-couchdb
ports:
- "5984:5984"
- '5984'

peer0:
environment:
Expand All @@ -17,7 +17,7 @@ services:
couchdb1:
image: hyperledger/fabric-couchdb
ports:
- "6984:5984"
- '5984'

peer1:
environment:
Expand All @@ -29,7 +29,7 @@ services:
couchdb2:
image: hyperledger/fabric-couchdb
ports:
- "7984:5984"
- '5984'

peer2:
environment:
Expand All @@ -41,7 +41,7 @@ services:
couchdb3:
image: hyperledger/fabric-couchdb
ports:
- "8984:5984"
- '5984'

peer3:
environment:
Expand Down
4 changes: 3 additions & 1 deletion bddtests/docker-compose-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ services:
- CORE_PEER_ENDORSER_ENABLED=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_GOSSIP_USELEADERELECTION=true

ports:
- '7051'
- '7053'
6 changes: 3 additions & 3 deletions bddtests/steps/endorser_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def createInvokeProposalForBDD(context, ccSpec, chainID, signersCert, Mspid, typ
nonce = bootstrap_util.BootstrapHelper.getNonce()

sigHdr = bootstrapHelper.makeSignatureHeader(serializedIdentity.SerializeToString(), nonce)

# Calculate the transaction ID
tx_id = binascii.hexlify(bootstrap_util.computeCryptoHash(nonce + serializedIdentity.SerializeToString()))

Expand Down Expand Up @@ -139,11 +139,11 @@ def getEndorserStubs(context, composeServices, directory, nodeAdminTuple):
signingOrg = directory.getOrganization(nodeAdminTuple.organization)

for composeService in composeServices:
ipAddress = bdd_test_util.ipFromContainerNamePart(composeService, context.compose_containers)
ipAddress, port = bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7051)
# natForPeerSigner = directory.findNodeAdminTuple(userName="{0}Signer".format(composeService), contextName=composeService, orgName="peerOrg0")
# signerCert = directory.getCertAsPEM(natForPeerSigner)
root_certificates = directory.getTrustedRootsForPeerNetworkAsPEM()
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=7051, root_certificates=root_certificates,
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=port, root_certificates=root_certificates,
ssl_target_name_override=composeService)
newEndorserStub = peer_pb2_grpc.EndorserStub(channel)
stubs.append(newEndorserStub)
Expand Down
8 changes: 3 additions & 5 deletions bddtests/steps/orderer_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,9 @@ def getABStubForComposeService(self, context, composeService):
return self.atomicBroadcastStubsDict[composeService]
# Get the IP address of the server that the user registered on
root_certificates = self.directory.getTrustedRootsForOrdererNetworkAsPEM()
# ipAddress = "{0}:{1}".format(*bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050))
ipAddress = bdd_test_util.ipFromContainerNamePart(composeService, context.compose_containers)
print("ipAddress in getABStubForComposeService == {0}".format(ipAddress))
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=7050, root_certificates=root_certificates, ssl_target_name_override=composeService)
# channel = getGRPCChannel(*bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050))
ipAddress, port = bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050)
print("ipAddress in getABStubForComposeService == {0}:{1}".format(ipAddress, port))
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=port, root_certificates=root_certificates, ssl_target_name_override=composeService)
newABStub = ab_pb2_grpc.AtomicBroadcastStub(channel)
self.atomicBroadcastStubsDict[composeService] = newABStub
return newABStub
Expand Down
5 changes: 4 additions & 1 deletion images/couchdb/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN set -x \
&& cp tini tini-static /usr/local/bin/ \
# Clean up su-exec and tini
&& rm -rf /tmp/tini \
&& rm -rf /tmp/su-exec
&& rm -rf /tmp/su-exec

ARG COUCHDB_VERSION=2.0.0

Expand Down Expand Up @@ -69,6 +69,9 @@ RUN chmod +x /docker-entrypoint.sh \

WORKDIR /opt/couchdb
EXPOSE 5984 4369 9100

USER couchdb

VOLUME ["/opt/couchdb/data"]

ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
Expand Down
10 changes: 0 additions & 10 deletions images/couchdb/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
set -e

if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
# we need to set the permissions here because docker mounts volumes as root
chown -R couchdb:couchdb /opt/couchdb

chmod -R 0770 /opt/couchdb/data

chmod 664 /opt/couchdb/etc/*.ini
chmod 664 /opt/couchdb/etc/local.d/*.ini
chmod 775 /opt/couchdb/etc/*.d

if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
Expand All @@ -30,7 +22,6 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
# Create admin
printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" > /opt/couchdb/etc/local.d/docker.ini
chown couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini
fi

# if we don't find an [admins] section followed by a non-comment, display a warning
Expand All @@ -51,7 +42,6 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
fi

sleep 1
exec su-exec couchdb "$@"
fi

exec "$@"
3 changes: 2 additions & 1 deletion images/couchdb/local.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
; overwritten on server upgrade.

[chttpd]
bind_address = any
bind_address = 0.0.0.0

0 comments on commit b45abc4

Please sign in to comment.