Skip to content

Commit

Permalink
test: Add torii api tests (hyperledger-iroha#4564)
Browse files Browse the repository at this point in the history
* test: add torii api tests

Signed-off-by: alexstroke <[email protected]>

* test: corrections for bug reports in github

Signed-off-by: alexstroke <[email protected]>

* test: optimize json for /scheme endpoint

Signed-off-by: alexstroke <[email protected]>

* test: add linters

Signed-off-by: alexstroke <[email protected]>

---------

Signed-off-by: alexstroke <[email protected]>
  • Loading branch information
AlexStroke authored May 23, 2024
1 parent 4396006 commit fad3e0c
Show file tree
Hide file tree
Showing 27 changed files with 2,050 additions and 11 deletions.
108 changes: 108 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: "\U0001F41E Bug report:"
description: Submit a bug you found in Iroha
title: "[BUG] "
labels: [ "Bug" ]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this form! You may refer to the [contributing guide](https://github.com/hyperledger/iroha/blob/main/CONTRIBUTING.md#reporting-bugs) for further details on filling bug reports.
Please be aware that SDK issues belong to other repositories:
- JavaScript: [`iroha-javascript`](https://github.com/hyperledger/iroha-javascript)
- Java/Kotlin: [`iroha-java`](https://github.com/hyperledger/iroha-java)
- Python: [`iroha-python`](https://github.com/hyperledger/iroha-python)
- type: input
id: env
attributes:
label: OS and Environment
description: |
Which operating system did you use when you encountered the issue?
Did you build Iroha from the source code or pulled it from [Docker Hub](https://hub.docker.com/) or [Nix](https://search.nixos.org/packages) packages?
placeholder: Ubuntu, Docker Hub
validations:
required: true
- type: input
id: commit-hash
attributes:
label: GIT commit hash
description: |
What is the commit hash of your Iroha version?
You can use the `git rev-parse --short HEAD` command to retrieve it.
Note that older versions may have more bugs.
placeholder: 4936869d
validations:
required: true
- type: textarea
id: mwe
attributes:
label: Minimum working example / Steps to reproduce
description: |
Please share a minimal working code that allows us to reproduce the issue.
Make sure you enable [syntax highlighting](https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting).
value: |
```rust
fn main() {
}
```
validations:
required: true
- type: textarea
id: actual-behaviour
attributes:
label: Actual result
description: What is the result or behaviour you got?
placeholder: |
I get an error message when running Iroha:
Example error #123
validations:
required: true
- type: textarea
id: expected-behaviour
attributes:
label: Expected result
description: What is the result or behaviour you expected to get?
placeholder: I expected Iroha to run normally on bare-metal after building Iroha.
validations:
required: true
- type: textarea
id: json-logs
attributes:
label: Logs
description: |
Provide an output log in JSON format, so we could determine what caused the issue faster.
To configure a file path and level for logs, check the [reference documentation](https://github.com/hyperledger/iroha/blob/iroha2-dev/docs/source/references/config.md#logger) or [peer configuration](https://hyperledger.github.io/iroha-2-docs/guide/configure/peer-configuration.html#logger).
**Please** leave JSON [syntax highlighting](https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting) and [collapsed sections](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections) (`<details>` tag) enabled.
If the log indentation is broken, use the [js-beautify](https://beautifier.io/) service to format it.
value: |
<details>
<summary>Log contents</summary>
```json
Replace this text with a JSON log,
so it doesn't grow too large and has highlighting.
```
</details>
validations:
required: true
- type: input
id: who-can-help
attributes:
label: Who can help to reproduce?
description: |
If you figure out the right person to tag, your issue might be resolved faster.
You can use `git blame` or check the following list of people **you can tag** based on what the issue is connected to:
- Documentation issues: Ekaterina Mekhnetsova (`@outoftardis`)
- Quality Assurance (`@AlexStroke`)
- WASM: Marin Veršić (`@mversic`)
- Triggers: Daniil Polyakov (`@Arjentix`)
placeholder: "@Username ..."
- type: textarea
id: notes
attributes:
label: Notes
description: |
For example specify the type of LibC you're using (`GNU libc` or `musl libc`) and its version etc. Use the `ldd --version ldd` command to determine it.
placeholder: Any useful information
28 changes: 23 additions & 5 deletions .github/workflows/iroha2-dev-pr-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,37 @@ jobs:
image: hyperledger/iroha2-ci:nightly-2024-04-18
steps:
- uses: actions/checkout@v4
- name: Install dependencies using Poetry
- name: Install dependencies using Poetry for client_cli/pytests
working-directory: client_cli/pytests
run: |
poetry lock --no-update
poetry install
- name: Check code formatting with Black
- name: Install dependencies using Poetry for torii/pytests
working-directory: torii/pytests
run: |
poetry lock --no-update
poetry install
- name: Check code formatting with Black in client_cli/pytests
working-directory: client_cli/pytests
run: |
poetry run black --check .
- name: Run mypy (Type Checker)
- name: Check code formatting with Black in torii/pytests
working-directory: torii/pytests
run: |
poetry run black --check .
- name: Run mypy (Type Checker) in client_cli/pytests
working-directory: client_cli/pytests
run: |
poetry run mypy --explicit-package-bases .
- name: Run flake8 (Linter)
poetry run mypy --explicit-package-bases --ignore-missing-imports .
- name: Run mypy (Type Checker) in torii/pytests
working-directory: torii/pytests
run: |
poetry run mypy --explicit-package-bases --ignore-missing-imports .
- name: Run flake8 (Linter) in client_cli/pytests
working-directory: client_cli/pytests
run: |
poetry run flake8 . --max-line-length=110 --ignore=F401,W503,E203
- name: Run flake8 (Linter) in torii/pytests
working-directory: torii/pytests
run: |
poetry run flake8 . --max-line-length=110 --ignore=F401,W503,E203
13 changes: 11 additions & 2 deletions .github/workflows/iroha2-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- '**.json'
- '**.toml'
- '**.lock'
- '**.py'
- '.github/workflows/iroha2-dev-pr.yml'

concurrency:
Expand Down Expand Up @@ -94,7 +95,7 @@ jobs:
# This context specification is required
context: .

client-cli-tests:
torii-api-and-client-cli-tests:
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-04-18
Expand All @@ -112,7 +113,15 @@ jobs:
- name: Mark binaries as executable
run: |
chmod +x ${{ env.CLIENT_CLI_DIR }}
- name: Install dependencies using Poetry
- name: Install torii api dependencies using Poetry
working-directory: torii/pytests
run: |
poetry install
- name: Run torii api tests
working-directory: torii/pytests
run: |
poetry run pytest
- name: Install client cli dependencies using Poetry
working-directory: client_cli/pytests
run: |
poetry install
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ RUN pacman -Syu rustup mold musl rust-musl openssl libgit2 jq \
python python-pip --noconfirm --disable-download-timeout && \
curl -sSL https://install.python-poetry.org | python3 -

WORKDIR /client_cli/pytests
COPY /client_cli/pytests/pyproject.toml /client_cli/pytests/poetry.lock $WORKDIR
RUN poetry install

RUN rustup toolchain install nightly-2024-04-18-x86_64-unknown-linux-gnu
RUN rustup default nightly-2024-04-18-x86_64-unknown-linux-gnu
RUN rustup component add llvm-tools-preview clippy
Expand Down
30 changes: 30 additions & 0 deletions torii/pytests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Torii API Testing Project

This project is dedicated to automating the testing of the Torii API, which is part of the Iroha 2 blockchain framework.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

- Python 3.11+
- Poetry for Python package management

### Installation

First, use Poetry to install the dependencies:

```bash
poetry install
```

This command will create a virtual environment and install all the necessary dependencies.

### Running the Tests

To run the automated tests, use the following command:

```bash
poetry run pytest
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"logger": {
"type": "object",
"properties": {
"level": {
"type": "string",
"enum": ["TRACE", "DEBUG", "INFO", "WARN", "ERROR"]
}
},
"required": ["level"]
}
},
"required": ["logger"]
}
Loading

0 comments on commit fad3e0c

Please sign in to comment.