Skip to content

Commit

Permalink
Busywork updates 9/22/2016
Browse files Browse the repository at this point in the history
Several changes are required due to the removal of the /devops route from
the REST API. The major change here is the conversion of the Tcl ::fabric
package to use the /chaincode route instead of /devops.

Several other enhancements and bug fixes are also inclued:

1) Fixes FAB-139 (Timer overflow)
2) Fixes FAB-414 (Additional timestamp for all TX committed)

Tcl support for reading /proc/<PID>/stat was added. This allows more
statistics to be printed after the Busywork run (e.g., user + system time
and CPU utilization). /proc/<PID>/stat fields can also be accessed for the
peers now by way of the 'busy' command, which was also enhanced with 'ps'
and 'pid' subcommands.

The 'pprofClient' was updated to support Go 1.7 naming conventions for pprof
files.

The -privacy flag was added to 'userModeNetwork'.

Removed trailing whitespace from all modified files.

Change-Id: Ie8d2cc95fb6e7384ce3fbb4d19949d14ec19ddc7
Signed-off-by: Bishop Brock <bcbrock@us.ibm.com>
  • Loading branch information
bcbrock committed Sep 22, 2016
1 parent 519e8e8 commit 02431ee
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 171 deletions.
109 changes: 78 additions & 31 deletions tools/busywork/bin/busy
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/tclsh

# Copyright IBM Corp. 2016. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -19,18 +19,18 @@ set usage {

The 'busy' script runs commands on one or more peers in a busywork network,
printing the salient portion of the response on stdout. 'busy' can be seen as
an easier-to-use version of the Hyperledger fabric command-line-interface
(CLI) in that 'busy' takes care of various kinds of bookkeeping and
boilerplate code behind the scenes. 'busy' is probably best used as a tool for
small scipts, or for issuing a few interactive commands to a peer
network. Alhough complex test scripts could be implemented entirely as 'busy'
calls, the performance of a test implemented this way would likely suffer from
the process-creation overhead of each 'busy' invocation.
an easier-to-use, enhanced version of the Hyperledger fabric
command-line-interface (CLI) in that 'busy' takes care of various kinds of
bookkeeping and boilerplate code behind the scenes. 'busy' is probably best
used as a tool for small scipts, or for issuing a few interactive commands to
a peer network. Alhough complex test scripts could be implemented entirely as
'busy' calls, the performance of a test implemented this way would likely
suffer from the process-creation overhead of each 'busy' invocation.

If the 'busy' command targets a single peer (see below) then the response from
that peer is printed. If multiple peers are targeted, then the results are
collected and printed as a JSON object, where each result is keyed by the peer
name, e.g.,
or for that peer is printed. If multiple peers are targeted, then the results
are collected and printed as a JSON object, where each result is keyed by the
peer name, e.g.,

{
"vp0" : <VP0 response>,
Expand All @@ -39,8 +39,8 @@ name, e.g.,
"vp<N>" : <VP<N> response>
}

Use -json to force results from operations on a single peer to print as a JSON
object.
Include the -json option to force results from operations on a single peer to
print as a JSON object.

'busy' is only supported for peer networks described by a 'network' file in
the BUSYWORK_HOME directory. The <peers> to target are named by the peer IDs
Expand Down Expand Up @@ -76,6 +76,9 @@ The following command and argument forms are supported:

ping <peers> <user-chaincode-id>

pid <peers>
ps <peers> <List of ps display keywords>

The 'network' and 'chaincodes' commands simply print the current 'network' and
'chaincodes' files respectively from the implied $BUSYWORK_HOME.

Expand Down Expand Up @@ -110,6 +113,17 @@ queries fail. If the ping query succeeds then the output of the ping queries
is returned. This function currently assumes that the chaincode implments a
'ping' query function with no parameters.

The 'pid' command simply returns the PID of each of the <peers>.

The 'ps' command is used to obtain 'ps' information from one or more
peers. For each peer implied by the <peers> specification, the result returned
is the result from executing 'ps' as follows, where <pid> is the PID of each
of the <peers>:

