Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latency metrics #4

Closed
wants to merge 18 commits into from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ main
.DS_Store
ffperf/ffperf
ff-perf.log
ffperf-report.html
.vscode
dist/
*.iml
Expand Down
12 changes: 9 additions & 3 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/hyperledger/firefly-perf-cli/internal/perf"
"github.com/hyperledger/firefly-perf-cli/internal/server"
"github.com/hyperledger/firefly-perf-cli/internal/types"
"github.com/hyperledger/firefly-perf-cli/internal/util"
"github.com/hyperledger/firefly/pkg/core"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -65,17 +66,22 @@ Executes a instance within a performance test suite to generate synthetic load a
log.Warn("both the \"instance-name\" and \"instance-index\" flags were provided, using \"instance-name\"")
}

instance, err := selectInstance(config)
instanceConfig, err := selectInstance(config)
if err != nil {
return err
}

runnerConfig, err := generateRunnerConfigFromInstance(instance, config)
runnerConfig, err := generateRunnerConfigFromInstance(instanceConfig, config)
if err != nil {
return err
}

perfRunner = perf.New(runnerConfig)
configYaml, err := yaml.Marshal(instanceConfig)
if err != nil {
return err
}

perfRunner = perf.New(runnerConfig, util.NewReportForTestInstance(string(configYaml), instanceName))
httpServer = server.NewHttpServer()

