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

chore: update stress test #930

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions test/bdd/stress_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ const (
)

var createLogCount int64
var createCount int64
var createSlowCount int64
var resolveCreateLogCount int64
var resolveCreateCount int64
var resolveCreateSlowCount int64
var updateLogCount int64
var updateCount int64
var updateSlowCount int64
var resolveUpdateLogCount int64
var resolveUpdateCount int64
var resolveUpdateSlowCount int64

// StressSteps is steps for orb stress BDD tests.
type StressSteps struct {
Expand Down Expand Up @@ -317,15 +325,21 @@ func (e *StressSteps) createConcurrentReq(domainsEnv, didNumsEnv, concurrencyEnv
}

fmt.Printf("Created did %d took: %s\n", didNums, createTimeStr)
fmt.Printf("Created did request that took more than 1000ms: %d/%d\n", createSlowCount, createCount)
fmt.Println("------")

fmt.Printf("Resolved anchor did %d took: %s\n", didNums, resolveTimeStr)
fmt.Printf("Resolved anchor did request that took more than 1000ms: %d/%d\n", resolveCreateSlowCount,
resolveCreateCount)
fmt.Println("------")

fmt.Printf("Updated did %d took: %s\n", didNums, updateTimeStr)
fmt.Printf("Updated did request that took more than 1000ms: %d/%d\n", updateSlowCount, updateCount)
fmt.Println("------")

fmt.Printf("Resolved updated did %d took: %s\n", didNums, resolveUpdateTimeStr)
fmt.Printf("Resolved updated did request that took more than 1000ms: %d/%d\n", resolveUpdateSlowCount,
resolveUpdateCount)
fmt.Println("------")

return nil
Expand Down Expand Up @@ -514,9 +528,12 @@ func (r *createDIDReq) Invoke() (interface{}, error) {
recoveryKeyPrivateKey, updateKeyPrivateKey, intermID, err = r.steps.createDID(r.verMethodsCreate,
uuid.New().URN(), r.vdr)

atomic.AddInt64(&createCount, 1)

endTime := time.Since(startTime)
if endTime.Milliseconds() > 100 {
logger.Errorf("request time for create DID taking more than 100ms %s:", endTime.String())
if endTime.Milliseconds() > 1000 {
atomic.AddInt64(&createSlowCount, 1)
logger.Errorf("request time for create DID taking more than 1000ms %s", endTime.String())
}

if err == nil {
Expand Down Expand Up @@ -568,9 +585,12 @@ func (r *updateDIDReq) Invoke() (interface{}, error) {

err := r.steps.updateDID(r.canonicalID, svcEndpoint, r.vdr, r.verMethodsCreate, r.verMethodsUpdate)

atomic.AddInt64(&updateCount, 1)

endTime := time.Since(startTime)
if endTime.Milliseconds() > 100 {
logger.Errorf("request time for update DID taking more than 100ms %s:", endTime.String())
if endTime.Milliseconds() > 1000 {
atomic.AddInt64(&updateSlowCount, 1)
logger.Errorf("request time for update DID taking more than 1000ms %s", endTime.String())
}

if err == nil {
Expand Down Expand Up @@ -616,9 +636,12 @@ func (r *resolveDIDReq) Invoke() (interface{}, error) {

docResolution, err = r.vdr.Read(r.intermID)

atomic.AddInt64(&resolveCreateCount, 1)

endTime := time.Since(startTime)
if endTime.Milliseconds() > 100 {
logger.Errorf("request time for resolve created DID taking more than 100ms %s:", endTime.String())
if endTime.Milliseconds() > 1000 {
atomic.AddInt64(&resolveCreateSlowCount, 1)
logger.Errorf("request time for resolve created DID taking more than 1000ms %s", endTime.String())
}

if err == nil && docResolution.DocumentMetadata.Method.Published {
Expand Down Expand Up @@ -675,9 +698,12 @@ func (r *resolveUpdatedDIDReq) Invoke() (interface{}, error) {

docResolution, err = r.vdr.Read(r.canonicalID)

atomic.AddInt64(&resolveUpdateCount, 1)

endTime := time.Since(startTime)
if endTime.Milliseconds() > 100 {
logger.Errorf("request time for resolve updated DID taking more than 100ms %s:", endTime.String())
if endTime.Milliseconds() > 1000 {
atomic.AddInt64(&resolveUpdateSlowCount, 1)
logger.Errorf("request time for resolve updated DID taking more than 1000ms %s", endTime.String())
}

if err == nil && docResolution.DIDDocument.Service[0].ServiceEndpoint == r.svcEndpoint {
Expand Down