ps -p <pid> -ww --noheader -o <List of ps display keywords>

Note that leading/trailing whitespace is removed from the result.

Examples:

busy chaincodes
Expand All @@ -124,6 +138,9 @@ Examples:

busy ping "*" cc2

busy pid vp0
busy ps vp0 etime,cputime

Optional arguments, with defaults after the colon:

-h | -help | --help : N/A
Expand All @@ -149,12 +166,12 @@ Optional arguments, with defaults after the colon:

The -waitFor option is supported for the 'deploy', 'invoke' and 'ping'
commands only. The semantics are explained below in the section headed
"Semantics of -waitFor"
"Semantics of -waitFor"

-json : See below

Select -json to force even single-peer operations to print as a JSON
object, rather than simply as a value. This opiton is ignored for the
object, rather than simply as a value. This option is ignored for the
'chaincodes' and 'network' commands.


Expand Down Expand Up @@ -191,6 +208,14 @@ proc singletonCommand {cmd} {
}


proc fixedArgs {cmd nArgs} {

if {[llength [parms args]] != $nArgs} {
errorExit "The '$cmd' command expects $nArgs arguments."
}
}


proc chaincodes {} {

singletonCommand chaincodes
Expand Down Expand Up @@ -294,7 +319,7 @@ proc invoke {} {
"Deployed IDs are $a(ids)"
}
set name $a($ccId.name)

if {![null [parms waitFor]]} {
set heights \
[mapeach address [parms restAddresses] {
Expand Down Expand Up @@ -322,7 +347,7 @@ proc invoke {} {
}
}


proc query {} {

waitForNotOK query
Expand All @@ -344,7 +369,7 @@ proc query {} {
errorExit
}
set name $a($ccId.name)

parms results \
[mapeach address [parms restAddresses] {
return [fabric::query $address [parms user] $name $function $args]
Expand All @@ -369,7 +394,7 @@ proc ping {} {
errorExit
}
set name $a($ccId.name)

proc _ping {name} {
set results {}
foreach address [parms restAddresses] {
Expand All @@ -395,7 +420,33 @@ proc ping {} {
}
}



proc pid {} {

waitForNotOK pid
fixedArgs pid 0

parms results [mapeach peer [parms peers] {
return [parms network.peer.$peer.pid]
}]
}


proc ps {} {

waitForNotOK ps
fixedArgs ps 1

parms results [mapeach peer [parms peers] {
set pid [parms network.peer.$peer.pid]
if {[catch {exec ps -p $pid -ww --noheader -o [parms args]} result]} {
errorExit "Exec of 'ps' failed : $result"
}
return [string trim $result]; # Remove leading/trailing whitespace
}]
}


############################################################################
# The script
############################################################################
Expand All @@ -410,11 +461,11 @@ setLoggingLevel {} warn
set options {
{enum {-h -help --help} parms(help) 0 p_help}
{key -home parms(home) {}}
{bool -user parms(user) {} p_user}
{key -user parms(user) {} p_user}
{key -waitFor parms(waitFor) {}}
{bool -json parms(json) 0}
}

mapKeywordArgs $argv $options parms(other)

if {$p_help} {
Expand All @@ -430,7 +481,7 @@ parms command [first [parms other]]
switch [parms command] {
chaincodes {chaincodes}
network {network}
}
}

parms peers [busywork::peersFromSpec [second [parms other]]]
parms args [restn [parms other] 2]
Expand Down Expand Up @@ -459,6 +510,8 @@ switch [parms command] {
invoke {invoke}
query {query}
ping {ping}
pid {pid}
ps {ps}
default {errorExit "Unrecognized command: [parms command]"}
}

Expand Down Expand Up @@ -489,9 +542,3 @@ if {[parms json] || [expr {[llength [parms results]] > 1}]} {

puts [first [parms results]]
}






0 comments on commit 02431ee

Please sign in to comment.