diff --git a/Makefile b/Makefile index 356f9dbe1..144a7f1dd 100644 --- a/Makefile +++ b/Makefile @@ -488,8 +488,8 @@ 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) -#run-integration-tests: SHELL := /bin/sh # Run not in nix-shell, we need codecov -run-integration-tests: export INTEGRATION_TESTS_DOCKER_UID ?= $(call sh, id -u $$USER) +#run-integration-tests: SHELL := /bin/sh # Run in nix-shell, we need codecov +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 diff --git a/_assets/scripts/codecov.sh b/_assets/scripts/codecov.sh index 022460334..217e85a0f 100755 --- a/_assets/scripts/codecov.sh +++ b/_assets/scripts/codecov.sh @@ -3,7 +3,7 @@ source "${GIT_ROOT}/_assets/scripts/colors.sh" report_to_codecov() { - # https://docs.codeclimate.com/docs/jenkins#jenkins-ci-builds + # https://go.dev/blog/integration-test-coverage echo -e "${GRN}Uploading coverage report to Codecov${RST}" local tests_report_wildcard="${1}" diff --git a/_assets/scripts/run_integration_tests.sh b/_assets/scripts/run_integration_tests.sh index 1b039aad9..e46cfff56 100755 --- a/_assets/scripts/run_integration_tests.sh +++ b/_assets/scripts/run_integration_tests.sh @@ -9,12 +9,6 @@ echo -e "${GRN}Running integration tests${RST}" root_path="${GIT_ROOT}/integration-tests" coverage_reports_path="${root_path}/coverage" test_results_path="${root_path}/reports" -log_file="${root_path}/tests.log" - -echo -e "${GRN}root_path:${RST} ${root_path}" -echo -e "${GRN}coverage_reports_path:${RST} ${coverage_reports_path}" -echo -e "${GRN}test_results_path:${RST} ${test_results_path}" -echo -e "${GRN}log_file:${RST} ${log_file}" # Create directories mkdir -p "${GIT_ROOT}/integration-tests/coverage" @@ -23,29 +17,24 @@ mkdir -p "${GIT_ROOT}/integration-tests/coverage" rm -rf "${coverage_reports_path}" rm -rf "${test_results_path}" +all_compose_files="-f ${root_path}/docker-compose.anvil.yml -f ${root_path}/docker-compose.test.status-go.yml" + # Run integration tests echo -e "${GRN}Running tests${RST}, HEAD: $(git rev-parse HEAD)" -docker-compose \ - -f ${root_path}/docker-compose.anvil.yml \ - -f ${root_path}/docker-compose.test.status-go.yml \ - up -d --build --remove-orphans > ${log_file} +docker-compose ${all_compose_files} up -d --build --remove-orphans # Save logs echo -e "${GRN}Saving logs${RST}" -docker-compose \ - -f ${root_path}/docker-compose.anvil.yml \ - -f ${root_path}/docker-compose.test.status-go.yml \ - logs -f tests-rpc > ${log_file} +docker-compose ${all_compose_files} logs -f tests-rpc > "${root_path}/tests-rpc.log" +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" # Retrieve exit code exit_code=$(docker inspect integration-tests_tests-rpc_1 -f '{{.State.ExitCode}}'); # Stop and remove containers echo -e "${GRN}Stopping docker containers${RST}" -docker-compose \ - -f ${root_path}/docker-compose.anvil.yml \ - -f ${root_path}/docker-compose.test.status-go.yml \ - down > ${log_file} +docker-compose ${all_compose_files} down # Early exit if tests failed if [[ "$exit_code" -ne 0 ]]; then @@ -54,12 +43,11 @@ fi # Prepare coverage reports binary_coverage_reports_path="${coverage_reports_path}/binary" -#merged_coverage_reports_path="${coverage_reports_path}/merged" -merged_coverage_reports_path="$(mktemp -d)" +merged_coverage_reports_path="${coverage_reports_path}/merged" full_coverage_profile="${coverage_reports_path}/coverage.out" # Clean merged reports directory -#mkdir -p "${merged_coverage_reports_path}" +mkdir -p "${merged_coverage_reports_path}" # Merge coverage reports go tool covdata merge -i="${binary_coverage_reports_path}" -o="${merged_coverage_reports_path}" @@ -69,6 +57,5 @@ go tool covdata textfmt -i="${merged_coverage_reports_path}" -o="${full_coverage # Upload reports to Codecov if [[ ${INTEGRATION_TESTS_REPORT_CODECOV} == 'true' ]]; then -# Docs: https://go.dev/blog/integration-test-coverage report_to_codecov "${test_results_path}/*.xml" "${full_coverage_profile}" "integration" fi diff --git a/integration-tests/docker-compose.test.status-go.yml b/integration-tests/docker-compose.test.status-go.yml index b61495aee..415aee5ed 100644 --- a/integration-tests/docker-compose.test.status-go.yml +++ b/integration-tests/docker-compose.test.status-go.yml @@ -1,5 +1,6 @@ services: status-go: + user: ${INTEGRATION_TESTS_DOCKER_UID} build: context: ../ dockerfile: _assets/build/Dockerfile @@ -7,7 +8,14 @@ services: build_tags: gowaku_no_rln build_target: statusd build_flags: -cover -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true" - entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test junk", "--password=Strong12345"] + entrypoint: [ + "statusd", + "--log", "DEBUG", + "-c", "/static/configs/config.json", + "--seed-phrase", "test test test test test test test test test test test junk", + "--password", "Strong12345", + "--dir", "/tmp/status-go-data", # Keep in sync with `config.json/DataDir` value. Later this arg not be needed. + ] ports: - 3333:3333 healthcheck: @@ -22,6 +30,7 @@ services: # TODO: Remove this duplication when implemented: https://github.com/status-im/status-go/issues/5803 status-go-no-funds: + user: ${INTEGRATION_TESTS_DOCKER_UID} build: context: ../ dockerfile: _assets/build/Dockerfile @@ -29,7 +38,13 @@ services: build_tags: gowaku_no_rln build_target: statusd build_flags: -cover -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true" - entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test takoe", "--password=Strong12345"] + entrypoint: [ + "statusd", + "-c", "/static/configs/config.json", + "--seed-phrase", "test test test test test test test test test test test takoe", + "--password", "Strong12345", + "--dir", "/tmp/status-go-data", # Keep in sync with `config.json/DataDir` value. Later this arg not be needed. + ] ports: - 3334:3333 healthcheck: diff --git a/integration-tests/pytest.ini b/integration-tests/pytest.ini index 68bb664ee..3247f8644 100644 --- a/integration-tests/pytest.ini +++ b/integration-tests/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = -s -v --tb=short --junitxml=results.xml +addopts = -s -v --tb=short markers = rpc