1- import { ChildProcess } from 'child_process' ;
1+ import { ChildProcess } from 'node:child_process' ;
2+ import { rm } from 'node:fs/promises' ;
3+
4+ import { retry } from 'async' ;
5+
26import { buildRubyProject , runInBackground , waitForStdout } from './helpers' ;
37import { Client } from 'jayson/promise' ;
48import { AppMapRpc } from '@appland/rpc' ;
@@ -28,9 +32,11 @@ describe('appmap', () => {
2832
2933 afterEach ( ( ) => {
3034 indexProcess . kill ( ) ;
35+ // remove the temporary project directory
36+ void rm ( projectPath , { recursive : true } ) ;
3137 } ) ;
3238
33- it ( 'picks up the correct configuration' , async ( ) => {
39+ const checkStats = async ( ) => {
3440 const { error, result } = await rpcClient . request ( AppMapRpc . Stats . V1 . Method , { } ) ;
3541 expect ( error ) . toBeUndefined ( ) ;
3642 expect ( result ) . toStrictEqual ( {
@@ -44,7 +50,15 @@ describe('appmap', () => {
4450 tables : [ 'api_keys' , 'pg_attribute' , 'pg_type' , 'users' ] ,
4551 numAppMaps : 1 ,
4652 } ) ;
47- } ) ;
53+ } ;
54+
55+ // it might take a moment for the maps to be indexed
56+ it ( 'picks up the correct configuration' , backoffRetry ( checkStats ) ) ;
4857 } ) ;
4958 } ) ;
5059} ) ;
60+
61+ function backoffRetry < T > ( fn : ( ) => Promise < T > , times = 10 , initialDelay = 10 ) : ( ) => Promise < T > {
62+ const interval = ( retryCount : number ) => Math . pow ( 2 , retryCount ) * initialDelay ;
63+ return ( ) => retry ( { times, interval } , fn ) ;
64+ }
0 commit comments