@@ -92,7 +92,7 @@ func (b *BaseSuite) CreateFixtures(fixturePath string, manifestNames []string) {
9292// Note that CleanupFixturesCheckMapFiles will wait until the map file is empty before
9393// returning. This is to ensure that the test does not finish before the cleanup
9494// has finished.
95- func (b * BaseSuite ) CleanupFixturesCheckMapFiles (fixturePath string , manifestNames []string , mapFileRelativePath string ) {
95+ func (b * BaseSuite ) CleanupFixturesCheckMapFiles (fixturePath string , manifestNames []string , mapFileRelativePaths [] string ) {
9696 b .T ().Logf ("Cleaning up fixtures in %s" , fixturePath )
9797 defer b .T ().Logf ("End of cleaning up fixtures in %s" , fixturePath )
9898 params := utils.RuntimeYamlParams {
@@ -105,13 +105,9 @@ func (b *BaseSuite) CleanupFixturesCheckMapFiles(fixturePath string, manifestNam
105105 }
106106 err := utils .DeleteRuntimeObjectsFromYAMLFiles (params )
107107 b .Require ().NoError (err )
108- b .Eventually (func () bool {
109- emptyMapFile := b .CheckMapContents (mapFileRelativePath , "" )
110- if ! emptyMapFile {
111- return false
112- }
113- return b .CheckRuntimeMapContents (mapFileRelativePath , "" )
114- }, timeout , interval , fmt .Sprintf ("maps in %s were not emptied" , mapFileRelativePath ))
108+ for _ , mapFileRelativePath := range mapFileRelativePaths {
109+ b .ExpectMapContents (mapFileRelativePath , "" )
110+ }
115111}
116112
117113func (b * BaseSuite ) CreateFixturesInNamespace (fixturePath , namespace string , manifestNames []string ) {
@@ -414,19 +410,25 @@ var StandardMaps = []string{
414410}
415411
416412func (b * BaseSuite ) ExpectMapContents (mapFilePath , expectedMapPath string ) {
417- res := b .Eventually (func () bool {
413+ b . Require () .Eventually (func () bool {
418414 check := b .CheckMapContents (mapFilePath , expectedMapPath )
419415 return check
420416 }, timeout , interval , fmt .Sprintf ("maps in %s did not match expected contents" , mapFilePath ))
421- if ! res {
422- msg := fmt .Sprintf ("maps in %s did not match expected contents" , mapFilePath )
423- b .T ().Fatal (msg )
424- }
425417}
426418
427419func (b * BaseSuite ) CheckMapContents (mapFileRelativePath , expectedMapPath string ) bool {
428- b .T ().Logf ("Checking map contents in %s" , mapFileRelativePath )
429- b .T ().Logf ("with expected map path %s" , expectedMapPath )
420+ checkFile := b .CheckMapFileContents (mapFileRelativePath , expectedMapPath )
421+ if ! checkFile {
422+ return false
423+ }
424+ if TestMapThroughRuntime {
425+ return b .CheckRuntimeMapContents (mapFileRelativePath , expectedMapPath )
426+ }
427+ return true
428+ }
429+
430+ func (b * BaseSuite ) CheckMapFileContents (mapFileRelativePath , expectedMapPath string ) bool {
431+ b .T ().Logf ("Checking map [file] in %s with expected map path %s" , mapFileRelativePath , expectedMapPath )
430432 for _ , mapName := range StandardMaps {
431433 expectedFilePath := path .Join (expectedMapPath , mapName )
432434
@@ -446,18 +448,18 @@ func (b *BaseSuite) CheckMapContents(mapFileRelativePath, expectedMapPath string
446448 if expectationExists {
447449 // Check if content matches
448450 if string (expectedContent ) != actualString {
449- b .T ().Logf ("Map mismatch for %s: \n expected %q, \n got %q" , mapName , string (expectedContent ), actualString )
451+ b .T ().Logf (" map [file] mismatch for %s: \n expected %q, \n got %q" , mapName , string (expectedContent ), actualString )
450452 return false
451453 }
452454 } else {
453455 // Check if actual is empty
454456 if strings .TrimSpace (actualString ) != "" {
455- b .T ().Logf ("Map %s should be empty but has content: %q" , mapName , actualString )
457+ b .T ().Logf (" map [file] %s should be empty but has content: %q" , mapName , actualString )
456458 return false
457459 }
458460 }
459461 }
460- b .T ().Logf ("Map contents correct for %s" , mapFileRelativePath )
462+ b .T ().Logf (" map [file] correct for %s" , mapFileRelativePath )
461463 return true
462464}
463465
@@ -636,8 +638,7 @@ func (b *BaseSuite) ConsistentlyNoReload(oldPid string, duration time.Duration)
636638}
637639
638640func (b * BaseSuite ) CheckRuntimeMapContents (mapFileRelativePath , expectedMapPath string ) bool {
639- b .T ().Logf ("Checking runtime map contents for %s with expected map path %s" , mapFileRelativePath , expectedMapPath )
640- defer b .T ().Logf ("End of checking runtime map contents for %s with expected map path %s" , mapFileRelativePath , expectedMapPath )
641+ b .T ().Logf ("Checking map [runtime] for %s with expected map path %s" , mapFileRelativePath , expectedMapPath )
641642 socketPath := filepath .Join (b .test .HaproxyCfgDir , "haproxy-runtime-api.sock" )
642643
643644 for _ , mapName := range StandardMaps {
@@ -669,11 +670,11 @@ func (b *BaseSuite) CheckRuntimeMapContents(mapFileRelativePath, expectedMapPath
669670 }
670671
671672 if expectationExists {
672- b .T ().Logf ("Runtime map contents: %s" , actualNormalized )
673- b .T ().Logf ("Expected runtime map contents: %s" , expectedNormalized )
673+ b .T ().Logf ("map [runtime] contents: %s" , actualNormalized )
674+ b .T ().Logf ("Expected map [runtime] contents: %s" , expectedNormalized )
674675 if expectedNormalized != actualNormalized {
675676 b .T ().Logf (
676- "Runtime map mismatch for %s:\n expected:\n %q\n got:\n %q" ,
677+ " map [runtime] mismatch for %s:\n expected:\n %q\n got:\n %q" ,
677678 mapName ,
678679 expectedNormalized ,
679680 actualNormalized ,
@@ -683,14 +684,15 @@ func (b *BaseSuite) CheckRuntimeMapContents(mapFileRelativePath, expectedMapPath
683684 } else {
684685 if strings .TrimSpace (actualNormalized ) != "" {
685686 b .T ().Logf (
686- "Runtime map %s should be empty but has content: %q" ,
687+ " map [runtime] %s should be empty but has content: %q" ,
687688 mapName ,
688689 actualNormalized ,
689690 )
690691 return false
691692 }
692693 }
693694 }
695+ b .T ().Logf (" map [runtime] correct for %s" , mapFileRelativePath )
694696
695697 return true
696698}
0 commit comments