Page MenuHomePhabricator

[chronik] Add new endpoint to check chronik version
ClosedPublic

Authored by bytesofman on Oct 26 2023, 21:31.

Details

Reviewers
PiRK
Fabien
Group Reviewers
Restricted Project
Commits
rABC423262c39829: [chronik] Add new endpoint to check chronik version
Summary

Add new endpoint /chronik-info to check the version of the currently running chronik-client server

Test Plan

cmake .. -GNinja -DBUILD_BITCOIN_CHRONIK=ON
ninja check-functional

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bytesofman updated this revision to Diff 42825.

patch version

need to set up the unit test so it doesn't need to be manually changed every time the version changes

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stdout: -------
2023-10-26T21:48:25.153000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214357/chronik_chronik_info_238
2023-10-26T21:48:25.458000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 142, in main
    self.run_test()
  File "/work/test/functional/chronik_chronik_info.py", line 29, in run_test
    chronik.chronik_info().ok(),
AttributeError: 'ChronikClient' object has no attribute 'chronik_info'
2023-10-26T21:48:25.508000Z TestFramework (INFO): Stopping nodes
2023-10-26T21:48:25.660000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214357/chronik_chronik_info_238
2023-10-26T21:48:25.660000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214357/chronik_chronik_info_238/test_framework.log
2023-10-26T21:48:25.660000Z TestFramework (ERROR): 
2023-10-26T21:48:25.660000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214357/chronik_chronik_info_238' to consolidate all logs
2023-10-26T21:48:25.660000Z TestFramework (ERROR): 
2023-10-26T21:48:25.660000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-10-26T21:48:25.660000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-10-26T21:48:25.660000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stdout: -------
2023-10-26T21:50:49.555000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214614/chronik_chronik_info_238
2023-10-26T21:50:49.847000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 142, in main
    self.run_test()
  File "/work/test/functional/chronik_chronik_info.py", line 29, in run_test
    chronik.chronik_info().ok(),
AttributeError: 'ChronikClient' object has no attribute 'chronik_info'
2023-10-26T21:50:49.898000Z TestFramework (INFO): Stopping nodes
2023-10-26T21:50:49.999000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214614/chronik_chronik_info_238
2023-10-26T21:50:49.999000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214614/chronik_chronik_info_238/test_framework.log
2023-10-26T21:50:49.999000Z TestFramework (ERROR): 
2023-10-26T21:50:49.999000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_  _20231026_214614/chronik_chronik_info_238' to consolidate all logs
2023-10-26T21:50:49.999000Z TestFramework (ERROR): 
2023-10-26T21:50:49.999000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-10-26T21:50:49.999000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-10-26T21:50:49.999000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Update client.py, get version from code

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path('../../chronik/chronik-http/Cargo.toml').read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path('../../chronik/chronik-http/Cargo.toml').read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path("../../chronik/chronik-http/Cargo.toml").read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: abc_p2p_compactproofs.py ======

------- Stdout: -------
2023-10-26T22:14:53.043000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20231026_221348/abc_p2p_compactproofs_11
2023-10-26T22:14:53.539000Z TestFramework (INFO): Check we send a getavaproofs message to our avalanche outbound peers
2023-10-26T22:14:55.532000Z TestFramework (INFO): Check we send periodic getavaproofs message to some of our peers
2023-10-26T22:14:55.582000Z TestFramework (INFO): After the first avaproofs has been received, all the peers are requested periodically
2023-10-26T22:14:55.845000Z TestFramework (INFO): Empty avaproofs will not trigger any request
2023-10-26T22:14:55.846000Z TestFramework (INFO): Check we send a getavaproofs message to our manually connected peers that support avalanche
2023-10-26T22:14:57.268000Z TestFramework (INFO): Check the node responds to getavaproofs messages
2023-10-26T22:15:22.054000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
    def avapeer_connected():
        node_list = []
        try:
            node_list = node.getavalanchepeerinfo(proofid_hex)[0]["node_list"]
        except BaseException:
            pass

        return n.nodeid in node_list
