Skip to content

Commit b45abc4

Browse files
author
Luis Sanchez
committed
[FAB-2908] Enable behave tests on macOS
- 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 <[email protected]>
1 parent e75e4ef commit b45abc4

7 files changed

+19
-25
lines changed

bddtests/docker-compose-next-4-couchdb.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
couchdb0:
66
image: hyperledger/fabric-couchdb
77
ports:
8-
- "5984:5984"
8+
- '5984'
99

1010
peer0:
1111
environment:
@@ -17,7 +17,7 @@ services:
1717
couchdb1:
1818
image: hyperledger/fabric-couchdb
1919
ports:
20-
- "6984:5984"
20+
- '5984'
2121

2222
peer1:
2323
environment:
@@ -29,7 +29,7 @@ services:
2929
couchdb2:
3030
image: hyperledger/fabric-couchdb
3131
ports:
32-
- "7984:5984"
32+
- '5984'
3333

3434
peer2:
3535
environment:
@@ -41,7 +41,7 @@ services:
4141
couchdb3:
4242
image: hyperledger/fabric-couchdb
4343
ports:
44-
- "8984:5984"
44+
- '5984'
4545

4646
peer3:
4747
environment:

bddtests/docker-compose-next.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ services:
1111
- CORE_PEER_ENDORSER_ENABLED=true
1212
- CORE_PEER_GOSSIP_ORGLEADER=false
1313
- CORE_PEER_GOSSIP_USELEADERELECTION=true
14-
14+
ports:
15+
- '7051'
16+
- '7053'

bddtests/steps/endorser_util.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def createInvokeProposalForBDD(context, ccSpec, chainID, signersCert, Mspid, typ
6767
nonce = bootstrap_util.BootstrapHelper.getNonce()
6868

6969
sigHdr = bootstrapHelper.makeSignatureHeader(serializedIdentity.SerializeToString(), nonce)
70-
70+
7171
# Calculate the transaction ID
7272
tx_id = binascii.hexlify(bootstrap_util.computeCryptoHash(nonce + serializedIdentity.SerializeToString()))
7373

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

141141
for composeService in composeServices:
142-
ipAddress = bdd_test_util.ipFromContainerNamePart(composeService, context.compose_containers)
142+
ipAddress, port = bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7051)
143143
# natForPeerSigner = directory.findNodeAdminTuple(userName="{0}Signer".format(composeService), contextName=composeService, orgName="peerOrg0")
144144
# signerCert = directory.getCertAsPEM(natForPeerSigner)
145145
root_certificates = directory.getTrustedRootsForPeerNetworkAsPEM()
146-
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=7051, root_certificates=root_certificates,
146+
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=port, root_certificates=root_certificates,
147147
ssl_target_name_override=composeService)
148148
newEndorserStub = peer_pb2_grpc.EndorserStub(channel)
149149
stubs.append(newEndorserStub)

bddtests/steps/orderer_util.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ def getABStubForComposeService(self, context, composeService):
199199
return self.atomicBroadcastStubsDict[composeService]
200200
# Get the IP address of the server that the user registered on
201201
root_certificates = self.directory.getTrustedRootsForOrdererNetworkAsPEM()
202-
# ipAddress = "{0}:{1}".format(*bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050))
203-
ipAddress = bdd_test_util.ipFromContainerNamePart(composeService, context.compose_containers)
204-
print("ipAddress in getABStubForComposeService == {0}".format(ipAddress))
205-
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=7050, root_certificates=root_certificates, ssl_target_name_override=composeService)
206-
# channel = getGRPCChannel(*bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050))
202+
ipAddress, port = bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050)
203+
print("ipAddress in getABStubForComposeService == {0}:{1}".format(ipAddress, port))
204+
channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=port, root_certificates=root_certificates, ssl_target_name_override=composeService)
207205
newABStub = ab_pb2_grpc.AtomicBroadcastStub(channel)
208206
self.atomicBroadcastStubsDict[composeService] = newABStub
209207
return newABStub

images/couchdb/Dockerfile.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN set -x \
3838
&& cp tini tini-static /usr/local/bin/ \
3939
# Clean up su-exec and tini
4040
&& rm -rf /tmp/tini \
41-
&& rm -rf /tmp/su-exec
41+
&& rm -rf /tmp/su-exec
4242

4343
ARG COUCHDB_VERSION=2.0.0
4444

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

7070
WORKDIR /opt/couchdb
7171
EXPOSE 5984 4369 9100
72+
73+
USER couchdb
74+
7275
VOLUME ["/opt/couchdb/data"]
7376

7477
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

images/couchdb/docker-entrypoint.sh

-10
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414
set -e
1515

1616
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
17-
# we need to set the permissions here because docker mounts volumes as root
18-
chown -R couchdb:couchdb /opt/couchdb
19-
20-
chmod -R 0770 /opt/couchdb/data
21-
22-
chmod 664 /opt/couchdb/etc/*.ini
23-
chmod 664 /opt/couchdb/etc/local.d/*.ini
24-
chmod 775 /opt/couchdb/etc/*.d
2517

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

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

5344
sleep 1
54-
exec su-exec couchdb "$@"
5545
fi
5646

5747
exec "$@"

images/couchdb/local.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
; overwritten on server upgrade.
66

77
[chttpd]
8-
bind_address = any
8+
bind_address = 0.0.0.0
9+

0 commit comments

Comments
 (0)