Skip to content

Commit fedc2ef

Browse files
jt-ntimbwhite
authored andcommitted
Improve integration test reliability
Order of tests can vary so it’s not safe to assume mychannel already exists Signed-off-by: James Taylor <[email protected]>
1 parent 6fd5507 commit fedc2ef

File tree

12 files changed

+83
-116
lines changed

12 files changed

+83
-116
lines changed

fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/Docker.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static public class DockerBuilder implements Cloneable {
2222
boolean exec;
2323
String container;
2424
String script;
25+
String channel;
2526

2627
public DockerBuilder duplicate() {
2728
try {
@@ -36,6 +37,11 @@ public DockerBuilder script(String script){
3637
this.script = script;
3738
return this;
3839
}
40+
41+
public DockerBuilder channel(String channel){
42+
this.channel = channel;
43+
return this;
44+
}
3945

4046
public DockerBuilder container(String container){
4147
this.container = container;
@@ -45,7 +51,8 @@ public DockerBuilder container(String container){
4551
public DockerBuilder exec(){
4652
this.exec = true;
4753
return this;
48-
}
54+
}
55+
4956
public Docker build(){
5057

5158
ArrayList<String> list = new ArrayList<>();
@@ -64,6 +71,11 @@ public Docker build(){
6471
throw new RuntimeException("script should be set");
6572
}
6673
list.add(script);
74+
75+
if (channel == null || channel.isEmpty()){
76+
throw new RuntimeException("channel should be set");
77+
}
78+
list.add(channel);
6779

6880

6981
return new Docker(list);

fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SACCIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void setUp() throws Exception {
3737
// the cli container contains a script that does the channel create, joing
3838
// and chaincode install/instantiate
3939
DockerBuilder dockerBuilder = new Docker.DockerBuilder();
40-
Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script.sh").build();
40+
Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script.sh").channel("sachannel").build();
4141
docker.run();
4242
}
4343

@@ -46,7 +46,7 @@ public void TestSACCChaincodeInstallInstantiateInvokeQuery() {
4646

4747
// Need to send a number of 'peer chaincode invoke' commands
4848
// Setup the core buider command and then duplicate per test
49-
PeerBuilder coreBuilder = Peer.newBuilder().ccname("javacc").channel("mychannel");
49+
PeerBuilder coreBuilder = Peer.newBuilder().ccname("javacc").channel("sachannel");
5050
Result r;
5151
String text;
5252

fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SBECCIntegrationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void setUp() throws Exception {
3232

3333
// Call the inbuilt script to install/instantiate
3434
DockerBuilder dockerBuilder = new Docker.DockerBuilder();
35-
Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script-sbe.sh").build();
35+
Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script.sh").channel("sbechannel").build();
3636
docker.run();
3737
}
3838

@@ -50,7 +50,7 @@ public void RunSBE_pub_setget() throws NoSuchAlgorithmException, InvalidKeySpecE
5050
String mode = "pub";
5151
// Need to send a number of 'peer chaincode invoke' commands
5252
// Setup the core buider command and then duplicate per test
53-
PeerBuilder coreBuilder = Peer.newBuilder().ccname("sbecc").channel("mychannel");
53+
PeerBuilder coreBuilder = Peer.newBuilder().ccname("sbecc").channel("sbechannel");
5454
Result r;
5555

5656
String text;
@@ -113,7 +113,7 @@ public void RunSBE_priv() throws NoSuchAlgorithmException, InvalidKeySpecExcepti
113113

114114
// Need to send a number of 'peer chaincode invoke' commands
115115
// Setup the core buider command and then duplicate per test
116-
PeerBuilder coreBuilder = Peer.newBuilder().ccname("sbecc").channel("mychannel");
116+
PeerBuilder coreBuilder = Peer.newBuilder().ccname("sbecc").channel("sbechannel");
117117
Result r;
118118
String text;
119119

fabric-chaincode-integration-test/src/test/resources/first-network/channel-artifacts/channel.tx renamed to fabric-chaincode-integration-test/src/test/resources/first-network/channel-artifacts/sachannel.tx

346 Bytes
Binary file not shown.

fabric-chaincode-integration-test/src/test/resources/first-network/channel-artifacts/Org1MSPanchors.tx renamed to fabric-chaincode-integration-test/src/test/resources/first-network/channel-artifacts/sachannelOrg1MSPanchors.tx

284 Bytes
Binary file not shown.

fabric-chaincode-integration-test/src/test/resources/first-network/channel-artifacts/Org2MSPanchors.tx renamed to fabric-chaincode-integration-test/src/test/resources/first-network/channel-artifacts/sachannelOrg2MSPanchors.tx

284 Bytes
Binary file not shown.
Binary file not shown.

fabric-chaincode-integration-test/src/test/resources/first-network/scripts/script-sbe.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)