@@ -102,16 +102,25 @@ func GetTestConfig(driver string) *TestConfig {
102102 }
103103}
104104
105- func syncCommand (config TestConfig , useState bool ) string {
105+ func syncCommand (config TestConfig , useState bool , flags ... string ) string {
106106 baseCmd := fmt .Sprintf ("/test-olake/build.sh driver-%s sync --config %s --catalog %s --destination %s" , config .Driver , config .SourcePath , config .CatalogPath , config .DestinationPath )
107107 if useState {
108108 baseCmd = fmt .Sprintf ("%s --state %s" , baseCmd , config .StatePath )
109109 }
110+
111+ if len (flags ) > 0 {
112+ baseCmd = fmt .Sprintf ("%s %s" , baseCmd , strings .Join (flags , " " ))
113+ }
110114 return baseCmd
111115}
112116
113- func discoverCommand (config TestConfig ) string {
114- return fmt .Sprintf ("/test-olake/build.sh driver-%s discover --config %s" , config .Driver , config .SourcePath )
117+ // pass flags as `--flag1, flag1 value, --flag2, flag2 value...`
118+ func discoverCommand (config TestConfig , flags ... string ) string {
119+ baseCmd := fmt .Sprintf ("/test-olake/build.sh driver-%s discover --config %s" , config .Driver , config .SourcePath )
120+ if len (flags ) > 0 {
121+ baseCmd = fmt .Sprintf ("%s %s" , baseCmd , strings .Join (flags , " " ))
122+ }
123+ return baseCmd
115124}
116125
117126// TODO: check if we can remove namespace from being passed as a parameter and use a common namespace for all drivers
@@ -307,8 +316,9 @@ func (cfg *IntegrationTest) TestIntegration(t *testing.T) {
307316 },
308317 }
309318
319+ destDBPrefix := fmt .Sprintf ("integration_%s" , cfg .TestConfig .Driver )
310320 runSync := func (c testcontainers.Container , useState bool , operation , opSymbol string , schema map [string ]interface {}) error {
311- cmd := syncCommand (* cfg .TestConfig , useState )
321+ cmd := syncCommand (* cfg .TestConfig , useState , "--destination-database-prefix" , destDBPrefix )
312322 if useState && operation != "" {
313323 cfg .ExecuteQuery (ctx , t , []string {currentTestTable }, operation , false )
314324 }
@@ -460,6 +470,8 @@ func (cfg *PerformanceTest) TestPerformance(t *testing.T) {
460470 code , output , err := utils .ExecCommand (timedCtx , c , cmd )
461471 // check if sync was canceled due to timeout (expected)
462472 if timedCtx .Err () == context .DeadlineExceeded {
473+ killCmd := "pkill -9 -f 'olake.*sync' || true"
474+ _ , _ , _ = utils .ExecCommand (ctx , c , killCmd )
463475 return output , nil
464476 }
465477 if err != nil || code != 0 {
@@ -491,11 +503,12 @@ func (cfg *PerformanceTest) TestPerformance(t *testing.T) {
491503 if code , output , err := utils .ExecCommand (ctx , c , installCmd ); err != nil || code != 0 {
492504 return fmt .Errorf ("failed to install dependencies:\n %s" , string (output ))
493505 }
494-
495506 t .Logf ("(backfill) running performance test for %s" , cfg .TestConfig .Driver )
496507
508+ destDBPrefix := fmt .Sprintf ("performance_%s" , cfg .TestConfig .Driver )
509+
497510 t .Log ("(backfill) discover started" )
498- discoverCmd := discoverCommand (* cfg .TestConfig )
511+ discoverCmd := discoverCommand (* cfg .TestConfig , "--destination-database-prefix" , destDBPrefix )
499512 if code , output , err := utils .ExecCommand (ctx , c , discoverCmd ); err != nil || code != 0 {
500513 return fmt .Errorf ("failed to perform discover:\n %s" , string (output ))
501514 }
@@ -508,7 +521,7 @@ func (cfg *PerformanceTest) TestPerformance(t *testing.T) {
508521
509522 t .Log ("(backfill) sync started" )
510523 usePreChunkedState := cfg .TestConfig .Driver == string (constants .MySQL )
511- syncCmd := syncCommand (* cfg .TestConfig , usePreChunkedState )
524+ syncCmd := syncCommand (* cfg .TestConfig , usePreChunkedState , "--destination-database-prefix" , destDBPrefix )
512525 if output , err := syncWithTimeout (ctx , c , syncCmd ); err != nil {
513526 return fmt .Errorf ("failed to perform sync:\n %s" , string (output ))
514527 }
@@ -529,7 +542,7 @@ func (cfg *PerformanceTest) TestPerformance(t *testing.T) {
529542 t .Log ("(cdc) setup cdc completed" )
530543
531544 t .Log ("(cdc) discover started" )
532- discoverCmd := discoverCommand (* cfg .TestConfig )
545+ discoverCmd := discoverCommand (* cfg .TestConfig , "--destination-database-prefix" , destDBPrefix )
533546 if code , output , err := utils .ExecCommand (ctx , c , discoverCmd ); err != nil || code != 0 {
534547 return fmt .Errorf ("failed to perform discover:\n %s" , string (output ))
535548 }
@@ -541,7 +554,7 @@ func (cfg *PerformanceTest) TestPerformance(t *testing.T) {
541554 }
542555
543556 t .Log ("(cdc) state creation started" )
544- syncCmd := syncCommand (* cfg .TestConfig , false )
557+ syncCmd := syncCommand (* cfg .TestConfig , false , "--destination-database-prefix" , destDBPrefix )
545558 if code , output , err := utils .ExecCommand (ctx , c , syncCmd ); err != nil || code != 0 {
546559 return fmt .Errorf ("failed to perform initial sync:\n %s" , string (output ))
547560 }
@@ -552,7 +565,7 @@ func (cfg *PerformanceTest) TestPerformance(t *testing.T) {
552565 t .Log ("(cdc) trigger cdc completed" )
553566
554567 t .Log ("(cdc) sync started" )
555- syncCmd = syncCommand (* cfg .TestConfig , true )
568+ syncCmd = syncCommand (* cfg .TestConfig , true , "--destination-database-prefix" , destDBPrefix )
556569 if output , err := syncWithTimeout (ctx , c , syncCmd ); err != nil {
557570 return fmt .Errorf ("failed to perform CDC sync:\n %s" , string (output ))
558571 }
0 commit comments