@@ -23,7 +23,6 @@ test('ioredis instrumentation', async (t) => {
2323 const { version : pkgVersion } = require ( 'ioredis/package.json' )
2424 const Redis = require ( 'ioredis' )
2525 const redisClient = new Redis ( params . redis_port , params . redis_host )
26- await redisClient . flushall ( )
2726 const METRIC_HOST_NAME = urltils . isLocalhost ( params . redis_host )
2827 ? agent . config . getHostnameSafe ( )
2928 : params . redis_host
@@ -41,10 +40,13 @@ test('ioredis instrumentation', async (t) => {
4140 }
4241 } )
4342
44- t . afterEach ( ( ctx ) => {
43+ t . afterEach ( async ( ctx ) => {
4544 const { agent, redisClient } = ctx . nr
4645 helper . unloadAgent ( agent )
4746 removeModules ( [ 'ioredis' ] )
47+ // re-select the default index for suite as some tests change it
48+ await redisClient . select ( DB_INDEX )
49+ await redisClient . flushdb ( )
4850 redisClient . disconnect ( )
4951 } )
5052
@@ -176,7 +178,6 @@ test('ioredis instrumentation', async (t) => {
176178 const { agent, redisClient, redisKey } = t . nr
177179 const plan = tspl ( t , { plan : 7 } )
178180 const SELECTED_DB = 5
179-
180181 agent . on ( 'transactionFinished' , function ( tx ) {
181182 const root = tx . trace . root
182183 const children = tx . trace . getChildren ( root . id )
@@ -196,6 +197,8 @@ test('ioredis instrumentation', async (t) => {
196197 await redisClient . select ( SELECTED_DB )
197198 await redisClient . set ( `${ redisKey } 2` , 'testvalue' )
198199 transaction . end ( )
200+ // flushing index 5
201+ await redisClient . flushdb ( )
199202 } )
200203 await plan . completed
201204 } )
0 commit comments