Skip to content

Commit b0ebbd3

Browse files
authored
[feat]: Allure reports in integration tests PoC (#190)
* [feat]: Allure reports in integration tests PoC Signed-off-by: Dmitry Balashov <[email protected]> * [fix]: lint, format, type errors Signed-off-by: Dmitry Balashov <[email protected]> * [docs]: extend docs Signed-off-by: Dmitry Balashov <[email protected]> * [docs]: typos Signed-off-by: Dmitry Balashov <[email protected]> --------- Signed-off-by: Dmitry Balashov <[email protected]>
1 parent d31c0f0 commit b0ebbd3

File tree

23 files changed

+898
-607
lines changed

23 files changed

+898
-607
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
},
2020
globals: {
2121
BigInt: true,
22+
globalThis: true
2223
},
2324
overrides: [
2425
{

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,9 @@ Each monorepo package might have its own scripts and tasks. You can find the pac
106106
> This package targets `hyperledger/iroha` at current `iroha2-lts` branch, which has a hash `b783f10fa7de26ed1fdd4c526bd162f8636f1a65`.
107107
108108
Put here a new Iroha 2 reference commit information.
109+
110+
### SDK Compatibility Matrix Tests
111+
112+
There are certain integration tests
113+
that are part of the [Compatibility Matrix](https://hyperledger.github.io/iroha-2-docs/reference/compatibility-matrix.html) endeavour.
114+
To read more about it, follow the [client Node integration tests](./packages/client/test/integration/test-node).

etc/jakefile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ namespace('test', () => {
105105
await $`pnpm --filter monorepo-crypto test`
106106
})
107107

108-
task('client-integration', ['build:all'], async () => {
108+
task('prepare-client-integration', ['build:all'])
109+
110+
task('client-integration', ['prepare-client-integration'], async () => {
109111
await $`pnpm --filter client test:integration`
110112
})
111113

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"tsx": "^3.12.2",
4444
"type-fest": "^3.9.0",
4545
"typescript": "^5.2.2",
46-
"vite": "^4.5.0",
47-
"vitest": "^0.34.6",
46+
"vite": "^5.1.5",
47+
"vitest": "^1.3.1",
4848
"zx": "^7.2.0"
4949
}
5050
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
allure-results
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
allure-results
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Client Node Integration Tests
2+
3+
This project is a collection of integration tests running from Node.js with actual Iroha peer.
4+
5+
## SDK Compatibility Matrix
6+
7+
Tests for [compatibility matrix](https://hyperledger.github.io/iroha-2-docs/reference/compatibility-matrix.html)
8+
are defined at [`compatibility.spec.ts`](./test/compatibility.spec.ts).
9+
10+
The easiest way to run tests:
11+
12+
```shell
13+
# run these commands anywhere in the repo
14+
15+
# install packages, once
16+
pnpm i
17+
18+
# prepare artifacts for tests, once
19+
pnpm jake test:prepare-client-integration
20+
21+
# run tests
22+
pnpm --filter client-test-node test
23+
```
24+
25+
Allure reports are stored after tests run at `./allure-results` directory.
26+
**Note:** these reports contain _all_ tests, not only compatibility tests results.
27+
So, be sure to filter the results by their metadata before submitting them to TestOps.

packages/client/test/integration/test-node/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
"name": "@iroha2/client-test-node",
33
"private": true,
44
"scripts": {
5-
"test": "cross-env DEBUG=@iroha2* vitest run main.spec"
5+
"test": "cross-env DEBUG=@iroha2* vitest run",
6+
"typecheck": "tsc --noEmit"
67
},
78
"devDependencies": {
89
"@iroha2/client": "workspace:^7.0.0",
910
"@iroha2/crypto-target-node": "workspace:^1.1.1",
1011
"@iroha2/test-configuration": "workspace:^",
1112
"@iroha2/test-peer": "workspace:^0.0.1",
13+
"allure-vitest": "^2.14.0",
1214
"cross-env": "^7.0.3",
1315
"fp-ts": "^2.13.1",
1416
"immer": "^9.0.19",
15-
"vite": "^4.5.0"
17+
"vite": "^5.1.5"
1618
}
1719
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* This file is for Compatibility Matrix tests, which assigns specific
3+
* Allure context tags.
4+
*/
5+
6+
import * as allure from 'allure-vitest'
7+
import { pipe } from 'fp-ts/function'
8+
import { describe, expect, test } from 'vitest'
9+
import { clientFactory, setupPeerTestsLifecycle } from './util'
10+
import { datamodel, sugar } from '@iroha2/data-model'
11+
12+
setupPeerTestsLifecycle()
13+
14+
// TODO: consider adding shared context for tests?
15+
// beforeEach(() => { ... })
16+
17+
// Read Allure API: https://allurereport.org/docs/vitest-reference/
18+
describe('Compatibility Matrix tests', () => {
19+
// Based on https://github.com/AlexStroke/iroha-java/blob/007a9ac55991cd8a2b519e62a10144156d9f8301/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/InstructionsTest.kt#L134
20+
test('register domain', async (ctx) => {
21+
await allure.feature(ctx, 'Domains')
22+
await allure.story(ctx, 'Account registers a domain')
23+
// TODO: add more Allure context
24+
25+
const DOMAIN_NAME = 'new_domain_name'
26+
27+
const { pre, client, getBlocksListener } = clientFactory()
28+
const blocks = await getBlocksListener()
29+
30+
await blocks.wait(async () => {
31+
await client.submitExecutable(
32+
pre,
33+
pipe(sugar.identifiable.newDomain(DOMAIN_NAME), sugar.instruction.register, sugar.executable.instructions),
34+
)
35+
})
36+
37+
const result = (
38+
await client.requestWithQueryBox(
39+
pre,
40+
datamodel.QueryBox(
41+
'FindDomainById',
42+
datamodel.FindDomainById({
43+
id: datamodel.Expression(
44+
'Raw',
45+
datamodel.Value('Id', datamodel.IdBox('DomainId', sugar.domainId(DOMAIN_NAME))),
46+
),
47+
}),
48+
),
49+
)
50+
)
51+
.as('Ok')
52+
.batch.enum.as('Identifiable')
53+
.enum.as('Domain')
54+
55+
expect(result.id.name).toEqual(DOMAIN_NAME)
56+
})
57+
})

packages/client/test/integration/test-node/test/main.spec.ts

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,14 @@
1-
import { Torii, type ToriiRequirementsForApiHttp, setCrypto } from '@iroha2/client'
2-
import { FREE_HEAP } from '@iroha2/crypto-core'
3-
import { crypto } from '@iroha2/crypto-target-node'
4-
import { type RustResult, Logger as ScaleLogger, datamodel, sugar, variant } from '@iroha2/data-model'
5-
import * as TestPeer from '@iroha2/test-peer'
1+
import { Torii } from '@iroha2/client'
2+
import { type RustResult, datamodel, sugar, variant } from '@iroha2/data-model'
63
import { CLIENT_CONFIG } from '@iroha2/test-configuration'
74
import { Seq } from 'immutable'
8-
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'vitest'
9-
import { delay } from '../../util'
10-
import { clientFactory, keyPair } from './test-util'
5+
import { describe, expect, test } from 'vitest'
6+
import { clientFactory, setupPeerTestsLifecycle } from './util'
117
import { pipe } from 'fp-ts/function'
128

13-
// for debugging convenience
14-
new ScaleLogger().mount()
15-
setCrypto(crypto)
9+
setupPeerTestsLifecycle()
1610

17-
let startedPeer: TestPeer.StartPeerReturn | null = null
18-
19-
async function killStartedPeer() {
20-
await startedPeer?.kill()
21-
startedPeer = null
22-
}
23-
24-
async function waitForGenesisCommitted(pre: ToriiRequirementsForApiHttp) {
25-
while (true) {
26-
const { blocks } = await Torii.getStatus(pre)
27-
if (blocks >= 1) return
28-
await delay(50)
29-
}
30-
}
31-
32-
// and now tests...
33-
34-
beforeAll(async () => {
35-
await TestPeer.clearAll()
36-
await TestPeer.prepareConfiguration()
37-
})
38-
39-
beforeEach(async () => {
40-
await TestPeer.clearPeerStorage()
41-
startedPeer = await TestPeer.startPeer()
42-
await waitForGenesisCommitted(clientFactory().pre)
43-
})
44-
45-
afterEach(async () => {
46-
await killStartedPeer()
47-
})
48-
49-
afterAll(async () => {
50-
keyPair.free()
51-
expect(FREE_HEAP.size).toEqual(0)
52-
})
53-
54-
// Actually it is already tested within `@iroha2/test-peer`
11+
// Actually, it is already tested within `@iroha2/test-peer`
5512
test('Peer is healthy', async () => {
5613
const { pre } = clientFactory()
5714

@@ -209,10 +166,6 @@ test('When querying for not existing domain, returns FindError', async () => {
209166
expect(result.as('Err').enum.as('QueryFailed').enum.as('Find').enum.as('AssetDefinition').name).toBe('XOR')
210167
})
211168

212-
test('Multisignature', async () => {
213-
await import('./multisignature')
214-
})
215-
216169
describe('Events API', () => {
217170
test('transaction-committed event is triggered after AddAsset instruction has been committed', async () => {
218171
const { pre, client } = clientFactory()

0 commit comments

Comments
 (0)