-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathprep.sh
executable file
·160 lines (133 loc) · 5.22 KB
/
prep.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# Colors
GREEN='\033[1;32m'
PURPLE='\033[0;35m'
RED='\033[0;31m'
NC='\033[0m' # No Color
BASE_PATH=~/ffperf-testing
FF_CLI=ff
# Verify three arguments were given
if [ $# -ne 3 ]; then
printf "${RED}Must provide exactly three arguments: \n1. Old stack name to remove \n2. New stack name to create \n3. Stack's blockchain type (ex. geth, besu, fabric, corda) \nex: ./prep.sh old_stack new_stack geth${NC}\n"
exit 1
fi
OLD_STACK_NAME=$1
NEW_STACK_NAME=$2
BLOCKCHAIN_PROVIDER=$3
# Kill existing ffperf processes
printf "${PURPLE}Killing ffperf processes...\n${NC}"
pkill -f 'ffperf'
rm $BASE_PATH/ffperf.log
# Install local ffperf-cli
printf "${PURPLE}Installing local ffperf CLI...\n${NC}"
cd $BASE_PATH/firefly-perf-cli
make install
# Build firefly image
printf "${PURPLE}Building FireFly Image...\n${NC}"
cd $BASE_PATH/firefly
make docker
cd $BASE_PATH
# Remove old Firefly stack
printf "${PURPLE}Removing FireFly Stack: $OLD_STACK_NAME...\n${NC}"
${FF_CLI} remove -f $OLD_STACK_NAME
# Create new Firefly stack
printf "${PURPLE}Creating FireFly Stack: $NEW_STACK_NAME...\n${NC}"
${FF_CLI} init $NEW_STACK_NAME 2 --manifest $BASE_PATH/firefly/manifest.json -t erc20_erc721 -c evmconnect -d postgres -b $BLOCKCHAIN_PROVIDER --prometheus-enabled --block-period 1 --connector-config ethconnect.yml --core-config core-config.yml
cat <<EOF > ~/.firefly/stacks/$NEW_STACK_NAME/docker-compose.override.yml
version: "2.1"
services:
firefly_core_0:
logging:
options:
max-file: "250"
max-size: "500m"
firefly_core_1:
logging:
options:
max-file: "250"
max-size: "500m"
evmconnect_0:
logging:
options:
max-file: "250"
max-size: "500m"
evmconnect_1:
logging:
options:
max-file: "250"
max-size: "500m"
postgres_0:
command: postgres -c log_min_duration_statement=500
postgres_1:
command: postgres -c log_min_duration_statement=500
EOF
printf "${PURPLE}Starting FireFly Stack: $NEW_STACK_NAME...\n${NC}"
${FF_CLI} start $NEW_STACK_NAME --verbose --no-rollback
cd $BASE_PATH
printf ${PURPLE}"Deploying custom test contract...\n${NC}"
TESTS='{"name": "msg_broadcast", "workers":50},{"name": "msg_private", "workers":50},{"name": "blob_broadcast", "workers":30},{"name": "blob_private", "workers":30}'
if [ "$BLOCKCHAIN_PROVIDER" = "geth" ] || [ "$BLOCKCHAIN_PROVIDER" = "besu" ]; then
output=$(${FF_CLI} deploy ethereum $NEW_STACK_NAME ./firefly/test/data/contracts/simplestorage/simple_storage.json | jq -r '.address')
prefix='contract address: '
CONTRACT_ADDRESS=${output#"$prefix"}
FLAGS="$FLAGS -a $CONTRACT_ADDRESS"
TESTS="${TESTS},{\"name\": \"custom_ethereum_contract\", \"workers\":20},{\"name\": \"token_mint\", \"workers\":10}"
CONTRACT_OPTIONS="{\"address\": \"${CONTRACT_ADDRESS}\"}"
elif [ "$BLOCKCHAIN_PROVIDER" == "fabric" ]; then
docker run --rm -v $BASE_PATH/firefly/test/data/assetcreator:/chaincode-go hyperledger/fabric-tools:2.4 peer lifecycle chaincode package /chaincode-go/package.tar.gz --path /chaincode-go --lang golang --label assetcreator
output=$(${FF_CLI} deploy $NEW_STACK_NAME ./firefly/test/data/assetcreator/package.tar.gz firefly assetcreator 1.0)
CONTRACT_OPTIONS="{\"channel\": \"firefly\", \"chaincode\": \"assetcreator\"}"
TESTS="${TESTS},{\"name\": \"custom_fabric_contract\", \"workers\":50}"
fi
cat <<EOF > $BASE_PATH/instances.yml
stackJSONPath: ${HOME}/.firefly/stacks/$NEW_STACK_NAME/stack.json
wsConfig:
wsPath: /ws
readBufferSize: 16000
writeBufferSize: 16000
initialDelay: 250ms
maximumDelay: 30s
initialConnectAttempts: 5
heartbeatInterval: 5s
instances:
- name: long-run
tests: [${TESTS}]
length: 500h
sender: 0
recipient: 1
messageOptions:
longMessage: false
tokenOptions:
tokenType: fungible
contractOptions: ${CONTRACT_OPTIONS}
EOF
cat <<EOF > start.sh
ffperf run -c $BASE_PATH/instances.yml -n long-run
docker exec ${NEW_STACK_NAME}_firefly_core_0 /bin/sh -c "curl 0.0.0.0:6060/debug/pprof/profile" > ${NEW_STACK_NAME}.prof
echo "Profiling data saved to ${NEW_STACK_NAME}.prof"
EOF
echo "FLAGS=$FLAGS"
printf "${PURPLE}Modify $BASE_PATH/instances.yml and the commnd below and run...\n${NC}"
echo '```'
printf "${GREEN}nohup ./start.sh &> ffperf.log &${NC}\n"
echo '```'
echo "core-config.yml"
echo '```'
cat core-config.yml
echo '```'
echo "ethconnect.yml"
echo '```'
cat ethconnect.yml
echo '```'
echo "instances.yml"
echo '```'
cat instances.yml
echo '```'
echo "FireFly git commit:"
echo '```'
sh -c 'cd firefly; git rev-parse HEAD; cd ..'
echo '```'
# Create markdown for Perf Test
#printf "\n${RED}*** Before Starting Test ***${NC}\n"
#printf "${PURPLE}*** Add the following entry to https://github.com/hyperledger/firefly/issues/519 ***${NC}\n"
#printf "\n| $(uuidgen) | $(TZ=":US/Eastern" date +%m_%d_%Y_%I_%M_%p) | *Add Snapshot After Test* | $(TZ=":US/Eastern" date +%m_%d_%Y_%I_%M_%p) | *Add After Test* | *Add After Test* | $BLOCKCHAIN_PROVIDER | *Add Num Broadcasts* | *Add Num Private* | *Add Num Minters* | *Add Num On-Chain* | *Add related Github Issue* | $(cd $BASE_PATH/firefly;git rev-parse --short HEAD) | *Add After Test* | $(echo $(jq -r 'to_entries[] | "\(.key):\(.value .sha)"' $BASE_PATH/firefly/manifest.json)// )|\n"