Skip to content

Commit

Permalink
FABJ-486
Browse files Browse the repository at this point in the history
Add yaml config for azure pipelines
fix service discovery integration test to work without changes to /etc/hosts

Change-Id: Ib6003511949d5e956cb246e8dfd2139a9e849780
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
  • Loading branch information
andrew-coleman committed Oct 18, 2019
1 parent 923cc16 commit d0a66e5
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 9 deletions.
34 changes: 34 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
vmImage: 'ubuntu-latest'

jobs:
- job: test
steps:
- script: |
set -eo pipefail
export ORG_HYPERLEDGER_FABRIC_SDKTEST_FIXVERSION=2.0
export ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION=2.0.0
export IMAGE_TAG_FABRIC=2.0
export IMAGE_TAG_FABRIC_CA=2.0
########################
# Pull nodenev image from nexus and re-tag to hyperledger/fabric-nodeenv
#######################
docker pull nexus3.hyperledger.org:10001/hyperledger/fabric-nodeenv:amd64-2.0.0-stable
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-nodeenv:amd64-2.0.0-stable hyperledger/fabric-nodeenv:amd64-latest
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-nodeenv:amd64-2.0.0-stable hyperledger/fabric-nodeenv
docker pull nexus3.hyperledger.org:10001/hyperledger/fabric-javaenv:amd64-2.0.0-stable
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-javaenv:amd64-2.0.0-stable hyperledger/fabric-javaenv:amd64-latest
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-javaenv:amd64-2.0.0-stable hyperledger/fabric-javaenv
##########
docker images | grep hyperledger/fabric-nodeenv || true
source ./src/test/fabric_test_commitlevel.sh
./src/test/pull_images.sh
WD=$PWD GOPATH=$PWD/src/test/fixture ./src/test/cirun.sh
10 changes: 7 additions & 3 deletions src/test/cirun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ set -eo pipefail
export ORG_HYPERLEDGER_FABRIC_SDKTEST_INTEGRATIONTESTS_TLS=true
export ORG_HYPERLEDGER_FABRIC_SDKTEST_INTEGRATIONTESTS_CA_TLS=--tls.enabled
export ORG_HYPERLEDGER_FABRIC_SDKTEST_INTEGRATIONTESTS_CLIENT_AUTH_REQUIRED=true
export ORG_HYPERLEDGER_FABRIC_SDK_TEST_FABRIC_HOST=localhost

export ORG_HYPERLEDGER_FABRIC_SDK_LOGLEVEL=TRACE
export ORG_HYPERLEDGER_FABRIC_CA_SDK_LOGLEVEL=TRACE
export ORG_HYPERLEDGER_FABRIC_SDK_LOG_EXTRALOGLEVEL=10

#export ORG_HYPERLEDGER_FABRIC_SDK_PROPOSAL_WAIT_TIME=55000
export ORG_HYPERLEDGER_FABRIC_SDK_CHANNELCONFIG_WAIT_TIME=20000
export ORG_HYPERLEDGER_FABRIC_SDK_PROPOSAL_WAIT_TIME=180000
export ORG_HYPERLEDGER_FABRIC_SDK_CHANNELCONFIG_WAIT_TIME=60000
export ORG_HYPERLEDGER_FABRIC_SDK_CLIENT_TRANSACTION_CLEANUP_UP_TIMEOUT_WAIT_TIME=65000
export ORG_HYPERLEDGER_FABRIC_SDK_ORDERER_ORDERERWAITTIMEMILLISECS=180000
export ORG_HYPERLEDGER_FABRIC_SDK_PEER_EVENTREGISTRATION_WAIT_TIME=180000
export ORG_HYPERLEDGER_FABRIC_SDK_CHANNEL_GENESISBLOCK_WAIT_TIME=180000

export ORG_HYPERLEDGER_FABRIC_SDK_SERVICE_DISCOVERY_AS_LOCALHOST=true

# TEST TIMES
export ORG_HYPERLEDGER_FABRIC_SDKTEST_INVOKEWAITTIME=300000
export ORG_HYPERLEDGER_FABRIC_SDKTEST_DEPLOYWAITTIME=1300000
export ORG_HYPERLEDGER_FABRIC_SDKTEST_PROPOSALWAITTIME=300000

