Skip to content

Commit

Permalink
update-tests (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed Jun 26, 2023
2 parents 8faa45f + 1a94b27 commit f74aa88
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
27 changes: 27 additions & 0 deletions k6/issuance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import http from 'k6/http';
import { check } from 'k6';

export const options = {
thresholds: {
http_req_failed: ['rate==0'], // not a single http request may fail
http_req_duration: ['p(95)<10'], // 95% of requests have to be below 10ms
checks: ['rate==1'], // all checks must pass
},
vus: 24,
duration: '60s',
};

export default function () {
const payload = `{"templateId":"VerifiableId","config":{"issuerDid":"did:key:z6Mkr6T1hhzQRt3ySK4SxMQAAgxNUprhx8VYZwk6nyHeN1kQ","subjectDid":"did:key:z6Mkr6T1hhzQRt3ySK4SxMQAAgxNUprhx8VYZwk6nyHeN1kQ"}}`

const res = http.post('http://127.0.0.1:7001/v1/credentials/issue', payload, {
headers: {
'Content-Type': 'application/json',
},
});

check(res, {
'is status 200': (r) => r.status === 200,
'verify JWT': (r) => r.body.startsWith("ey")
})
}
2 changes: 1 addition & 1 deletion src/main/kotlin/id/walt/cli/did/DidCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CreateDidCommand : CliktCommand(
else -> CryptoService.getService().generateKey(KeyAlgorithm.EdDSA_Ed25519).id
}

echo("Creating did:${method} (key: ${keyId})")
echo("Creating did:${method.method} (key: ${keyId})")

val did = when (method) {
is WebMethodOption -> DidService.create(web, keyId, DidWebCreateOptions((method as WebMethodOption).domain, (method as WebMethodOption).path))
Expand Down
19 changes: 11 additions & 8 deletions src/test/kotlin/id/walt/Performance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import id.walt.signatory.ProofType
import id.walt.signatory.Signatory
import id.walt.test.getTemplate
import io.kotest.core.spec.style.StringSpec
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlin.system.measureTimeMillis
class Performance : StringSpec({
ServiceMatrix("service-matrix.properties")
val issuerWebDid: String = DidService.create(DidMethod.web)
val issuerWebDid: String = DidService.create(DidMethod.key)
//val credentialService: JwtCredentialService = JwtCredentialService.getService()
val signatory = Signatory.getService()
Expand All @@ -28,13 +25,19 @@ class Performance : StringSpec({
template.issuer = W3CIssuer(issuerWebDid)
template.credentialSubject!!.id = issuerWebDid // self signed
println("Warm up")
repeat(100) {
signatory.issue("VerifiableId", ProofConfig(issuerDid = issuerWebDid, proofType = ProofType.JWT))
}
"Issue 1" {
val jobs = ArrayList<Job>()
repeat(100000) {
println("Starting issuance...")
repeat(1_000_000) {
jobs.add(GlobalScope.launch {
println("" + measureTimeMillis {
signatory.issue("VerifiableId", ProofConfig(issuerDid = issuerWebDid, proofType = ProofType.JWT))
} + " ms")
/*println("" + measureTimeMillis {*/
signatory.issue("VerifiableId", ProofConfig(issuerDid = issuerWebDid, proofType = ProofType.JWT))
/*} + " ms")*/
})
}
Expand Down

0 comments on commit f74aa88

Please sign in to comment.