return nil
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hyperledger/firefly v1.2.0 h1:No82vzsur3TODU0giIECDcMnWQ/8BRGoYo7QK/avr4A=
github.com/hyperledger/firefly v1.2.0/go.mod h1:tmpTfSjX/NIa7xHTtTb36S48X9+3nNutY7ZxLt3lgCU=
github.com/hyperledger/firefly-common v1.2.13 h1:4pGL8LusXoijeoxM9J36fzBq4jvZpZbGjpQqgempXMk=
github.com/hyperledger/firefly-common v1.2.13/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM=
github.com/hyperledger/firefly-common v1.2.14 h1:HON9GJZXvrL0l2AG5DWHSGiBh05hElgFS5lm1OPR83M=
github.com/hyperledger/firefly-common v1.2.14/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM=
github.com/hyperledger/firefly-common v1.2.15 h1:WdNB65IJvIyiOhVW3nxB3sQKqtJbdJ7ie0PJIM11CSU=
github.com/hyperledger/firefly-common v1.2.15/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM=
github.com/hyperledger/firefly-common v1.2.16 h1:cVSaxKycOb+/oT2wExbrzxr68aVKQObeBOLaiJ0mTLg=
github.com/hyperledger/firefly-common v1.2.16/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
6 changes: 3 additions & 3 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type InstanceConfig struct {
MaxTimePerAction time.Duration `json:"maxTimePerAction,omitempty" yaml:"maxTimePerAction,omitempty"`
MaxActions int64 `json:"maxActions,omitempty" yaml:"maxActions,omitempty"`
RampLength time.Duration `json:"rampLength,omitempty" yaml:"rampLength,omitempty"`
SkipMintConfirmations bool `json:"skipMintConfirmations,omitempty" yaml:"skipMintConfirmations,omitempty"`
SkipMintConfirmations bool `json:"skipMintConfirmations" yaml:"skipMintConfirmations"`
DelinquentAction string `json:"delinquentAction,omitempty" yaml:"delinquentAction,omitempty"`
PerWorkerSigningKeyPrefix string `json:"perWorkerSigningKeyPrefix,omitempty" yaml:"perWorkerSigningKeyPrefix,omitempty"`
}
Expand Down Expand Up @@ -121,8 +121,8 @@ type TokenConfig struct {

type ContractOptions struct {
Address string `json:"address" yaml:"address"`
Channel string `json:"channel" yaml:"channel"`
Chaincode string `json:"chaincode" yaml:"chaincode"`
Channel string `json:"channel,omitempty" yaml:"channel,omitempty"`
Chaincode string `json:"chaincode,omitempty" yaml:"chaincode,omitempty"`
}

type FireFlyWsConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/perf/blob_broadcast_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (tc *blobBroadcast) IDType() TrackingIDType {
return TrackingIDTypeMessageID
}

func (tc *blobBroadcast) RunOnce() (string, error) {
func (tc *blobBroadcast) RunOnce(iterationCount int) (string, error) {

blob, hash := tc.generateBlob(big.NewInt(1024))
dataID, err := tc.uploadBlob(blob, hash, tc.pr.client.BaseURL)
Expand Down
2 changes: 1 addition & 1 deletion internal/perf/blob_private_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (tc *blobPrivate) IDType() TrackingIDType {
return TrackingIDTypeMessageID
}

func (tc *blobPrivate) RunOnce() (string, error) {
func (tc *blobPrivate) RunOnce(iterationCount int) (string, error) {

blob, hash := tc.generateBlob(big.NewInt(1024))
dataID, err := tc.uploadBlob(blob, hash, tc.pr.client.BaseURL)
Expand Down
2 changes: 1 addition & 1 deletion internal/perf/broadcast_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (tc *broadcast) IDType() TrackingIDType {
return TrackingIDTypeMessageID
}

func (tc *broadcast) RunOnce() (string, error) {
func (tc *broadcast) RunOnce(iterationCount int) (string, error) {

payload := fmt.Sprintf(`{
"data":[
Expand Down
6 changes: 2 additions & 4 deletions internal/perf/custom_ethereum_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

type customEthereum struct {
testBase
iteration int
}

func newCustomEthereumTestWorker(pr *perfRunner, workerID int, actionsPerLoop int) TestCase {
Expand All @@ -51,8 +50,8 @@ func (tc *customEthereum) IDType() TrackingIDType {
return TrackingIDTypeWorkerNumber
}

func (tc *customEthereum) RunOnce() (string, error) {
idempotencyKey := tc.pr.getIdempotencyKey(tc.workerID, tc.iteration)
func (tc *customEthereum) RunOnce(iterationCount int) (string, error) {
idempotencyKey := tc.pr.getIdempotencyKey(tc.workerID, iterationCount)
invokeOptionsJSON := ""
if tc.pr.cfg.InvokeOptions != nil {
b, err := json.Marshal(tc.pr.cfg.InvokeOptions)
Expand Down Expand Up @@ -106,6 +105,5 @@ func (tc *customEthereum) RunOnce() (string, error) {
return "", fmt.Errorf("Error invoking contract [%d]: %s (%+v)", resStatus(res), err, &resError)
}
}
tc.iteration++
return strconv.Itoa(tc.workerID), nil
}
6 changes: 2 additions & 4 deletions internal/perf/custom_fabric_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

type customFabric struct {
testBase
iteration int
}

func newCustomFabricTestWorker(pr *perfRunner, workerID int, actionsPerLoop int) TestCase {
Expand All @@ -50,8 +49,8 @@ func (tc *customFabric) IDType() TrackingIDType {
return TrackingIDTypeWorkerNumber
}

func (tc *customFabric) RunOnce() (string, error) {
idempotencyKey := tc.pr.getIdempotencyKey(tc.workerID, tc.iteration)
func (tc *customFabric) RunOnce(iterationCount int) (string, error) {
idempotencyKey := tc.pr.getIdempotencyKey(tc.workerID, iterationCount)
invokeOptionsJSON := ""
if tc.pr.cfg.InvokeOptions != nil {
b, err := json.Marshal(tc.pr.cfg.InvokeOptions)
Expand Down Expand Up @@ -143,6 +142,5 @@ func (tc *customFabric) RunOnce() (string, error) {
if err != nil || res.IsError() {
return "", fmt.Errorf("Error invoking contract [%d]: %s (%+v)", resStatus(res), err, &resError)
}
tc.iteration++
return strconv.Itoa(tc.workerID), nil
}
Loading