export ORG_HYPERLEDGER_FABRIC_SDKTEST_RUNIDEMIXMTTEST=true
# IdeMixTest disabled in Azure Pipelines - it takes too long to run (>2 hours!)
export ORG_HYPERLEDGER_FABRIC_SDKTEST_RUNIDEMIXMTTEST=false
export ORG_HYPERLEDGER_FABRIC_SDKTEST_RUNSERVICEDISCOVERYIT=true
echo '----- etc/hosts -------'
cat /etc/hosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void setup() throws Exception {

//Create initial discovery peer.

Peer discoveryPeer = client.newPeer("peer0.org1.example.com", protocol + "//peer0.org1.example.com:7051", properties);
Peer discoveryPeer = client.newPeer("peer0.org1.example.com", protocol + "//localhost:7051", properties);
Channel foo = client.newChannel("foo"); //create channel that will be discovered.

foo.addPeer(discoveryPeer, createPeerOptions().setPeerRoles(EnumSet.of(PeerRole.SERVICE_DISCOVERY, PeerRole.LEDGER_QUERY, PeerRole.EVENT_SOURCE, PeerRole.CHAINCODE_QUERY)));
Expand Down Expand Up @@ -141,8 +141,8 @@ public Orderer addOrderer(Channel.SDOrdererAdditionInfo sdOrdererAdditionInfo) t
final Collection<Peer> org1MSPPeers = foo.getPeersForOrganization("Org1MSP");
assertNotNull(org1MSPPeers);
assertEquals(2, org1MSPPeers.size());
Set<String> expectpeerURL = new HashSet<>(Arrays.asList(protocol + "//peer0.org1.example.com:7051",
protocol + "//peer1.org1.example.com:7056")); //discovered orderer
Set<String> expectpeerURL = new HashSet<>(Arrays.asList(protocol + "//localhost:7051",
protocol + "//localhost:7056")); //discovered orderer
org1MSPPeers.forEach(peer -> {
assertTrue(format("Missing peer %s", peer), expectpeerURL.contains(peer.getUrl()));
});
Expand All @@ -155,12 +155,12 @@ public Orderer addOrderer(Channel.SDOrdererAdditionInfo sdOrdererAdditionInfo) t
final Collection<Orderer> org1MSPOrderers = foo.getOrderersForOrganization("OrdererMSP");
assertNotNull(org1MSPOrderers);
assertEquals(1, org1MSPOrderers.size());
Set<String> expectordererURL = new HashSet<>(Arrays.asList(protocol + "//orderer.example.com:7050")); //discovered orderer
Set<String> expectordererURL = new HashSet<>(Arrays.asList(protocol + "//localhost:7050")); //discovered orderer
org1MSPOrderers.forEach(orderer -> {
assertTrue(format("Missing orderer %s", orderer), expectordererURL.contains(orderer.getUrl()));
});

Set<String> expect = new HashSet<>(Arrays.asList(protocol + "//orderer.example.com:7050")); //discovered orderer
Set<String> expect = new HashSet<>(Arrays.asList(protocol + "//localhost:7050")); //discovered orderer
for (Orderer orderer : foo.getOrderers()) {
expect.remove(orderer.getUrl());
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public Orderer addOrderer(Channel.SDOrdererAdditionInfo sdOrdererAdditionInfo) t
assertEquals(transactionPropResp.size(), 1);
final ProposalResponse proposalResponse = transactionPropResp.iterator().next();
final Peer peer = proposalResponse.getPeer();
assertEquals(protocol + "//peer1.org1.example.com:7056", peer.getUrl()); // not our discovery peer but the discovered one.
assertEquals(protocol + "//localhost:7056", peer.getUrl()); // not our discovery peer but the discovered one.

String expectedTransactionId = null;

Expand Down
60 changes: 60 additions & 0 deletions src/test/pull_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash -e
set -o pipefail

echo "======== PULL DOCKER IMAGES ========"

##########################################################
# Pull and Tag the fabric and fabric-ca images from Nexus
##########################################################
echo "Fetching images from Nexus"
NEXUS_URL=nexus3.hyperledger.org:10001
ORG_NAME="hyperledger/fabric"

VERSION=2.0.0
ARCH="amd64"
: ${STABLE_VERSION:=$VERSION-stable}
STABLE_TAG=$ARCH-$STABLE_VERSION
MASTER_TAG=$ARCH-master

echo "---------> STABLE_VERSION:" $STABLE_VERSION

dockerTag() {
for IMAGES in peer orderer ca ca orderer baseos ccenv javaenv nodeenv tools; do
echo "Images: $IMAGES"
echo
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
if [ $? != 0 ]; then
echo "FAILED: Docker Pull Failed on $IMAGES"
exit 1
fi
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES:$MASTER_TAG
echo "$ORG_NAME-$IMAGES:$MASTER_TAG"
echo "Deleting Nexus docker images: $IMAGES"
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
done
}

dockerTag2() {
for IMAGES in baseos ccenv javaenv nodeenv; do
echo "Images: $IMAGES"
echo
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
if [ $? != 0 ]; then
echo "FAILED: Docker Pull Failed on $IMAGES"
exit 1
fi
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES:$VERSION
echo "$ORG_NAME-$IMAGES:$VERSION"
echo "Deleting Nexus docker images: $IMAGES"
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
done
}

dockerTag
dockerTag2

echo
docker images | grep "hyperledger*"
echo

0 comments on commit d0a66e5

Please sign in to comment.