Page MenuHomePhabricator

[chronik-client] Switch to next server if we cannot decode a chronik server error per chronik server error proto
ClosedPublic

Authored by bytesofman on Aug 5 2024, 16:28.

Details

Summary

In production, seeing instances where valid chronik queries may return unparseable errors if the server is re-indexing. In this case, we want to try a different server. But right now, chronik-client only recognizes the need to try a different server if the server is unreachable.

The unreachable server case is distinguished by 'code' in err. We add a new filter for "try another server" -- if we are unable to decode the error msg returned by the server according to chronik's proto.

If we can't parse the error, it's not a defined chronik error, and there is something wrong with the server.

Test Plan

Install locally and test the following queries on an indexing server, e.g. 'https://chronik-native1.fabien.cash'

  • query for chronik.block(856498) with chronik-native1 as first server and no second server, no response, error
  • query for chronik.block(856498) with chronik-native1 as first server and chronik-native2 as second server, get response as failoverProxy cycles to next server
  • query for chronik.block('test') with chronik-native1 as first server and no second server, we get "error connecting to known chronik instances" as the indexing server does not return the proper error msg
  • query chronik.block('test') with chronik-native1 as the first server and chronik-native2 as second server, get expected error "Error in printBlock Error: Failed getting /block/test (): 400: Not a hash or height: test" (confirming that we cycled to the good server with a bad query to a bad server).

Event Timeline

do not catch error intended to be thrown

bytesofman edited the test plan for this revision. (Show Details)
bytesofman published this revision for review.Aug 5 2024, 16:44

Tail of the build log:

2024-08-05T16:50:43.574000Z TestFramework (INFO): Step 1: Initialized regtest chain
chronik_info.ts tests complete, shutting down child process
2024-08-05T16:50:43.581000Z TestFramework (INFO): Received a stop message, exiting
2024-08-05T16:50:43.632000Z TestFramework (INFO): Stopping nodes
2024-08-05T16:50:43.836000Z TestFramework (INFO): Cleaning up /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20240805_165040/setup_scripts/chronik-client_chronik_info_0 on exit
2024-08-05T16:50:43.836000Z TestFramework (INFO): Tests successful
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_chronik_info.py started
setup_scripts/chronik-client_chronik_info.py passed, Duration: 3 s

TEST                                         | STATUS    | DURATION

setup_scripts/chronik-client_chronik_info.py | ✓ Passed  | 3 s

ALL                                          | ✓ Passed  | 3 s (accumulated) 
Runtime: 3 s

testRunner complete in chronik_info.ts
Starting test_runner for chronik-client_lokad_id
Test runner for chronik-client_lokad_id started
2024-08-05T16:50:44.132000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20240805_165043/setup_scripts/chronik-client_lokad_id_0
2024-08-05T16:50:45.821000Z TestFramework (INFO): Passed test setup data to mocha
chronikUrl set to ["http://127.0.0.1:28001"]
Mocha timeout set to 240 seconds
2024-08-05T16:50:46.098000Z TestFramework (INFO): Step 0: New regtest chain
2024-08-05T16:50:46.114000Z TestFramework (INFO): Step 1: Broadcast a tx with lok0 LOKAD id in OP_RETURN
2024-08-05T16:50:46.292000Z TestFramework (INFO): Step 2: We detect 'lok1' LOKAD from an input script
2024-08-05T16:51:46.307000Z TestFramework (INFO): Step 3: We detect 'lok2' and 'lok0' LOKAD IDs when both are in EMPP
2024-08-05T16:52:46.312000Z TestFramework (INFO): Step 4: Mine lokad txs
2024-08-05T16:53:46.336000Z TestFramework (INFO): Step 5: EMPP lok0 and lok2 spending from lok3 p2sh
Exited lokad_id.ts test setup after exceeding mocha timeout.
-----------------------|---------|----------|---------|---------|-----------------------------------
File                   | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                 
-----------------------|---------|----------|---------|---------|-----------------------------------
All files              |    14.6 |     3.41 |   10.77 |    14.5 |                                   
 chronik-client        |     100 |      100 |     100 |     100 |                                   
  index.ts             |     100 |      100 |     100 |     100 |                                   
 chronik-client/proto  |   12.14 |     2.84 |    7.37 |    12.2 |                                   
  chronik.ts           |     6.1 |     0.83 |    2.54 |    6.09 | ...,3978-3985,3990-4027,4031-4036 
  chronikNode.ts       |   16.59 |     4.56 |   11.49 |   16.71 | ...,4991-5030,5038-5111,5146-5151 
 chronik-client/src    |   28.01 |    10.83 |   23.17 |   27.15 |                                   
  ChronikClient.ts     |    4.24 |        0 |       0 |    4.29 | 33-163,178-222,290-692            
  ChronikClientNode.ts |   28.81 |     13.6 |   31.32 |   28.81 | ...83,902,929-1048,1056,1064-1184 
  failoverProxy.ts     |   40.54 |    40.62 |   31.03 |   40.74 | ...45,60,69,80,92,153,193,231-344 
  hex.ts               |   86.84 |        0 |      75 |   84.84 | 50,58,66-68                       
  validation.ts        |      30 |        0 |       0 |   22.22 | 14-49,54-55,62-63                 
-----------------------|---------|----------|---------|---------|-----------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='612']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='4191']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='133']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='3898']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='82']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='761']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='602']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='4150']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/chronik-client-integration-tests-junit.xml': No such file or directory
Build chronik-client-integration-tests failed with exit code 1

checking out the test failure

nm test failures related to earlier draft push

This revision is now accepted and ready to land.Aug 6 2024, 06:34