'''
2023-10-26T22:15:22.616000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 142, in main
    self.run_test()
  File "/work/test/functional/abc_p2p_compactproofs.py", line 736, in run_test
    self.test_respond_getavaproofs()
  File "/work/test/functional/abc_p2p_compactproofs.py", line 288, in test_respond_getavaproofs
    p = get_ava_p2p_interface(self, node)
  File "/work/test/functional/test_framework/avatools.py", line 411, in get_ava_p2p_interface
    wait_until_helper(avapeer_connected, timeout=5)
  File "/work/test/functional/test_framework/util.py", line 298, in wait_until_helper
    raise AssertionError(
AssertionError: Predicate ''''
    def avapeer_connected():
        node_list = []
        try:
            node_list = node.getavalanchepeerinfo(proofid_hex)[0]["node_list"]
        except BaseException:
            pass

        return n.nodeid in node_list
''' not true after 5.0 seconds
2023-10-26T22:15:22.670000Z TestFramework (INFO): Stopping nodes
2023-10-26T22:15:29.062000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20231026_221348/abc_p2p_compactproofs_11
2023-10-26T22:15:29.062000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20231026_221348/abc_p2p_compactproofs_11/test_framework.log
2023-10-26T22:15:29.062000Z TestFramework (ERROR): 
2023-10-26T22:15:29.062000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20231026_221348/abc_p2p_compactproofs_11' to consolidate all logs
2023-10-26T22:15:29.062000Z TestFramework (ERROR): 
2023-10-26T22:15:29.062000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-10-26T22:15:29.062000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-10-26T22:15:29.063000Z TestFramework (ERROR):
====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path('../../chronik/chronik-http/Cargo.toml').read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'
====== Bitcoin ABC functional tests with the next upgrade activated: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path('../../chronik/chronik-http/Cargo.toml').read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_p2p_compactproofs.py
Bitcoin ABC functional tests: chronik_chronik_info.py
Bitcoin ABC functional tests with the next upgrade activated: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path('../../chronik/chronik-http/Cargo.toml').read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path("../../chronik/chronik-http/Cargo.toml").read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path("../../chronik/chronik-http/Cargo.toml").read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path("../../chronik/chronik-http/Cargo.toml").read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'
====== Bitcoin ABC functional tests with the next upgrade activated: chronik_chronik_info.py ======

------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_chronik_info.py", line 15, in <module>
    chronik_cargo_toml = Path("../../chronik/chronik-http/Cargo.toml").read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '../../chronik/chronik-http/Cargo.toml'

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_chronik_info.py
Bitcoin ABC functional tests with the next upgrade activated: chronik_chronik_info.py

don't use relative path

do not use relative path to read cargo toml

PiRK requested changes to this revision.Oct 27 2023, 06:45
PiRK added a subscriber: PiRK.
PiRK added inline comments.
test/functional/chronik_chronik_info.py
16 ↗(On Diff #42830)

This won't work when running the tests outside a git repository (source distribution...)
There is a get_srcdir function in test_framework/cdefs.py that could be reused here.

18 ↗(On Diff #42830)

an OS agnostic solution in case we someday want to make the tests work on windows

This revision now requires changes to proceed.Oct 27 2023, 06:45
bytesofman marked 2 inline comments as done.

More robust methods for path handling per review suggestions

Fabien requested changes to this revision.Oct 27 2023, 13:53
Fabien added a subscriber: Fabien.
Fabien added inline comments.
test/functional/chronik_chronik_info.py
24 ↗(On Diff #42837)

Make it a function that returns the version instead so there is no global var/code

This revision now requires changes to proceed.Oct 27 2023, 13:53

Move chronik version grab to a function to avoid global var

This revision is now accepted and ready to land.Oct 28 2023, 08:13