chore_: rename integration tests to functional tests (#5908)
This commit is contained in:
parent
04784d18a0
commit
ae2ec8f369
|
@ -101,13 +101,13 @@ test-bob/
|
||||||
# Nix
|
# Nix
|
||||||
/.nix-gcroots/
|
/.nix-gcroots/
|
||||||
|
|
||||||
# integration-tests
|
# functional tests
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
.envrc
|
.envrc
|
||||||
report/results.xml
|
report/results.xml
|
||||||
integration-tests/coverage
|
tests-functional/coverage
|
||||||
integration-tests/reports
|
tests-functional/reports
|
||||||
integration-tests/*.log
|
tests-functional/*.log
|
||||||
|
|
|
@ -71,7 +71,7 @@ Once a feature has undergone testing and is ready for production use, the featur
|
||||||
Test coverage is vital for ensuring the stability and reliability of our project. Follow these guidelines:
|
Test coverage is vital for ensuring the stability and reliability of our project. Follow these guidelines:
|
||||||
|
|
||||||
1. Before submitting a PR, check the existing test coverage for the modified or new code.
|
1. Before submitting a PR, check the existing test coverage for the modified or new code.
|
||||||
2. Ensure that the new code is covered by relevant unit tests, integration tests, or other appropriate testing methods.
|
2. Ensure that the new code is covered by relevant unit, integration and/or functional tests, or other appropriate testing methods.
|
||||||
3. If modifying existing code, update or add tests to cover the changes.
|
3. If modifying existing code, update or add tests to cover the changes.
|
||||||
4. If adding new features, include tests that demonstrate the correct functionality and handle edge cases.
|
4. If adding new features, include tests that demonstrate the correct functionality and handle edge cases.
|
||||||
|
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -399,6 +399,11 @@ test-e2e: ##@tests Run e2e tests
|
||||||
test-e2e-race: export GOTEST_EXTRAFLAGS=-race
|
test-e2e-race: export GOTEST_EXTRAFLAGS=-race
|
||||||
test-e2e-race: test-e2e ##@tests Run e2e tests with -race flag
|
test-e2e-race: test-e2e ##@tests Run e2e tests with -race flag
|
||||||
|
|
||||||
|
test-functional: export FUNCTIONAL_TESTS_DOCKER_UID ?= $(call sh, id -u)
|
||||||
|
test-functional: export FUNCTIONAL_TESTS_REPORT_CODECOV ?= false
|
||||||
|
test-functional:
|
||||||
|
@./_assets/scripts/run_functional_tests.sh
|
||||||
|
|
||||||
canary-test: node-canary
|
canary-test: node-canary
|
||||||
# TODO: uncomment that!
|
# TODO: uncomment that!
|
||||||
#_assets/scripts/canary_test_mailservers.sh ./config/cli/fleet-eth.prod.json
|
#_assets/scripts/canary_test_mailservers.sh ./config/cli/fleet-eth.prod.json
|
||||||
|
@ -505,15 +510,9 @@ build-verif-proxy-wrapper:
|
||||||
test-verif-proxy-wrapper:
|
test-verif-proxy-wrapper:
|
||||||
CGO_CFLAGS="$(CGO_CFLAGS)" go test -v github.com/status-im/status-go/rpc -tags gowaku_skip_migrations,nimbus_light_client -run ^TestProxySuite$$ -testify.m TestRun -ldflags $(LDFLAGS)
|
CGO_CFLAGS="$(CGO_CFLAGS)" go test -v github.com/status-im/status-go/rpc -tags gowaku_skip_migrations,nimbus_light_client -run ^TestProxySuite$$ -testify.m TestRun -ldflags $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
run-integration-tests: export INTEGRATION_TESTS_DOCKER_UID ?= $(call sh, id -u)
|
|
||||||
run-integration-tests: export INTEGRATION_TESTS_REPORT_CODECOV ?= false
|
|
||||||
run-integration-tests:
|
|
||||||
@./_assets/scripts/run_integration_tests.sh
|
|
||||||
|
|
||||||
run-anvil: SHELL := /bin/sh
|
run-anvil: SHELL := /bin/sh
|
||||||
run-anvil:
|
run-anvil:
|
||||||
docker-compose -f integration-tests/docker-compose.anvil.yml up --remove-orphans
|
docker-compose -f tests-functional/docker-compose.anvil.yml up --remove-orphans
|
||||||
|
|
||||||
codecov-validate: SHELL := /bin/sh
|
codecov-validate: SHELL := /bin/sh
|
||||||
codecov-validate:
|
codecov-validate:
|
||||||
|
|
|
@ -31,7 +31,7 @@ RUN mkdir -p /static/configs
|
||||||
|
|
||||||
COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/$build_target /usr/local/bin/
|
COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/$build_target /usr/local/bin/
|
||||||
COPY --from=builder /go/src/github.com/status-im/status-go/static/keys/* /static/keys/
|
COPY --from=builder /go/src/github.com/status-im/status-go/static/keys/* /static/keys/
|
||||||
COPY --from=builder /go/src/github.com/status-im/status-go/integration-tests/config.json /static/configs/
|
COPY --from=builder /go/src/github.com/status-im/status-go/tests-functional/config.json /static/configs/
|
||||||
|
|
||||||
RUN ln -s /usr/local/bin/$build_target /usr/local/bin/entrypoint
|
RUN ln -s /usr/local/bin/$build_target /usr/local/bin/entrypoint
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ pipeline {
|
||||||
description: 'Name of branch to build.'
|
description: 'Name of branch to build.'
|
||||||
)
|
)
|
||||||
booleanParam(
|
booleanParam(
|
||||||
name: 'INTEGRATION_TESTS_REPORT_CODECOV',
|
name: 'FUNCTIONAL_TESTS_REPORT_CODECOV',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
description: 'Should the job report test coverage to Codecov?'
|
description: 'Should the job report test coverage to Codecov?'
|
||||||
)
|
)
|
||||||
|
@ -36,7 +36,7 @@ pipeline {
|
||||||
|
|
||||||
/* Hack-fix for params not being set in env on first job run. */
|
/* Hack-fix for params not being set in env on first job run. */
|
||||||
BRANCH = "${params.BRANCH}"
|
BRANCH = "${params.BRANCH}"
|
||||||
INTEGRATION_TESTS_REPORT_CODECOV = "${params.INTEGRATION_TESTS_REPORT_CODECOV}"
|
FUNCTIONAL_TESTS_REPORT_CODECOV = "${params.FUNCTIONAL_TESTS_REPORT_CODECOV}"
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
@ -48,7 +48,7 @@ pipeline {
|
||||||
variable: 'CODECOV_TOKEN'
|
variable: 'CODECOV_TOKEN'
|
||||||
),
|
),
|
||||||
]) {
|
]) {
|
||||||
nix.shell('make run-integration-tests', pure: false)
|
nix.shell('make test-functional', pure: false)
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ pipeline {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
archiveArtifacts(
|
archiveArtifacts(
|
||||||
artifacts: 'integration-tests/reports/*.xml, integration-tests/*.log, integration-tests/coverage/coverage.html',
|
artifacts: 'tests-functional/reports/*.xml, tests-functional/*.log, tests-functional/coverage/coverage.html',
|
||||||
allowEmptyArchive: true,
|
allowEmptyArchive: true,
|
||||||
)
|
)
|
||||||
junit(
|
junit(
|
||||||
testResults: 'integration-tests/reports/*.xml',
|
testResults: 'tests-functional/reports/*.xml',
|
||||||
skipOldReports: true,
|
skipOldReports: true,
|
||||||
skipPublishingChecks: true,
|
skipPublishingChecks: true,
|
||||||
skipMarkingBuildUnstable: true,
|
skipMarkingBuildUnstable: true,
|
||||||
|
|
|
@ -6,9 +6,9 @@ GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||||
source "${GIT_ROOT}/_assets/scripts/colors.sh"
|
source "${GIT_ROOT}/_assets/scripts/colors.sh"
|
||||||
source "${GIT_ROOT}/_assets/scripts/codecov.sh"
|
source "${GIT_ROOT}/_assets/scripts/codecov.sh"
|
||||||
|
|
||||||
echo -e "${GRN}Running integration tests${RST}"
|
echo -e "${GRN}Running functional tests${RST}"
|
||||||
|
|
||||||
root_path="${GIT_ROOT}/integration-tests"
|
root_path="${GIT_ROOT}/tests-functional"
|
||||||
coverage_reports_path="${root_path}/coverage"
|
coverage_reports_path="${root_path}/coverage"
|
||||||
binary_coverage_reports_path="${coverage_reports_path}/binary"
|
binary_coverage_reports_path="${coverage_reports_path}/binary"
|
||||||
merged_coverage_reports_path="${coverage_reports_path}/merged"
|
merged_coverage_reports_path="${coverage_reports_path}/merged"
|
||||||
|
@ -25,7 +25,7 @@ mkdir -p "${test_results_path}"
|
||||||
|
|
||||||
all_compose_files="-f ${root_path}/docker-compose.anvil.yml -f ${root_path}/docker-compose.test.status-go.yml"
|
all_compose_files="-f ${root_path}/docker-compose.anvil.yml -f ${root_path}/docker-compose.test.status-go.yml"
|
||||||
|
|
||||||
# Run integration tests
|
# Run functional tests
|
||||||
echo -e "${GRN}Running tests${RST}, HEAD: $(git rev-parse HEAD)"
|
echo -e "${GRN}Running tests${RST}, HEAD: $(git rev-parse HEAD)"
|
||||||
docker-compose ${all_compose_files} up -d --build --remove-orphans
|
docker-compose ${all_compose_files} up -d --build --remove-orphans
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ docker-compose ${all_compose_files} logs status-go > "${root_path}/statusd.log"
|
||||||
docker-compose ${all_compose_files} logs status-go-no-funds > "${root_path}/statusd-no-funds.log"
|
docker-compose ${all_compose_files} logs status-go-no-funds > "${root_path}/statusd-no-funds.log"
|
||||||
|
|
||||||
# Retrieve exit code
|
# Retrieve exit code
|
||||||
exit_code=$(docker inspect integration-tests_tests-rpc_1 -f '{{.State.ExitCode}}');
|
exit_code=$(docker inspect tests-functional_tests-rpc_1 -f '{{.State.ExitCode}}');
|
||||||
|
|
||||||
# Cleanup containers
|
# Cleanup containers
|
||||||
echo -e "${GRN}Removing docker containers${RST}"
|
echo -e "${GRN}Removing docker containers${RST}"
|
||||||
|
@ -56,7 +56,7 @@ go tool covdata textfmt -i="${merged_coverage_reports_path}" -o="${full_coverage
|
||||||
convert_coverage_to_html "${full_coverage_profile}" "${coverage_reports_path}/coverage.html"
|
convert_coverage_to_html "${full_coverage_profile}" "${coverage_reports_path}/coverage.html"
|
||||||
|
|
||||||
# Upload reports to Codecov
|
# Upload reports to Codecov
|
||||||
if [[ ${INTEGRATION_TESTS_REPORT_CODECOV} == 'true' ]]; then
|
if [[ ${FUNCTIONAL_TESTS_REPORT_CODECOV} == 'true' ]]; then
|
||||||
report_to_codecov "${test_results_path}/*.xml" "${full_coverage_profile}" "functional"
|
report_to_codecov "${test_results_path}/*.xml" "${full_coverage_profile}" "functional"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
- Prove that the functionality performs as described
|
- Prove that the functionality performs as described
|
||||||
- Can be falsified
|
- Can be falsified
|
||||||
- Are resistant to fuzzing
|
- Are resistant to fuzzing
|
||||||
- All new `integration tests` MUST BE validated via a minimum of 1000 tests.
|
- All new `functional tests` MUST BE validated via a minimum of 1000 tests.
|
||||||
- This can be achieved using the `-count` or `-test.count` flag with the test command eg: `-count 1000` / `-test.count 1000`
|
- This can be achieved using the `-count` or `-test.count` flag with the test command eg: `-count 1000` / `-test.count 1000`
|
||||||
- Where the CI can not support this work flow automatically, the developer MUST perform validation tests via local testing.
|
- Where the CI can not support this work flow automatically, the developer MUST perform validation tests via local testing.
|
||||||
- `TODO` Add link to issue for CI automation of validation test runs of new `integration tests`.
|
- `TODO` Add link to issue for CI automation of validation test runs of new `functional tests`.
|
||||||
- Ensuring that the test passes consistently every time gives confidence that the test is not flaky.
|
- Ensuring that the test passes consistently every time gives confidence that the test is not flaky.
|
||||||
|
|
||||||
## Flaky Tests
|
## Flaky Tests
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Integration tests for status-go
|
Functional tests for status-go
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
|
@ -14,28 +14,28 @@ Integration tests for status-go
|
||||||
|
|
||||||
* Install [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/)
|
* Install [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/)
|
||||||
* Install [Python 3.10.14](https://www.python.org/downloads/)
|
* Install [Python 3.10.14](https://www.python.org/downloads/)
|
||||||
* In `integration-tests` directory, run `pip install -r requirements.txt`
|
* In `./tests-functional`, run `pip install -r requirements.txt`
|
||||||
* **Optional (for test development)**: Use Python virtual environment for better dependency management. You can follow the guide [here](https://akrabat.com/creating-virtual-environments-with-pyenv/):
|
* **Optional (for test development)**: Use Python virtual environment for better dependency management. You can follow the guide [here](https://akrabat.com/creating-virtual-environments-with-pyenv/):
|
||||||
|
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
### Running dev RPC (anvil with contracts)
|
### Running dev RPC (anvil with contracts)
|
||||||
- In `integration-tests` run `docker compose -f docker-compose.anvil.yml up --remove-orphans --build`, as result:
|
- In `./tests-functional` run `docker compose -f docker-compose.anvil.yml up --remove-orphans --build`, as result:
|
||||||
* an [anvil](https://book.getfoundry.sh/reference/anvil/) container with ChainID 31337 exposed on `0.0.0.0:8545` will start running
|
* an [anvil](https://book.getfoundry.sh/reference/anvil/) container with ChainID 31337 exposed on `0.0.0.0:8545` will start running
|
||||||
* Status-im contracts will be deployed to the network
|
* Status-im contracts will be deployed to the network
|
||||||
|
|
||||||
### Run tests
|
### Run tests
|
||||||
- In `integration-tests` run `docker compose -f docker-compose.anvil.yml -f docker-compose.test.status-go.yml -f docker-compose.status-go.local.yml up --build --remove-orphans`, as result:
|
- In `./tests-functional` run `docker compose -f docker-compose.anvil.yml -f docker-compose.test.status-go.yml -f docker-compose.status-go.local.yml up --build --remove-orphans`, as result:
|
||||||
* a container with [status-go as daemon](https://github.com/status-im/status-go/issues/5175) will be created with APIModules exposed on `0.0.0.0:3333`
|
* a container with [status-go as daemon](https://github.com/status-im/status-go/issues/5175) will be created with APIModules exposed on `0.0.0.0:3333`
|
||||||
* status-go will use [anvil](https://book.getfoundry.sh/reference/anvil/) as RPCURL with ChainID 31337
|
* status-go will use [anvil](https://book.getfoundry.sh/reference/anvil/) as RPCURL with ChainID 31337
|
||||||
* all Status-im contracts will be deployed to the network
|
* all Status-im contracts will be deployed to the network
|
||||||
|
|
||||||
* In `integration-tests/tests` directory run `pytest -m wallet`
|
* In `./tests-functional/tests` directory run `pytest -m wallet`
|
||||||
|
|
||||||
## Implementation details
|
## Implementation details
|
||||||
|
|
||||||
- Integration tests are implemented in `integration-tests/tests` based on [pytest](https://docs.pytest.org/en/8.2.x/)
|
- Functional tests are implemented in `./tests-functional/tests` based on [pytest](https://docs.pytest.org/en/8.2.x/)
|
||||||
- Every test has two types of verifications:
|
- Every test has two types of verifications:
|
||||||
- `verify_is_valid_json_rpc_response()` checks for status code 200, non-empty response, JSON-RPC structure, presence of the `result` field, and expected ID.
|
- `verify_is_valid_json_rpc_response()` checks for status code 200, non-empty response, JSON-RPC structure, presence of the `result` field, and expected ID.
|
||||||
- `jsonschema.validate()` is used to check that the response contains expected data, including required fields and types. Schemas are stored in `/schemas/wallet_MethodName`
|
- `jsonschema.validate()` is used to check that the response contains expected data, including required fields and types. Schemas are stored in `/schemas/wallet_MethodName`
|
||||||
- New schemas can be generated using `integration-tests/schema_builder.py` by passing a response to the `CustomSchemaBuilder(schema_name).create_schema(response.json())` method, should be used only on test creation phase, please search `how to create schema:` to see an example in a test
|
- New schemas can be generated using `./tests-functional/schema_builder.py` by passing a response to the `CustomSchemaBuilder(schema_name).create_schema(response.json())` method, should be used only on test creation phase, please search `how to create schema:` to see an example in a test
|
|
@ -1,6 +1,6 @@
|
||||||
services:
|
services:
|
||||||
status-go:
|
status-go:
|
||||||
user: ${INTEGRATION_TESTS_DOCKER_UID}
|
user: ${FUNCTIONAL_TESTS_DOCKER_UID}
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: _assets/build/Dockerfile
|
dockerfile: _assets/build/Dockerfile
|
||||||
|
@ -32,7 +32,7 @@ services:
|
||||||
|
|
||||||
# TODO: Remove this duplication when implemented: https://github.com/status-im/status-go/issues/5803
|
# TODO: Remove this duplication when implemented: https://github.com/status-im/status-go/issues/5803
|
||||||
status-go-no-funds:
|
status-go-no-funds:
|
||||||
user: ${INTEGRATION_TESTS_DOCKER_UID}
|
user: ${FUNCTIONAL_TESTS_DOCKER_UID}
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: _assets/build/Dockerfile
|
dockerfile: _assets/build/Dockerfile
|
||||||
|
@ -59,7 +59,7 @@ services:
|
||||||
stop_signal: SIGINT
|
stop_signal: SIGINT
|
||||||
|
|
||||||
tests-rpc:
|
tests-rpc:
|
||||||
user: ${INTEGRATION_TESTS_DOCKER_UID}
|
user: ${FUNCTIONAL_TESTS_DOCKER_UID}
|
||||||
depends_on:
|
depends_on:
|
||||||
status-go:
|
status-go:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
Loading…
Reference in New Issue