Granulate / gprofiler

gProfiler is a system-wide profiler, combining multiple sampling profilers to produce unified visualization of what your CPU is spending time on.
https://profiler.granulate.io
Apache License 2.0
746 stars 54 forks source link

tests: java java_attach_socket_missing fail on aarch64 #722

Open pfilipko1 opened 1 year ago

pfilipko1 commented 1 year ago

test:

FAILED tests/test_java.py::test_java_attach_socket_missing[True] - assert 18 == 1

Output:

application_pid = 71321, profiler_state = <gprofiler.profiler_state.ProfilerState object at 0xffff8049b3d0>

    @pytest.mark.parametrize("in_container", [True])  # only in container is enough
    def test_java_attach_socket_missing(
        application_pid: int,
        profiler_state: ProfilerState,
    ) -> None:
        """
        Tests that we get the proper JattachMissingSocketException when the attach socket is deleted.
        """
        with make_java_profiler(
            profiler_state,
            duration=1,
        ) as profiler:
            snapshot_pid_profile(profiler, application_pid)

            # now the attach socket is created, remove it
            Path(f"/proc/{application_pid}/root/tmp/.java_pid{get_process_nspid(application_pid)}").unlink()

            profile = snapshot_pid_profile(profiler, application_pid)
>           assert len(profile.stacks) == 1
E           assert 18 == 1
E             +18
E             -1

tests/test_java.py:594: AssertionError
============================================================================================================================= warnings summary ==============================================================================================================================test_java.py: 71 warnings
  /usr/local/lib/python3.10/dist-packages/docker/utils/utils.py:52: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    s1 = StrictVersion(v1)

test_java.py: 71 warnings
  /usr/local/lib/python3.10/dist-packages/docker/utils/utils.py:53: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    s2 = StrictVersion(v2)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
pfilipko1 commented 1 year ago

When looking for nspid, status file does not provide correct .java_pid number, and there are multiple ones.

Path(f"/proc/{application_pid}/root/tmp/.java_pid{get_process_nspid(application_pid)}").unlink()

This seems to be a problem with certain jvms (found using openjdk:342 image), so I would consider closing the issue.

Jongy commented 1 year ago

As we talked - this "problem" is because we test gprofiler's behavior against old JVM impls who do not restore the socket after deletion :)

Did you try using an older JVM and now the problem is gone? If so, the ticket can be closed (if https://github.com/Granulate/gprofiler/pull/716 does not xfail those relevant tests).