Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit 385539b

Browse files
author
Tong Li
committed
fixed the calling caliper container issue
Signed-off-by: Tong Li <litong01@us.ibm.com>
1 parent 1b394e0 commit 385539b

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

app/app.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module.exports.info = 'Template callback';
44

55
const contractID = 'samplecc';
6-
const version = '0.0.1';
6+
const version = '1.0';
77

88
let bc, ctx, clientArgs, clientIdx;
99

@@ -12,30 +12,16 @@ module.exports.init = async function(blockchain, context, args) {
1212
ctx = context;
1313
clientArgs = args;
1414
clientIdx = context.clientIdx.toString();
15-
for (let i=0; i<clientArgs.assets; i++) {
16-
try {
17-
const assetID = `${clientIdx}_${i}`;
18-
console.log(`Client ${clientIdx}: Creating asset ${assetID}`);
19-
const myArgs = {
20-
chaincodeFunction: 'createCar',
21-
invokerIdentity: 'Admin@org1.example.com',
22-
chaincodeArguments: [assetID,'blue','ford','fiesta','Jamie']
23-
};
24-
await bc.bcObj.invokeSmartContract(ctx, contractID, version, myArgs);
25-
} catch (error) {
26-
console.log(`Client ${clientIdx}: Smart Contract threw with error: ${error}` );
27-
}
28-
}
2915
};
3016

3117
module.exports.run = function() {
3218
const randomId = Math.floor(Math.random()*clientArgs.assets);
3319
const myArgs = {
34-
chaincodeFunction: 'queryCar',
35-
invokerIdentity: 'Admin@org1.example.com',
36-
chaincodeArguments: [`${clientIdx}_${randomId}`]
20+
chaincodeFunction: 'invoke',
21+
invokerIdentity: 'Admin@org0.example.com',
22+
chaincodeArguments: ['put', `${clientIdx}_${randomId}`, `${clientIdx}_${randomId}`]
3723
};
38-
return bc.bcObj.querySmartContract(ctx, contractID, version, myArgs);
24+
return bc.bcObj.invokeSmartContract(ctx, contractID, version, myArgs);
3925
};
4026

4127
module.exports.end = async function() {

playbooks/ops/caliperrun/apply.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,16 @@
44
src: "{{ pjroot }}/playbooks/ops/caliperrun/templates/{{ item.name }}"
55
dest: "{{ pjroot }}/vars/run/{{ item.target }}"
66
with_items:
7-
- {name: 'networkconfig.j2', target: 'networkconfig.json'}
8-
- {name: 'benchmarkconfig.j2', target: 'benchmarkconfig.yaml'}
7+
- {name: 'networkconfig.j2', target: 'calipernetworkconfig.json'}
8+
- {name: 'benchmarkconfig.j2', target: 'caliperbenchmarkconfig.yaml'}
9+
10+
- name: Launch caliper test
11+
command: >-
12+
docker run --network {{ NETNAME }} --name calipertester --hostname calipertester
13+
-e "ROOTPATH=/vars/keyfiles"
14+
-v /var/run/docker.sock:/var/run/docker.sock
15+
-v {{ hostroot }}/vars:/vars
16+
hyperledger/caliper:0.3.2
17+
"launch master --caliper-benchconfig /vars/run/caliperbenchmarkconfig.yaml
18+
--caliper-networkconfig /vars/run/calipernetworkconfig.json
19+
--caliper-flow-only-test --caliper-fabric-gateway-usegateway --caliper-fabric-gateway-discovery"

playbooks/ops/caliperrun/templates/benchmarkconfig.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test:
1313
type: fixed-backlog
1414
opts:
1515
unfinished_per_client: 2
16-
callback: benchmarks/callbacks/queryAssetBenchmarks.js
16+
callback: /vars/app/app.js
1717
arguments:
1818
assets: 10
1919

0 commit comments

Comments
 (0)