Skip to content

Commit

Permalink
impl to support minifab (#89)
Browse files Browse the repository at this point in the history
* impl

Signed-off-by: SamYuan1990 <yy19902439@126.com>
  • Loading branch information
SamYuan1990 authored Feb 27, 2021
1 parent 5f72599 commit 5a6da3c
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 16 deletions.
35 changes: 30 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
npm test
displayName: 'npm ci'
- job: e2e
displayName: e2eSample
- job: e2eTestNetwork
displayName: e2eTestNetworkSample
dependsOn:
- ut
pool:
Expand All @@ -57,18 +57,43 @@ jobs:
displayName: downloadFabricSample
- script: docker pull guoger/tape
displayName: downloadTape
- script: cp sample/prepareConfig.sh fabric-samples/test-network
- script: cp sample/test-network/prepareConfig.sh fabric-samples/test-network
displayName: cpPrepareConfig
- script: npm run e2e
- script: cp sample/test-network/config.yaml .
displayName: cpconfig.yaml
- script: npm run e2eTestNetwork
displayName: startEnd2EndTest
- script: cat ./data/rs.csv
displayName: checkResult
- script: cat logger.log
displayName: checkLog

# - job: e2eMiniFab
# displayName: e2eMiniFabSample
# dependsOn:
# - ut
# pool:
# vmImage: 'ubuntu-latest'
# steps:
# - script: npm install
# displayName: npmInstall
# - script: docker pull guoger/tape
# displayName: downloadTape
# - script: mkdir -p minifabric && cd minifabric && curl -o minifab -sL https://tinyurl.com/yxa2q6yr && chmod +x minifab && cd ..
# displayName: download downloadMiniFab
# - script: cp sample/minifab/* minifabric
# displayName: cpPrepareConfig
# - script: npm run e2eMiniFab
# displayName: startEnd2EndTest
# - script: cat ./data/rs.csv
# displayName: checkResult
# - script: cat logger.log
# displayName: checkLog

- job: releasePage
dependsOn:
- e2e
- e2eTestNetwork
# - e2eMiniFab
steps:
- task: GitHubRelease@1
inputs:
Expand Down
4 changes: 1 addition & 3 deletions data/rs.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Chaincode,BatchTimeout,MaxMessageCount,AbsoluteMaxBytes,PreferredMaxBytes,TPS,
sample,1,10,3,4, 122.308717,
sample,2,10,3,4, 123.720466,
Chaincode,BatchTimeout,MaxMessageCount,AbsoluteMaxBytes,PreferredMaxBytes,TPS,
31 changes: 31 additions & 0 deletions e2e/minifab.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const app = require('../app');
const request = require('supertest')(app);

describe('# test app.js', function () {
it('Post /api/run/new 200', function (done) {
request.post('/api/run/new').set('Content-Type', 'application/x-www-form-urlencoded').send(
{
BatchTimeout: '1',
MaxMessageCount: '10,20',
AbsoluteMaxBytes: '103809024',
PreferredMaxBytes: '524288',
path: './minifabric',
cmd: `[
{"order":0,"cmdType":"Shell","args":["./minifab","up","-i","2.2"]},
{"order":1,"cmdType":"Shell","args":["./minifab","channelquery","-c","systemchannel"]},
{"order":2,"cmdType":"Shell","args":["cp","vars/systemchannel_config.json","updatedchannel.json"]},
{"order":3,"cmdType":"PrePare","args":["./prepareConfig.sh"]},
{"order":4,"cmdType":"Shell","args":["cp","updatedchannel.json","vars/systemchannel_config.json"]},
{"order":5,"cmdType":"Shell","args":["./minifab","channelsign,channelupdate","-c","systemchannel"]},
{"order":6,"cmdType":"Shell","args":["mkdir","-p","/tmp/minifab"]},
{"order":7,"cmdType":"Shell","args":["cp","config.yaml","/tmp/minifab"]},
{"order":8,"cmdType":"Shell","args":["cp","-r","./vars","/tmp/minifab"]},
{"order":9,"cmdType":"Tape","args":["docker","run","--name","tape","-e","TAPE_LOGLEVEL=debug","--network","mysite0","-v","/tmp/minifab:/config","guoger/tape","tape","-c","/config/config.yaml","-n","500"]},
{"order":10,"cmdType":"Shell","args":["docker","rm","tape"]},
{"order":11,"cmdType":"Shell","args":["rm","-rf","/tmp/minifab"]},
{"order":12,"cmdType":"Shell","args":["sleep","10"]},
{"order":13,"cmdType":"Shell","args":["./minifab","down"]},
{"order":14,"cmdType":"Shell","args":["./minifab","cleanup"]}]`
}).expect(200, done);
});
});
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"lint": "eslint --ext .js ./lib ./routes ./test ./e2e",
"test": "export NODE_ENV=test PORT=3300 && nyc mocha 'test/**/*.test.js' --timeout 5000 --exit",
"cover:report": "nyc report --reporter=lcov --reporter=text",
"e2e": "export NODE_ENV=test PORT=3000 && mocha 'e2e/**/*.test.js' --timeout 600000 --exit",
"e2eTestNetwork": "export NODE_ENV=test PORT=3000 && mocha 'e2e/testnetwork.test.js' --timeout 600000 --exit",
"e2eMiniFab": "export NODE_ENV=test PORT=3000 && mocha 'e2e/minifab.test.js' --timeout 600000 --exit",
"build": "webpack"
},
"repository": {
Expand Down
14 changes: 7 additions & 7 deletions public/javascripts/newUI/bundle.js

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions sample/minifab/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Definition of nodes
peer1: &peer1
addr: peer1.org0.example.com:7051
tls_ca_cert: /config/vars/keyfiles/peerOrganizations/org0.example.com/msp/tlscacerts/tlsca.org0.example.com-cert.pem

peer2: &peer2
addr: peer1.org1.example.com:7051
tls_ca_cert: /config/vars/keyfiles/peerOrganizations/org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem

orderer1: &orderer1
addr: orderer1.example.com:7050
tls_ca_cert: /config/vars/keyfiles/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem

# Nodes to interact with
endorsers:
- *peer1
- *peer2
# we might support multi-committer in the future for more complex test scenario,
# i.e. consider tx committed only if it's done on >50% of nodes. But for now,
# it seems sufficient to support single committer.
committers:
- *peer2

commitThreshold: 1

orderer: *orderer1

# Invocation configs
channel: mychannel
chaincode: simple
args:
- query
- a
mspid: org0-example-com

private_key: /config/vars/keyfiles/peerOrganizations/org0.example.com/users/Admin@org0.example.com/msp/keystore/priv_sk
sign_cert: /config/vars/keyfiles/peerOrganizations/org0.example.com/users/Admin@org0.example.com/msp/signcerts/Admin@org0.example.com-cert.pem
num_of_conn: 10
client_per_conn: 10
6 changes: 6 additions & 0 deletions sample/minifab/prepareConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sed -i -e "s/ \"timeout\": \".*s\"/ \"timeout\": \"$1s\"/g" updatedchannel.json
sed -i -e "s/ \"max_message_count\": .*,/ \"max_message_count\": $2,/g" updatedchannel.json
sed -i -e "s/ \"absolute_max_bytes\": .*,/ \"absolute_max_bytes\": $3,/g" updatedchannel.json
sed -i -e "s/ \"preferred_max_bytes\": .*/ \"preferred_max_bytes\": $4/g" updatedchannel.json
37 changes: 37 additions & 0 deletions sample/test-network/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Definition of nodes
peer1: &peer1
addr: peer0.org1.example.com:7051
tls_ca_cert: /config/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem

peer2: &peer2
addr: peer0.org2.example.com:9051
tls_ca_cert: /config/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem

orderer1: &orderer1
addr: orderer.example.com:7050
tls_ca_cert: /config/fabric-samples/test-network/organizations/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem

# Nodes to interact with
endorsers:
- *peer1
- *peer2
# we might support multi-committer in the future for more complex test scenario,
# i.e. consider tx committed only if it's done on >50% of nodes. But for now,
# it seems sufficient to support single committer.
committers:
- *peer2

commitThreshold: 1

orderer: *orderer1

# Invocation configs
channel: mychannel
chaincode: basic
args:
- GetAllAssets
mspid: Org1MSP
private_key: /config/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk
sign_cert: /config/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem
num_of_conn: 40
client_per_conn: 40
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/newUI/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function render(){
typeTape={() => store.dispatch({ type: 'TYPE_TAPE' })}
ApplyTestNetwork = {() => store.dispatch({ type: 'TEST_NET_SAMPLE' })}
ApplyTestNetworkWithMonitor = {() => store.dispatch({ type: 'TEST_NET_MONITOR_SAMPLE' })}
ApplyTestNetworkMinifab = {() => store.dispatch({ type: 'TEST_NET_MINIFAB' })}
dispatch = {store.dispatch}
/>
,rootEl);
Expand Down
1 change: 1 addition & 0 deletions src/newUI/components/MyList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default class MyList extends React.Component {
<Card.Body>
<Button variant="info" onClick={this.props.ApplyTestNetwork}>TestNetwork Sample</Button>
<Button variant="info" onClick={this.props.ApplyTestNetworkWithMonitor}>TestNetwork With Monitor Sample</Button>
<Button variant="info" onClick={this.props.ApplyTestNetworkMinifab}>TestNetwork Minifab</Button>
<ListGroup variant="flush">
<ListGroup>Path <input type="text" onChange={this.changePath} placeholder={this.props.todos.todos.path}/> </ListGroup>
<ListGroup>BatchTimeout List <input type="text" onChange={this.changeBatchTimeout} placeholder={this.props.todos.todos.BatchTimeout}/> </ListGroup>
Expand Down
40 changes: 40 additions & 0 deletions src/newUI/reducers/todos.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
const todos = (state = {path:'./fabric-samples/test-network', BatchTimeout:'1', MaxMessageCount:'10', AbsoluteMaxBytes:'2', PreferredMaxBytes:'512', cmd:[{order:0, cmdType: 'Shell', args:['']}]}, action) => {
switch (action.type) {
case 'TEST_NET_MINIFAB':
state = {
path:'./minifabric',
BatchTimeout:'1',
MaxMessageCount:'10,20',
AbsoluteMaxBytes:'103809024',
PreferredMaxBytes:'524288',
cmd:[
{order:0, cmdType: 'Shell', args:['./minifab', 'up', '-i', '2.2']},
{order:1, cmdType: 'Shell', args:['./minifab', 'channelquery', '-c', 'systemchannel']},
{order:2, cmdType: 'Shell', args:['cp', 'vars/systemchannel_config.json', 'updatedchannel.json']},
{order:3, cmdType: 'PrePare', args:['./prepareConfig.sh']},
{order:4, cmdType: 'Shell', args:['cp', 'updatedchannel.json', 'vars/systemchannel_config.json']},
{order:5, cmdType: 'Shell', args:['./minifab', 'channelsign,channelupdate', '-c', 'systemchannel']},
{order:6, cmdType: 'Shell', args:['mkdir', '-p', '/tmp/minifab']},
{order:7, cmdType: 'Shell', args:['cp', 'config.yaml', '/tmp/minifab']},
{order:8, cmdType: 'Shell', args:['cp', '-r', './vars', '/tmp/minifab']},
{order:9, cmdType: 'Tape', args:['docker',
'run',
'--name',
'tape',
'-e',
'TAPE_LOGLEVEL=debug',
'--network',
'mysite0',
'-v',
'/tmp/minifab:/config',
'guoger/tape',
'tape',
'-c',
'/config/config.yaml',
'-n',
'500']},
{order:10, cmdType: 'Shell', args:['docker', 'rm', 'tape']},
{order:11, cmdType: 'Shell', args:['rm', '-rf', '/tmp/minifab']},
{order:12, cmdType: 'Shell', args:['sleep', '10']},
{order:13, cmdType: 'Shell', args:['./minifab', 'down']},
{order:14, cmdType: 'Shell', args:['./minifab', 'cleanup']},
]};
return state;
case 'TEST_NET_SAMPLE':
state = {
path:'./fabric-samples/test-network',
Expand Down

0 comments on commit 5a6da3c

Please sign in to comment.