Skip to content

Commit e361aca

Browse files
committed
updates bench scripts and docs
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
1 parent 22bbfbd commit e361aca

7 files changed

+37
-31
lines changed

bench/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ By that reason load test uses prepared load data which can be generated as follo
2828
* Initialize the pool and test accounts (**Warning** applicable to local in-docker pool only for now):
2929

3030
```bash
31-
sudo make localnet_clean
31+
make localnet_clean
3232

3333
# DCL_OBSERVERS=1 make localnet_init # to initialize observers as well
3434
make localnet_init

bench/generate.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
from render import render
2828

2929

30-
DCLCLI = "dclcli"
30+
DCLCLI = "dcld"
31+
DCL_CHAIN_ID = "dclchain"
3132

3233
DEF_ACCOUNT_N_START = 4
3334
DEF_SEQUENCE_START = 0
@@ -36,10 +37,8 @@
3637
SEQUENCE_START_F = "sequence-number-start"
3738
QUERIES_F = "q"
3839

39-
TEST_PASSWORD = "test1234"
40-
4140
MODEL_INFO_PREFIX = 1
42-
VENDOR_PRODUCTS_PREFIX = 2
41+
# VENDOR_PRODUCTS_PREFIX = 2
4342

4443

4544
def pack_model_info_key(vid, pid):
@@ -110,14 +109,13 @@ def txn_generate(u_address, txn_t_cls, txn_t_cmd, **params):
110109

111110

112111
def txn_sign(u_address, account, sequence, f_path):
113-
cmd = [DCLCLI, "tx", "sign"]
112+
cmd = [DCLCLI, "tx", "sign", "--chain-id", DCL_CHAIN_ID]
114113
params = {"from": u_address}
115114
cmd += to_cli_args(
116115
account_number=account, sequence=sequence, gas="auto", **params
117116
)
118117
cmd.extend(["--offline", f_path])
119-
cmd = f"echo '{TEST_PASSWORD}' | {' '.join(cmd)}"
120-
return run_shell_cmd(cmd, shell=True).stdout
118+
return run_shell_cmd(cmd).stdout
121119

122120

123121
def txn_encode(f_path):

bench/locustfile.py

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def add_model(self):
123123
f"{self.host}/", json.dumps(payload), name="write-txn",
124124
catch_response=True
125125
) as response:
126+
# logger.debug(f"{self.username}: response {response.__dict__}")
126127
logger.debug(f"{self.username}: response {response.text}")
127128
payload = json.loads(response.text)
128129
if "error" in payload:

bench/test.spec.yaml

+9-8
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ templates:
1717
add-model: &add-model-tmpl
1818
vid: 1
1919
pid: 1
20-
name: Device
21-
description: decription
22-
sku: SKU12FS
23-
hardware-version: 1.0
24-
firmware-version: 2.0
25-
tis-or-trp-testing-completed: "true"
20+
deviceTypeID: 1
21+
productName: Device
22+
productLabel: decription
23+
partNumber: SKU12FS
24+
#hardware-version: 1.0
25+
#firmware-version: 2.0
26+
#tis-or-trp-testing-completed: "true"
2627

2728
defaults:
2829
account-number-start: 4
@@ -46,9 +47,9 @@ users:
4647
tu{{ vid_str }}:
4748
q:
4849
{%- for pid in range(1, write_users_q_c) %}
49-
- tx/modelinfo/add-model:
50+
- tx/model/add-model:
5051
<<: *add-model-tmpl
51-
vid: {{ vid_str }}
52+
vid: {{ vid }}
5253
pid: {{ pid }}
5354
{%- endfor %}
5455

cmd/dcld/cmd/genaccounts.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/cosmos/cosmos-sdk/server"
1717
sdk "github.com/cosmos/cosmos-sdk/types"
1818
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
19+
"github.com/spf13/cast"
1920
"github.com/spf13/cobra"
2021
"github.com/spf13/viper"
2122
dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types"
@@ -27,6 +28,7 @@ const (
2728
FlagAddress = "address"
2829
FlagPubKey = "pubkey"
2930
FlagRoles = "roles"
31+
FlagVID = "vid"
3032
)
3133

3234
// AddGenesisAccountCmd returns add-genesis-account cobra Command.
@@ -95,8 +97,17 @@ the address will be looked up in the local Keybase.
9597
// and uses pack/unpack API to extract accounts from genesis state
9698

9799
ba := authtypes.NewBaseAccount(addr, pk, 0, 0)
100+
101+
var vendorID uint64 = 0
102+
if viper.GetString(FlagVID) != "" {
103+
vendorID, err = cast.ToUint64E(viper.GetString(FlagVID))
104+
if err != nil {
105+
return err
106+
}
107+
}
108+
98109
// FIXME issue 99 VendorID
99-
genAccount = dclauthtypes.NewAccount(ba, roles, 0)
110+
genAccount = dclauthtypes.NewAccount(ba, roles, vendorID)
100111

101112
if err := genAccount.Validate(); err != nil {
102113
return fmt.Errorf("failed to validate new genesis account: %w", err)
@@ -138,6 +149,7 @@ the address will be looked up in the local Keybase.
138149
cmd.Flags().String(FlagPubKey, "", "The validator's Protobuf JSON encoded public key")
139150
cmd.Flags().String(FlagRoles, "",
140151
fmt.Sprintf("The list of roles (split by comma) to assign to account (supported roles: %v)", dclauthtypes.Roles))
152+
cmd.Flags().String(FlagVID, "", "Vendor ID associated with this account. Required only for Vendor Roles")
141153

142154
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
143155
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")

genlocalnetconfig.sh

+1-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if [ "$(uname)" == "Darwin" ]; then
2525
fi
2626

2727
DCL_DIR="$HOME/.dcl"
28-
KEYPASSWD=test1234
28+
KEYPASSWD=test1234 # NOTE not necessary actually since we yse 'test' keyring backend now
2929
CHAIN_ID=dclchain
3030

3131
rm -rf "$DCL_DIR"
@@ -41,13 +41,7 @@ fi
4141

4242
dcld config chain-id "$CHAIN_ID"
4343
dcld config output json
44-
# TODO issue 99: empty value will override defaults by some reason
45-
# (e.g. in dcld status)
4644
dcld config node "tcp://localhost:26657"
47-
# TODO issue 99: check the replacement for the setting
48-
# dcld config indent true
49-
# TODO issue 99: check the replacement for the setting
50-
# dcld config trust-node false
5145
dcld config keyring-backend test
5246
dcld config broadcast-mode block
5347

gentestaccounts.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ if [ "$(uname)" == "Darwin" ]; then
2121
SED_EXT="''"
2222
fi
2323

24+
DCL_DIR="$HOME/.dcl"
2425
LOCALNET_DIR=".localnet"
2526

2627
rm -rf "$LOCALNET_DIR"/client/*
2728

28-
PASSWD=test1234
2929
NUMUSERS="${1:-10}"
3030

3131
for i in $(seq 1 "$NUMUSERS"); do
3232
userN="$(printf "%05d\n" "$i")"
3333
username="tu${userN}"
34-
echo $PASSWD"" | dclcli keys add "$username"
34+
dcld keys add "$username"
3535

36-
tu_address="$(dclcli keys show "$username" -a)"
37-
tu_pubkey="$(dclcli keys show "$username" -p)"
36+
tu_address="$(dcld keys show "$username" -a)"
37+
tu_pubkey="$(dcld keys show "$username" -p)"
3838

39-
dcld add-genesis-account --address=$tu_address --pubkey=$tu_pubkey --roles="Vendor"
39+
dcld add-genesis-account --address=$tu_address --pubkey=$tu_pubkey --roles="Vendor" --vid="$i"
4040
echo "$username generated"
4141
done
4242

4343
dcld validate-genesis
4444

45-
cp -r ~/.dclcli/* "$LOCALNET_DIR"/client
45+
cp -r "$DCL_DIR"/* "$LOCALNET_DIR"/client
4646
for node_id in node0 node1 node2 node3 observer0; do
4747
if [[ -d "$LOCALNET_DIR/${node_id}" ]]; then
48-
cp -f ~/.dcld/config/genesis.json "$LOCALNET_DIR/${node_id}/config/"
48+
cp -f "$DCL_DIR"/config/genesis.json "$LOCALNET_DIR/${node_id}/config/"
4949
fi
5050
done

0 commit comments

Comments
 (0)