Skip to content

Commit c0e8000

Browse files
committed
Int. test to use ccenv-1.4 image to build cc
With the removal of the shim from ccenv-2.0, chaincode packaged for previous releases can't be built by a 2.0 peer using ccenv-2.0. This CR adds a test to ensure that a 2.0 peer can be configured to use ccenv-1.4 as the builder image. FAB-16721 #done Change-Id: I335f78aeacf08ce0145803173ee392c5323ce7b8 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent bc3948a commit c0e8000

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,16 @@ unit-test: unit-test-clean docker-thirdparty ccenv-docker baseos-docker
148148
unit-tests: unit-test
149149

150150
# Pull thirdparty docker images based on the latest baseimage release version
151+
# Also pull ccenv-1.4 for compatibility test to ensure pre-2.0 installed chaincodes
152+
# can be built by a peer configured to use the ccenv-1.4 as the builder image.
151153
.PHONY: docker-thirdparty
152154
docker-thirdparty:
153155
docker pull couchdb:${COUCHDB_VER}
154156
docker pull $(BASE_DOCKER_NS)/fabric-zookeeper:$(BASE_DOCKER_TAG)
155157
docker tag $(BASE_DOCKER_NS)/fabric-zookeeper:$(BASE_DOCKER_TAG) $(DOCKER_NS)/fabric-zookeeper
156158
docker pull $(BASE_DOCKER_NS)/fabric-kafka:$(BASE_DOCKER_TAG)
157159
docker tag $(BASE_DOCKER_NS)/fabric-kafka:$(BASE_DOCKER_TAG) $(DOCKER_NS)/fabric-kafka
160+
docker pull hyperledger/fabric-ccenv:1.4
158161

159162
.PHONY: verify
160163
verify: export JOB_TYPE=VERIFY

integration/lifecycle/interop_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,4 +802,60 @@ var _ = Describe("Release interoperability", func() {
802802
})
803803
})
804804
})
805+
806+
Describe("solo network using ccenv-1.4", func() {
807+
var network *nwo.Network
808+
var process ifrit.Process
809+
810+
BeforeEach(func() {
811+
network = nwo.New(nwo.BasicSolo(), testDir, client, StartPort(), components)
812+
813+
// Generate config and bootstrap the network
814+
network.GenerateConfigTree()
815+
816+
for _, peer := range network.PeersWithChannel("testchannel") {
817+
core := network.ReadPeerConfig(peer)
818+
core.Chaincode.Builder = "$(DOCKER_NS)/fabric-ccenv:1.4"
819+
network.WritePeerConfig(peer, core)
820+
}
821+
822+
network.Bootstrap()
823+
824+
// Start all of the fabric processes
825+
networkRunner := network.NetworkGroupRunner()
826+
process = ifrit.Invoke(networkRunner)
827+
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
828+
})
829+
830+
AfterEach(func() {
831+
// Shutdown processes and cleanup
832+
process.Signal(syscall.SIGTERM)
833+
Eventually(process.Wait(), network.EventuallyTimeout).Should(Receive())
834+
network.Cleanup()
835+
})
836+
837+
It("deploys and executes chaincode (simple)", func() {
838+
By("deploying the chaincode using LSCC on a channel with V1_4 application capabilities")
839+
orderer := network.Orderer("orderer")
840+
peer := network.Peer("Org1", "peer1")
841+
842+
cwd, err := os.Getwd()
843+
Expect(err).NotTo(HaveOccurred())
844+
845+
// this chaincode was packaged using the v1.4.3 fabric-tools
846+
// (image id: 18ed4db0cd57) and peer (image id: fa87ccaed0ef)
847+
// images. It was packaged with name "mycc" and version "0.0".
848+
chaincode := nwo.Chaincode{
849+
Name: "mycc",
850+
Version: "0.0",
851+
PackageFile: filepath.Join(cwd, "testdata/mycc-0_0-v14.cds"),
852+
Ctor: `{"Args":["init","a","100","b","200"]}`,
853+
Policy: `AND ('Org1MSP.member','Org2MSP.member')`,
854+
}
855+
856+
network.CreateAndJoinChannels(orderer)
857+
nwo.DeployChaincodeLegacy(network, "testchannel", orderer, chaincode)
858+
RunQueryInvokeQuery(network, orderer, peer, "mycc", 100)
859+
})
860+
})
805861
})
Binary file not shown.

integration/nwo/deploy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ func DeployChaincodeLegacy(n *Network, channel string, orderer *Orderer, chainco
107107
chaincode.PackageFile = tempFile.Name()
108108
}
109109

110-
// package using the first peer
111-
PackageChaincodeLegacy(n, chaincode, peers[0])
110+
// only create chaincode package if it doesn't already exist
111+
if fi, err := os.Stat(chaincode.PackageFile); os.IsNotExist(err) || fi.Size() == 0 {
112+
PackageChaincodeLegacy(n, chaincode, peers[0])
113+
}
112114

113115
// install on all peers
114116
InstallChaincodeLegacy(n, chaincode, peers...)

0 commit comments

Comments
 (0)