Skip to content

Commit

Permalink
add stress test scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanYuan committed Jan 3, 2024
1 parent 513eae5 commit 39d695c
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 0 deletions.
34 changes: 34 additions & 0 deletions util/rich-indexer/src/tests/stress_test_scripts/get_cells.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"

wrk.body = [[
{
"id": 2,
"jsonrpc": "2.0",
"method": "get_cells",
"params": [
{
"script": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type",
"args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223"
},
"script_type": "lock",
"script_search_mode": "exact"
},
"asc",
"0x64"
]
}
]]


function response(status, headers, body)
if (string.find(body, '"error"')) then
print('error, resp: ', body)
wrk.thread:stop()
end
end

-- This command is run under the condition that the CPU has 4 cores
-- wrk -t4 -c100 -d60s -s ./util/rich-indexer/src/tests/stress_test_scripts/get_cells.lua --latency http://127.0.0.1:8114
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"

wrk.body = [[
{
"id": 2,
"jsonrpc": "2.0",
"method": "get_cells_capacity",
"params": [
{
"script": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type",
"args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223"
},
"script_type": "lock",
"script_search_mode": "exact"
}
]
}
]]


function response(status, headers, body)
if (string.find(body, '"error"')) then
print('error, resp: ', body)
wrk.thread:stop()
end
end

-- This command is run under the condition that the CPU has 4 cores
-- wrk -t4 -c100 -d60s -s ./util/rich-indexer/src/tests/stress_test_scripts/get_cells_capacity.lua --latency http://127.0.0.1:8114
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"

wrk.body = [[
{
"id": 2,
"jsonrpc": "2.0",
"method": "get_cells_capacity",
"params": [
{
"script": {
"code_hash": "0xbbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494",
"hash_type": "type",
"args": "0x"
},
"script_type": "type",
"script_search_mode": "partial",
"filter": {
"output_data": "0x0000",
"output_data_filter_mode": "partial"
}
}
]
}
]]


function response(status, headers, body)
if (string.find(body, '"error"')) then
print('error, resp: ', body)
wrk.thread:stop()
end
end

-- This command is run under the condition that the CPU has 4 cores
-- wrk -t4 -c100 -d60s -s ./util/rich-indexer/src/tests/stress_test_scripts/get_cells_capacity_partial_mode.lua --latency http://127.0.0.1:8114
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"

wrk.body = [[
{
"id": 2,
"jsonrpc": "2.0",
"method": "get_cells",
"params": [
{
"script": {
"code_hash": "0xbbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494",
"hash_type": "type",
"args": "0x"
},
"script_type": "type",
"script_search_mode": "partial",
"filter": {
"output_data": "0x0000",
"output_data_filter_mode": "partial"
}
},
"asc",
"0x64"
]
}
]]


function response(status, headers, body)
if (string.find(body, '"error"')) then
print('error, resp: ', body)
wrk.thread:stop()
end
end

-- This command is run under the condition that the CPU has 4 cores
-- wrk -t4 -c100 -d60s -s ./util/rich-indexer/src/tests/stress_test_scripts/get_cells_partial_mode.lua --latency http://127.0.0.1:8114
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"

wrk.body = [[
{
"id": 2,
"jsonrpc": "2.0",
"method": "get_transactions",
"params": [
{
"script": {
"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hash_type": "type",
"args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223"
},
"script_type": "lock",
"script_search_mode": "exact",
"group_by_transaction": true
},
"asc",
"0x64"
]
}
]]

function response(status, headers, body)
if (string.find(body, '"error"')) then
print('error, resp: ', body)
wrk.thread:stop()
end
end

-- This command is run under the condition that the CPU has 4 cores
-- wrk -t4 -c100 -d60s -s ./util/rich-indexer/src/tests/stress_test_scripts/get_transactions.lua --latency http://127.0.0.1:8114
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"

wrk.body = [[
{
"id": 2,
"jsonrpc": "2.0",
"method": "get_transactions",
"params": [
{
"script": {
"code_hash": "0xbbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494",
"hash_type": "type",
"args": "0x"
},
"script_type": "type",
"script_search_mode": "partial",
"group_by_transaction": true,
"filter": {
"output_data": "0x0000",
"output_data_filter_mode": "partial"
}
},
"asc",
"0x64"
]
}
]]

function response(status, headers, body)
if (string.find(body, '"error"')) then
print('error, resp: ', body)
wrk.thread:stop()
end
end

-- This command is run under the condition that the CPU has 4 cores
-- wrk -t4 -c100 -d60s -s ./util/rich-indexer/src/tests/stress_test_scripts/get_transactions_partial_mode.lua --latency http://127.0.0.1:8114

0 comments on commit 39d695c

Please sign in to comment.