From 0d473e75301cb21fa45290bd2eba6d87f2f0d929 Mon Sep 17 00:00:00 2001 From: laodouya Date: Fri, 17 May 2019 17:20:24 +0800 Subject: [PATCH 01/11] Prebuild a bench binary for GNTE test. --- Makefile | 9 ++++++++- cmd/cql-minerd/benchGNTE.sh | 10 ++++++---- test/GNTE/run.sh | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e594c5183..59979d470 100644 --- a/Makefile +++ b/Makefile @@ -177,13 +177,20 @@ bin/cql-faucet: -o bin/cql-faucet \ github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet +bin/intergration.test: + CGO_ENABLED=1 go test $(test_flags) -tags "$(tags)" \ + -ldflags "$(ldflags_role_client)" \ + -o bin/intergration.test \ + github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd + + bp: bin/cqld.test bin/cqld miner: bin/cql-minerd.test bin/cql-minerd client: bin/cql bin/cql.test bin/cql-fuse bin/cql-mysql-adapter bin/cql-faucet -all: bp miner client +all: bp miner client bin/intergration.test build-release: bin/cqld bin/cql-minerd bin/cql bin/cql-fuse bin/cql-mysql-adapter bin/cql-faucet diff --git a/cmd/cql-minerd/benchGNTE.sh b/cmd/cql-minerd/benchGNTE.sh index 229753fac..029ce51f8 100755 --- a/cmd/cql-minerd/benchGNTE.sh +++ b/cmd/cql-minerd/benchGNTE.sh @@ -8,6 +8,8 @@ declare flags=( "-run=^$" ) +BENCH_BIN=${PROJECT_DIR}/bin/intergration.test + clean() { if [ -n "${TEST_WD}" ]; then # Clean @@ -24,11 +26,11 @@ clean() { fast() { echo "Fast benchmarking with flags: $@" clean - go test "${flags[@]}" "$pkg" "$@" | tee -a gnte.log + ${BENCH_BIN} "${flags[@]}" "$pkg" "$@" | tee -a gnte.log clean - go test "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log + ${BENCH_BIN} "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log clean - go test -cpu=1 "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log + ${BENCH_BIN} -cpu=1 "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log } full() { @@ -45,7 +47,7 @@ full() { clean - go test "${caseflags[@]}" "$pkg" "$@" -bench-miner-count=$count | tee -a gnte.log + ${BENCH_BIN} "${caseflags[@]}" "$pkg" "$@" -bench-miner-count=$count | tee -a gnte.log ips=(2 3 4 5 6 7 8 9) cur_sec=`date '+%s'` diff --git a/test/GNTE/run.sh b/test/GNTE/run.sh index 67ccd3806..f230ec808 100755 --- a/test/GNTE/run.sh +++ b/test/GNTE/run.sh @@ -11,7 +11,7 @@ else fi export TEST_WD=$(cd $(dirname $0)/; pwd) -PROJECT_DIR=$(cd ${TEST_WD}/../../; pwd) +export PROJECT_DIR=$(cd ${TEST_WD}/../../; pwd) echo ${PROJECT_DIR} From 8aff1be5d0cf1cad6b4a791d34ae759efa1718b9 Mon Sep 17 00:00:00 2001 From: laodouya Date: Fri, 17 May 2019 17:38:50 +0800 Subject: [PATCH 02/11] Fix test bench binary flag changes. --- cmd/cql-minerd/benchGNTE.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/cql-minerd/benchGNTE.sh b/cmd/cql-minerd/benchGNTE.sh index 029ce51f8..69fc6464f 100755 --- a/cmd/cql-minerd/benchGNTE.sh +++ b/cmd/cql-minerd/benchGNTE.sh @@ -3,9 +3,9 @@ set -euo pipefail declare pkg="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd" declare flags=( - "-bench=^BenchmarkMinerGNTE$" - "-benchtime=10s" - "-run=^$" + "-test.bench=^BenchmarkMinerGNTE$" + "-test.benchtime=10s" + "-test.run=^$" ) BENCH_BIN=${PROJECT_DIR}/bin/intergration.test From 850a4620537f0c589370ea3c175f14dd8341e5d7 Mon Sep 17 00:00:00 2001 From: laodouya Date: Fri, 17 May 2019 17:55:28 +0800 Subject: [PATCH 03/11] Fix bench data race. --- cmd/cql-minerd/integration_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go index ceb079a8c..120e40eb0 100644 --- a/cmd/cql-minerd/integration_test.go +++ b/cmd/cql-minerd/integration_test.go @@ -704,7 +704,6 @@ func makeBenchName(trailings ...string) string { } func benchDB(b *testing.B, db *sql.DB, createDB bool) { - var err error if createDB { prepareBenchTable(db) } @@ -725,7 +724,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) { ctx, task := trace.NewTask(context.Background(), "BenchInsert") - _, err = db.ExecContext(ctx, "INSERT INTO "+TABLENAME+" ( k, v1 ) VALUES"+ + _, err := db.ExecContext(ctx, "INSERT INTO "+TABLENAME+" ( k, v1 ) VALUES"+ "(?, ?)", index, ii, ) //log.Warnf("insert index = %d %v", index, time.Since(start)) @@ -754,7 +753,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) { rowCount := db.QueryRow("SELECT COUNT(1) FROM " + TABLENAME) var count int64 - err = rowCount.Scan(&count) + err := rowCount.Scan(&count) if err != nil { b.Fatal(err) } @@ -777,7 +776,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) { row := db.QueryRowContext(ctx, "SELECT v1 FROM "+TABLENAME+" WHERE k = ? LIMIT 1", index) //log.Warnf("select index = %d %v", index, time.Since(start)) var result []byte - err = row.Scan(&result) + err := row.Scan(&result) if err != nil || (len(result) == 0) { log.Errorf("index = %d", index) b.Fatal(err) From 2719c30b42b346f82c41ef420feca69eeb1d38e9 Mon Sep 17 00:00:00 2001 From: laodouya Date: Fri, 17 May 2019 18:11:14 +0800 Subject: [PATCH 04/11] Fix test bench binary -cpu flag. --- cmd/cql-minerd/benchGNTE.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cql-minerd/benchGNTE.sh b/cmd/cql-minerd/benchGNTE.sh index 69fc6464f..b49d66118 100755 --- a/cmd/cql-minerd/benchGNTE.sh +++ b/cmd/cql-minerd/benchGNTE.sh @@ -30,7 +30,7 @@ fast() { clean ${BENCH_BIN} "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log clean - ${BENCH_BIN} -cpu=1 "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log + ${BENCH_BIN} -test.cpu=1 "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log } full() { @@ -42,7 +42,7 @@ full() { if [[ -z $cpu ]]; then caseflags=("${flags[@]}") else - caseflags=("-cpu=$cpu" "${flags[@]}") + caseflags=("-test.cpu=$cpu" "${flags[@]}") fi clean From 9d6a9b65cd8bc23222105865d4c26c870b6ca7d6 Mon Sep 17 00:00:00 2001 From: laodouya Date: Fri, 10 May 2019 15:25:10 +0800 Subject: [PATCH 05/11] Add GNTE test cases --- test/GNTE/conf/gnte_50ms.yaml | 79 ++++++++++++++++++++++++++++ test/GNTE/conf/gnte_bpminer50ms.yaml | 74 ++++++++++++++++++++++++++ test/GNTE/conf/gnte_inbp50ms.yaml | 74 ++++++++++++++++++++++++++ test/GNTE/run.sh | 2 +- 4 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 test/GNTE/conf/gnte_50ms.yaml create mode 100644 test/GNTE/conf/gnte_bpminer50ms.yaml create mode 100644 test/GNTE/conf/gnte_inbp50ms.yaml diff --git a/test/GNTE/conf/gnte_50ms.yaml b/test/GNTE/conf/gnte_50ms.yaml new file mode 100644 index 000000000..35c229620 --- /dev/null +++ b/test/GNTE/conf/gnte_50ms.yaml @@ -0,0 +1,79 @@ +# Only support 10.250.0.2 ~ 10.250.254.254 +group: + - + name: bp + nodes: + - # bp10.250.1.2 + ip: 10.250.1.2/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_0/config.yaml" + - # bp10.250.1.3 + ip: 10.250.1.3/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_1/config.yaml" + - # bp10.250.1.4 + ip: 10.250.1.4/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_2/config.yaml" + delay: "50ms" + rate: "1000mbit" + - + name: miner + nodes: + - # miner10.250.100.2 + ip: 10.250.100.2/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.2/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.3 + ip: 10.250.100.3/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.3/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.4 + ip: 10.250.100.4/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.4/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.5 + ip: 10.250.100.5/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.5/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.6 + ip: 10.250.100.6/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.6/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.7 + ip: 10.250.100.7/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.7/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.8 + ip: 10.250.100.8/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.8/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.9 + ip: 10.250.100.9/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.9/config.yaml -metric-web 0.0.0.0:6060" + delay: "50ms" + rate: "1000mbit" + - + name: client + nodes: + - # node_c + ip: 10.250.0.2/32 + cmd: "ping -c3 g.cn" + - # node_adapter + ip: 10.250.0.254/32 + cmd: "cd /scripts && ./bin/cql-adapter -config ./node_c/config.yaml" + delay: "50ms" + rate: "1000mbit" + +network: + - + groups: + - bp + - miner + delay: "50ms" + rate: "1000mbit" + + - + groups: + - bp + - client + delay: "50ms" + rate: "1000mbit" + + - + groups: + - client + - miner + delay: "50ms" + rate: "1000mbit" + diff --git a/test/GNTE/conf/gnte_bpminer50ms.yaml b/test/GNTE/conf/gnte_bpminer50ms.yaml new file mode 100644 index 000000000..d88294d0d --- /dev/null +++ b/test/GNTE/conf/gnte_bpminer50ms.yaml @@ -0,0 +1,74 @@ +# Only support 10.250.0.2 ~ 10.250.254.254 +group: + - + name: bp + nodes: + - # bp10.250.1.2 + ip: 10.250.1.2/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_0/config.yaml" + - # bp10.250.1.3 + ip: 10.250.1.3/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_1/config.yaml" + - # bp10.250.1.4 + ip: 10.250.1.4/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_2/config.yaml" + rate: "1000mbit" + - + name: miner + nodes: + - # miner10.250.100.2 + ip: 10.250.100.2/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.2/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.3 + ip: 10.250.100.3/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.3/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.4 + ip: 10.250.100.4/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.4/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.5 + ip: 10.250.100.5/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.5/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.6 + ip: 10.250.100.6/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.6/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.7 + ip: 10.250.100.7/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.7/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.8 + ip: 10.250.100.8/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.8/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.9 + ip: 10.250.100.9/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.9/config.yaml -metric-web 0.0.0.0:6060" + rate: "1000mbit" + - + name: client + nodes: + - # node_c + ip: 10.250.0.2/32 + cmd: "ping -c3 g.cn" + - # node_adapter + ip: 10.250.0.254/32 + cmd: "cd /scripts && ./bin/cql-adapter -config ./node_c/config.yaml" + rate: "1000mbit" + +network: + - + groups: + - bp + - miner + delay: "50ms" + rate: "1000mbit" + + - + groups: + - bp + - client + rate: "1000mbit" + + - + groups: + - client + - miner + rate: "1000mbit" + diff --git a/test/GNTE/conf/gnte_inbp50ms.yaml b/test/GNTE/conf/gnte_inbp50ms.yaml new file mode 100644 index 000000000..cdd96817b --- /dev/null +++ b/test/GNTE/conf/gnte_inbp50ms.yaml @@ -0,0 +1,74 @@ +# Only support 10.250.0.2 ~ 10.250.254.254 +group: + - + name: bp + nodes: + - # bp10.250.1.2 + ip: 10.250.1.2/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_0/config.yaml" + - # bp10.250.1.3 + ip: 10.250.1.3/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_1/config.yaml" + - # bp10.250.1.4 + ip: 10.250.1.4/32 + cmd: "cd /scripts && ./bin/cqld -config ./node_2/config.yaml" + delay: "50ms" + rate: "1000mbit" + - + name: miner + nodes: + - # miner10.250.100.2 + ip: 10.250.100.2/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.2/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.3 + ip: 10.250.100.3/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.3/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.4 + ip: 10.250.100.4/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.4/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.5 + ip: 10.250.100.5/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.5/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.6 + ip: 10.250.100.6/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.6/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.7 + ip: 10.250.100.7/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.7/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.8 + ip: 10.250.100.8/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.8/config.yaml -metric-web 0.0.0.0:6060" + - # miner10.250.100.9 + ip: 10.250.100.9/32 + cmd: "cd /scripts && ./bin/cql-minerd -config ./node_miner_10.250.100.9/config.yaml -metric-web 0.0.0.0:6060" + rate: "1000mbit" + - + name: client + nodes: + - # node_c + ip: 10.250.0.2/32 + cmd: "ping -c3 g.cn" + - # node_adapter + ip: 10.250.0.254/32 + cmd: "cd /scripts && ./bin/cql-adapter -config ./node_c/config.yaml" + rate: "1000mbit" + +network: + - + groups: + - bp + - miner + rate: "1000mbit" + + - + groups: + - bp + - client + rate: "1000mbit" + + - + groups: + - client + - miner + rate: "1000mbit" + diff --git a/test/GNTE/run.sh b/test/GNTE/run.sh index f230ec808..1a72fd895 100755 --- a/test/GNTE/run.sh +++ b/test/GNTE/run.sh @@ -6,7 +6,7 @@ if [ "fast" == "$param" ]; then yaml=./scripts/gnte_0ms.yaml else yaml=( - ./scripts/gnte_{0,0.2,5,20,100,eventual}ms.yaml + ./scripts/gnte_{0,50,bpminer50,inbp50,eventual}ms.yaml ) fi From 662ca2e15905b0cc9cb7e8656efa92929af0a9ba Mon Sep 17 00:00:00 2001 From: laodouya Date: Mon, 20 May 2019 11:04:52 +0800 Subject: [PATCH 06/11] Reorder bench binary flags. --- cmd/cql-minerd/benchGNTE.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/cql-minerd/benchGNTE.sh b/cmd/cql-minerd/benchGNTE.sh index b49d66118..3e2a15ac9 100755 --- a/cmd/cql-minerd/benchGNTE.sh +++ b/cmd/cql-minerd/benchGNTE.sh @@ -26,11 +26,11 @@ clean() { fast() { echo "Fast benchmarking with flags: $@" clean - ${BENCH_BIN} "${flags[@]}" "$pkg" "$@" | tee -a gnte.log + ${BENCH_BIN} "$@" "${flags[@]}" "$pkg" | tee -a gnte.log clean - ${BENCH_BIN} "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log + ${BENCH_BIN} -bench-miner-count=2 "$@" "${flags[@]}" "$pkg" | tee -a gnte.log clean - ${BENCH_BIN} -test.cpu=1 "${flags[@]}" "$pkg" "$@" -bench-miner-count=2 | tee -a gnte.log + ${BENCH_BIN} -bench-miner-count=2 "$@" -test.cpu=1 "${flags[@]}" "$pkg" | tee -a gnte.log } full() { @@ -47,7 +47,7 @@ full() { clean - ${BENCH_BIN} "${caseflags[@]}" "$pkg" "$@" -bench-miner-count=$count | tee -a gnte.log + ${BENCH_BIN} "$@" -bench-miner-count=$count "${caseflags[@]}" "$pkg" | tee -a gnte.log ips=(2 3 4 5 6 7 8 9) cur_sec=`date '+%s'` From f5f42d3b5ceb136a23323eafde4b6ae7213afcc3 Mon Sep 17 00:00:00 2001 From: laodouya Date: Mon, 20 May 2019 15:04:18 +0800 Subject: [PATCH 07/11] Remove intergration.test race flags. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 59979d470..c4cad1e69 100644 --- a/Makefile +++ b/Makefile @@ -178,7 +178,7 @@ bin/cql-faucet: github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet bin/intergration.test: - CGO_ENABLED=1 go test $(test_flags) -tags "$(tags)" \ + CGO_ENABLED=1 go test -tags "$(tags)" \ -ldflags "$(ldflags_role_client)" \ -o bin/intergration.test \ github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd From 36ddd12a7a15736651253e3636dad7b078270278 Mon Sep 17 00:00:00 2001 From: laodouya Date: Mon, 20 May 2019 15:24:36 +0800 Subject: [PATCH 08/11] Fix intergration.test missing flag. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c4cad1e69..5b42bf8e3 100644 --- a/Makefile +++ b/Makefile @@ -178,7 +178,7 @@ bin/cql-faucet: github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet bin/intergration.test: - CGO_ENABLED=1 go test -tags "$(tags)" \ + CGO_ENABLED=1 go test -c -tags "$(tags)" \ -ldflags "$(ldflags_role_client)" \ -o bin/intergration.test \ github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd From 369e75db21df20ce488f09ff7e31262b7d4b5d03 Mon Sep 17 00:00:00 2001 From: laodouya Date: Tue, 21 May 2019 15:50:34 +0800 Subject: [PATCH 09/11] Move benchGNTE.sh to GNTE folder --- {cmd/cql-minerd => test/GNTE}/benchGNTE.sh | 0 test/GNTE/run.sh | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename {cmd/cql-minerd => test/GNTE}/benchGNTE.sh (100%) diff --git a/cmd/cql-minerd/benchGNTE.sh b/test/GNTE/benchGNTE.sh similarity index 100% rename from cmd/cql-minerd/benchGNTE.sh rename to test/GNTE/benchGNTE.sh diff --git a/test/GNTE/run.sh b/test/GNTE/run.sh index 1a72fd895..eed7cbe79 100755 --- a/test/GNTE/run.sh +++ b/test/GNTE/run.sh @@ -6,7 +6,7 @@ if [ "fast" == "$param" ]; then yaml=./scripts/gnte_0ms.yaml else yaml=( - ./scripts/gnte_{0,50,bpminer50,inbp50,eventual}ms.yaml + ./scripts/gnte_{0,0.2,5,20,100,eventual}ms.yaml ) fi @@ -48,7 +48,7 @@ do export delay_file=${gnte_yaml} # Bench GNTE - cd ${PROJECT_DIR}/cmd/cql-minerd/ + cd ${TEST_WD} ips=(2 3 4 5 6 7 8 9) if ! bash -x ./benchGNTE.sh $param; then for ip in "${ips[@]}"; do From 3a73116b0fedf4b6b8c42df9a07ea305a2d87525 Mon Sep 17 00:00:00 2001 From: laodouya Date: Tue, 21 May 2019 16:39:11 +0800 Subject: [PATCH 10/11] Modify gnte.yaml --- test/GNTE/TODO | 4 ++++ test/GNTE/conf/gnte.yaml | 5 +---- test/GNTE/conf/gnte_bpminer50ms.yaml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 test/GNTE/TODO diff --git a/test/GNTE/TODO b/test/GNTE/TODO new file mode 100644 index 000000000..83af6579e --- /dev/null +++ b/test/GNTE/TODO @@ -0,0 +1,4 @@ +1. python yaml decode and replace delay +2. refactor run.sh, replace yaml by python +3. benchGNTE refactor, docker exec benchGNTE +4. reduce yaml in one. replace client to 'tail -f /dev/null' diff --git a/test/GNTE/conf/gnte.yaml b/test/GNTE/conf/gnte.yaml index e305a08c1..584a225c0 100644 --- a/test/GNTE/conf/gnte.yaml +++ b/test/GNTE/conf/gnte.yaml @@ -46,10 +46,7 @@ group: nodes: - # node_c ip: 10.250.0.2/32 - cmd: "ping -c3 g.cn" - - # node_adapter - ip: 10.250.0.254/32 - cmd: "cd /scripts && ./bin/cql-adapter -config ./node_c/config.yaml" + cmd: "tail -f /dev/null" rate: "1000mbit" network: diff --git a/test/GNTE/conf/gnte_bpminer50ms.yaml b/test/GNTE/conf/gnte_bpminer50ms.yaml index d88294d0d..a26269465 100644 --- a/test/GNTE/conf/gnte_bpminer50ms.yaml +++ b/test/GNTE/conf/gnte_bpminer50ms.yaml @@ -46,7 +46,7 @@ group: nodes: - # node_c ip: 10.250.0.2/32 - cmd: "ping -c3 g.cn" + cmd: "tail -f /dev/null" - # node_adapter ip: 10.250.0.254/32 cmd: "cd /scripts && ./bin/cql-adapter -config ./node_c/config.yaml" From 4a56f56a5436dea5b0fc58f8949732bc87dd9966 Mon Sep 17 00:00:00 2001 From: laodouya Date: Wed, 22 May 2019 19:26:04 +0800 Subject: [PATCH 11/11] Add a python script for generate custom delay gnte yaml --- test/GNTE/Pipfile | 13 ++++++++ test/GNTE/change_delay.py | 66 +++++++++++++++++++++++++++++++++++++++ test/GNTE/conf/gnte.yaml | 3 ++ 3 files changed, 82 insertions(+) create mode 100644 test/GNTE/Pipfile create mode 100644 test/GNTE/change_delay.py diff --git a/test/GNTE/Pipfile b/test/GNTE/Pipfile new file mode 100644 index 000000000..1aec944a0 --- /dev/null +++ b/test/GNTE/Pipfile @@ -0,0 +1,13 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] +pylint = "*" + +[packages] +pyyaml = "*" + +[requires] +python_version = "3.7" diff --git a/test/GNTE/change_delay.py b/test/GNTE/change_delay.py new file mode 100644 index 000000000..baaa6029a --- /dev/null +++ b/test/GNTE/change_delay.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +#python3 change_delay.py miner 50ms bp 50ms bpminer 50ms + +import yaml +import os, sys, getopt + +delay={} +cur_path = os.path.dirname(os.path.realpath(__file__)) + +def load_template(): + templete_yaml_file = os.path.join(cur_path, "conf/gnte.yaml") + f = open(templete_yaml_file, 'r', encoding='utf-8') + templete_yaml_raw = f.read() + templete_yaml = yaml.full_load(templete_yaml_raw) + return templete_yaml + +def change_delay(templete): + #print(templete_yaml["network"]) + for group in templete["group"]: + for name in delay: + if group["name"] == name and delay[name] != "": + group["delay"] = delay[name] + for network in templete["network"]: + for name in delay: + if network["name"] == name and delay[name] != "": + network["delay"] = delay[name] + return templete + +def print_yaml(out, case_name): + out_yaml_file = os.path.join(cur_path, "conf/"+case_name+".yaml") + f = open(out_yaml_file, 'w', encoding='utf-8') + yaml.safe_dump(out, f) + +def main(argv): + try: + opts, _ = getopt.getopt(argv,"h",["name=", "bp=","miner=","client=","bpminer=","bpclient=","minerclient="]) + except getopt.GetoptError: + print('change_delay.py -bp "xxms" -miner "xxms"...') + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print('change_delay.py -bp "xxms" -miner "xxms"...') + sys.exit() + elif opt in ("--name"): + case_name = arg + elif opt in ("--bp"): + delay["bp"] = arg + elif opt in ("--miner"): + delay["miner "] = arg + elif opt in ("--client"): + delay["client"] = arg + elif opt in ("--bpminer"): + delay["bpminer "] = arg + elif opt in ("--bpclient"): + delay["bpclient "] = arg + elif opt in ("--minerclient"): + delay["minerclient"] = arg + + templete = load_template() + out = change_delay(templete) + print_yaml(out, case_name) + +if __name__ == "__main__": + main(sys.argv[1:]) + diff --git a/test/GNTE/conf/gnte.yaml b/test/GNTE/conf/gnte.yaml index 584a225c0..2bcdc7350 100644 --- a/test/GNTE/conf/gnte.yaml +++ b/test/GNTE/conf/gnte.yaml @@ -51,18 +51,21 @@ group: network: - + name: bpminer groups: - bp - miner rate: "1000mbit" - + name: bpclient groups: - bp - client rate: "1000mbit" - + name: minerclient groups: - client - miner