apm-agent-python icon indicating copy to clipboard operation
apm-agent-python copied to clipboard

Test failures when running on K8s pods or docker containers locally

Open v1v opened this issue 3 years ago • 1 comments

I'm running tests/scripts/run_tests.sh with the WEBFRAMEWORK=none using the container python:3.8

=================================== FAILURES ===================================
_________________ test_file_is_readable_validator_not_readable _________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_file_is_readable_validato2')

    @pytest.mark.skipif(platform.system() == "Windows", reason="os.access() doesn't seem to work as we expect on Windows")
    def test_file_is_readable_validator_not_readable(tmpdir):
        p = tmpdir.join("nonreadable")
        p.write("")
        os.chmod(p.strpath, stat.S_IWRITE)
        validator = FileIsReadableValidator()
        with pytest.raises(ConfigurationError) as e:
>           validator(p.strpath, "path")
E           Failed: DID NOT RAISE <class 'elasticapm.conf.ConfigurationError'>

e          = <ExceptionInfo for raises contextmanager>
p          = local('/tmp/pytest-of-root/pytest-0/test_file_is_readable_validato2/nonreadable')
tmpdir     = local('/tmp/pytest-of-root/pytest-0/test_file_is_readable_validato2')
validator  = <elasticapm.conf.FileIsReadableValidator object at 0x7f65f00c29a0>

tests/config/tests.py:287: Failed
=============================== warnings summary ===============================
tests/client/transaction_tests.py::test_transaction_span_stack_trace_min_duration_overrides_old_config
tests/client/transaction_tests.py::test_transaction_span_stack_trace_min_duration_overrides_old_config
tests/client/transaction_tests.py::test_transaction_span_stack_trace_min_duration_overrides_old_config
tests/client/transaction_tests.py::test_transaction_span_stack_trace_min_duration_overrides_old_config
  /code/elasticapm/traces.py:909: DeprecationWarning: `span_frames_min_duration` is deprecated. Please use `span_stack_trace_min_duration`.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/config/tests.py::test_file_is_readable_validator_not_readable - ...
============ 1 failed, 685 passed, 50 skipped, 4 warnings in 49.70s ============
make: *** [Makefile:14: test] Error 1

A similar error for other different python versions: 3.6, 3.7, 3.9 and 3.10

You can reproduce the error with the below command that runs in one of the docker images I've created for testing skaffold:

docker run --rm -ti docker.elastic.co/beats-dev/apm-agent-python-3_10:v6.12.0-19-gdf6fc75d-dirty@sha256:ad548ceef42ed963c373b0b28ab3b3d33ac016e886fe82d2fce5d8443f753783 /bin/bash -c "WEBFRAMEWORK=none tests/scripts/run_tests.sh"

The docker image content:

ARG VERSION
FROM python:${VERSION}
WORKDIR /code
ADD . .
ENV WEBFRAMEWORK=none

v1v avatar Oct 05 '22 10:10 v1v

I guess the default docker image requires some further configuration as done in the current dockerfile in the tests folder.

v1v avatar Oct 05 '22 15:10 v1v