Commit 04b55f57 authored by 35V LG84's avatar 35V LG84

it:test: enhance and add tests to TacklerTxnsGit

Add progress reporting, add 10x1E5 loop test with
performance reporting.
Signed-off-by: 35V LG84's avatar35V LG84 <35vlg84-x4e6b92@e257.fi>
parent 7945d0b1
Pipeline #60854840 passed with stage
in 10 minutes and 16 seconds
......@@ -21,7 +21,7 @@ import fi.e257.tackler.api.GitInputReference
import fi.e257.tackler.core.{Settings, TacklerException}
import org.scalatest.FunSpec
class TacklerTxnsGitTest extends FunSpec{
class TacklerTxnsGitTest extends FunSpec {
val cfg = ConfigFactory.parseString(
"""
......@@ -42,93 +42,144 @@ class TacklerTxnsGitTest extends FunSpec{
val settings = Settings(cfg)
describe("Git input") {
describe("Git storage system") {
/**
* test: ce2e6523-ee83-46e7-a767-441c5b9f2802
*/
it("handle ref with 10 (1E1) txns") {
val tt = new TacklerTxns(settings)
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E1"))
describe("Normal operations") {
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "4aa4e9797501c1aefc92f32dff30ab462dae5545")
case _ => assert(false)
/**
* test: ce2e6523-ee83-46e7-a767-441c5b9f2802
*/
it("handled ref with 10 (1E1) txns") {
val tt = new TacklerTxns(settings)
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E1"))
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "4aa4e9797501c1aefc92f32dff30ab462dae5545")
case _ => assert(false)
}
assert(txns.txns.size === 10)
}
assert(txns.txns.size === 10)
}
/**
* test: 074f5549-346c-4780-90a1-07d60ae0e79d
*/
it("handled ref with 100_000 (1E5) txns") {
val tt = new TacklerTxns(settings)
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E5"))
/**
* test: 074f5549-346c-4780-90a1-07d60ae0e79d
*/
it("handle ref with 100_000 (1E5) txns") {
val tt = new TacklerTxns(settings)
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E5"))
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "cb56fdcdd2b56d41fc08cc5af4a3b410896f03b5")
case _ => assert(false)
}
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "cb56fdcdd2b56d41fc08cc5af4a3b410896f03b5")
case _ => assert(false)
assert(txns.txns.size === 100000)
}
assert(txns.txns.size === 100000)
}
/**
* test: fae31eb0-bd4a-483e-9eb7-9e4c36e7f785
*/
val loops = 1000
it(s"survives looping (ref: txns-1E1) x ${loops} loops") {
val i = (1 to loops).map(_ => {
val tt = new TacklerTxns(settings)
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E1"))
describe("Test looping with 10 txns") {
val loops = 10000
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "4aa4e9797501c1aefc92f32dff30ab462dae5545")
case _ => assert(false)
/**
* test: fae31eb0-bd4a-483e-9eb7-9e4c36e7f785
*/
it(s"made ${loops} loops with txns-1E1") {
val loopCount = (1 to loops).foldLeft((0, 0)) { case (i, r) => {
val tt = new TacklerTxns(settings)
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E1"))
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "4aa4e9797501c1aefc92f32dff30ab462dae5545")
case _ => assert(false)
}
assert(txns.txns.size === 10)
val printRound = r / (loops / 10)
if (i._2 < printRound) {
System.err.println(f"Done: ${r}%10d of $loops loops")
(i._1 + 1, printRound)
} else {
(i._1 + 1, i._2)
}
}
}
assert(txns.txns.size === 10)
1
}).sum
assert(loopCount._1 === loops)
}
}
describe("Test looping with 100_000 txns") {
/**
* test: 33d85471-a04c-49b9-b7a0-9d7f7f5762eb
*/
it("made 10 loops with txns-1E5") {
assert(i === loops)
val loopCount = (1 to 10).foldLeft((0, 0.0)) { case (i, _) => {
val tt = new TacklerTxns(settings)
val tsStart = System.currentTimeMillis()
val txns = tt.git2Txns(TacklerTxns.gitReference("txns-1E5"))
val tsEnd = System.currentTimeMillis()
txns.metadata.get.items.head match {
case gitmd: GitInputReference => assert(gitmd.commit === "cb56fdcdd2b56d41fc08cc5af4a3b410896f03b5")
case _ => assert(false)
}
assert(txns.txns.size === 100000)
val txn_s = 100000.0 / ((tsEnd - tsStart) / 1000.0)
System.err.println(f"Done: ${i._1 + 1}%10d of 10 loops, ${txn_s}%.0f txn/s")
(i._1 + 1, i._2 + txn_s)
}
}
val txn_s_ave = loopCount._2 / 10
val txn_s_ref = 31000
System.err.println(f"On average: ${txn_s_ave}%.0f txn/s. " +
f"Reference system (laptop): ${txn_s_ref} txn/s (${txn_s_ave - txn_s_ref}%+.0f txn/s)")
assert(loopCount._1 === 10)
}
}
/**
* test: a6cfe3b6-feec-4422-afbf-faeca5baf752
*/
it("reports reasonable details in case of audit error") {
val auditCfg = ConfigFactory.parseString(
"""
|{
| auditing {
| hash = "SHA-256"
| txn-set-checksum = on
| }
|}
""".stripMargin)
.withFallback(cfg)
.resolve()
val auditSettings = Settings(auditCfg)
val tt = new TacklerTxns(auditSettings)
val errMsg =
"""GIT: Error while processing git object
| commit id: 63014ea235b23aa7330511a25bcba0b62cd33c6f
| object id: d87737611e7a2bc551117c77fadd06dbc2c848d8
| path: txns/2016/04/01/20160401T115935-25.txn
| msg : Configuration setting 'auditing.txn-set-checksum' is activated and there is txn without UUID.""".stripMargin
val ex = intercept[TacklerException]({
tt.git2Txns(TacklerTxns.gitReference("errs-1E2"))
})
assert(ex.message === errMsg)
describe("Error cases") {
/**
* test: a6cfe3b6-feec-4422-afbf-faeca5baf752
*/
it("reported reasonable details in case of audit error") {
val auditCfg = ConfigFactory.parseString(
"""
|{
| auditing {
| hash = "SHA-256"
| txn-set-checksum = on
| }
|}
""".stripMargin)
.withFallback(cfg)
.resolve()
val auditSettings = Settings(auditCfg)
val tt = new TacklerTxns(auditSettings)
val errMsg =
"""GIT: Error while processing git object
| commit id: 63014ea235b23aa7330511a25bcba0b62cd33c6f
| object id: d87737611e7a2bc551117c77fadd06dbc2c848d8
| path: txns/2016/04/01/20160401T115935-25.txn
| msg : Configuration setting 'auditing.txn-set-checksum' is activated and there is txn without UUID.""".stripMargin
val ex = intercept[TacklerException]({
tt.git2Txns(TacklerTxns.gitReference("errs-1E2"))
})
assert(ex.message === errMsg)
}
}
}
}
......@@ -12,14 +12,18 @@ link:https://gitlab.com/e257/accounting/tackler[GitLab / E257 / Accounting / Tac
== Building and testing
----
LC_ALL=C.UTF-8 sbt clean test it:test
LC_ALL=C.UTF-8 sbt clean compile
----
=== Running tests
----
LC_ALL=C.UTF-8 sbt test it:test
----
Some of the integration tests generate lots of output or take several minutes run.
Especially `cli/it:test` generates lots of output and `core/it:test` takes long time to run.
Especially `cli/it:test` generates lots of output and `core/it:test` takes few minutes to run.
It might be helpful to run tests selectively, especially in case of errors:
......@@ -34,8 +38,8 @@ Start `LC_ALL=C.UTF-8 sbt` and run on sbt shell:
==== Running integration tests
You could run integration tests all at once (`core/it:test` and `cli/it:test`) or step-by-step.
cli intergration tests (Dirsuite-tests) will generate supstantial amount of output.
You could run integration tests all at once (`core/it:test`, `cli/it:test`)
or by step-by-step. `core/it:test` contains some performance tests.
----
> core/it:test
......@@ -47,13 +51,14 @@ cli intergration tests (Dirsuite-tests) will generate supstantial amount of outp
== Generating binaries
sbt cli/assembly
----
sbt cli/assembly
----
== Code coverage
----
LC_ALL=C.UTF-8 sbt clean coveraOn test coverageAggregate
LC_ALL=C.UTF-8 sbt clean coverage test it:test && sbt coverageAggregate
----
== IntelliJ
......
......@@ -22,12 +22,15 @@ Tackler has *99* tracked features. For those 99 features, tackler has
over *500* test cases, tackler-cli is executed over *160* times by test setup,
and results are verified by over *400* reference reports.
=== Performance
Accounting Journal with size of *one hundred thousand* (1E5) transactions
is used with *unit tests*
(see: {gitlink}/core/src/test/scala/fi/e257/tackler/parser/TacklerTxnsGitTest.scala[TacklerTxnsGitTest]),
and Tackler is stress and performance tested with up to *one million* (1E6)
transactions test sets. See xref:./performance.adoc[Performance Overview]
for details.
is used with integration tests
(see: {gitlink}/core/src/it/scala/fi/e257/tackler/parser/TacklerTxnsGitTest.scala[TacklerTxnsGitTest])
and tackler is stress and performance tested with up to *one million* (1E6)
transactions test sets. On laptop, tackler can process over 30 000 txn/s.
See xref:./performance.adoc[Performance Overview] for details
or {gitlink}/docs/devel/build.adoc[test it yourself].
=== Tackler Test Tracking Database
......
......@@ -95,15 +95,19 @@ features:
- test:
id: ce2e6523-ee83-46e7-a767-441c5b9f2802
name: TacklerTxnsGitTest
desc: "handle ref with 1E3 txns"
desc: "handled ref with 10 (1E1) txns"
- test:
id: 074f5549-346c-4780-90a1-07d60ae0e79d
name: TacklerTxnsGitTest
desc: "handle ref with 1E5 txns"
desc: "handled ref with 100_000 (1E5) txns"
- test:
id: fae31eb0-bd4a-483e-9eb7-9e4c36e7f785
name: TacklerTxnsGitTest
desc: "survive looping"
desc: "made 10000 loops with txns-1E1"
- test:
id: 33d85471-a04c-49b9-b7a0-9d7f7f5762eb
name: TacklerTxnsGitTest
desc: "made 10 loops with txns-1E5"
- test:
id: c2f39ef7-c085-4ff4-af4d-85a50d0ee203
name: tests/core/ok/git-utf8-01.exec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment