@@ -287,6 +287,10 @@ func TestConfigureInstallation(t *testing.T) {
287287 t .Run (tc .name , func (t * testing.T ) {
288288 // Create a runtime config
289289 rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
290+ // Set the expected data directory to match the test case
291+ if tc .config .DataDirectory != "" {
292+ rc .SetDataDir (tc .config .DataDirectory )
293+ }
290294
291295 // Create an install controller with the config manager
292296 installController , err := linuxinstall .NewInstallController (
@@ -342,7 +346,7 @@ func TestConfigureInstallation(t *testing.T) {
342346 err = json .NewDecoder (rec .Body ).Decode (& status )
343347 require .NoError (t , err )
344348
345- // Verify that the status is not pending. We cannot check for an end state here because the hots config is async
349+ // Verify that the status is not pending. We cannot check for an end state here because the host config is async
346350 // so the state might have moved from running to a final state before we get the response.
347351 assert .NotEqual (t , types .StatePending , status .State )
348352 }
@@ -363,7 +367,7 @@ func TestConfigureInstallation(t *testing.T) {
363367 // Verify that the config is in the store
364368 storedConfig , err := installController .GetInstallationConfig (t .Context ())
365369 require .NoError (t , err )
366- assert .Equal (t , tc . config . DataDirectory , storedConfig .DataDirectory )
370+ assert .Equal (t , rc . EmbeddedClusterHomeDirectory () , storedConfig .DataDirectory )
367371 assert .Equal (t , tc .config .AdminConsolePort , storedConfig .AdminConsolePort )
368372
369373 // Verify that the runtime config is updated
@@ -372,7 +376,7 @@ func TestConfigureInstallation(t *testing.T) {
372376 assert .Equal (t , tc .config .LocalArtifactMirrorPort , rc .LocalArtifactMirrorPort ())
373377 }
374378
375- // Verify host confiuration was performed for successful tests
379+ // Verify host configuration was performed for successful tests
376380 tc .mockHostUtils .AssertExpectations (t )
377381 tc .mockNetUtils .AssertExpectations (t )
378382
@@ -534,7 +538,8 @@ func TestConfigureInstallationControllerError(t *testing.T) {
534538// Test the getInstall endpoint returns installation data correctly
535539func TestGetInstallationConfig (t * testing.T ) {
536540 rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
537- rc .SetDataDir (t .TempDir ())
541+ tempDir := t .TempDir ()
542+ rc .SetDataDir (tempDir )
538543
539544 // Create a config manager
540545 installationManager := installation .NewInstallationManager ()
@@ -548,7 +553,7 @@ func TestGetInstallationConfig(t *testing.T) {
548553
549554 // Set some initial config
550555 initialConfig := types.InstallationConfig {
551- DataDirectory : "/tmp/test-data" ,
556+ DataDirectory : rc . EmbeddedClusterHomeDirectory () ,
552557 AdminConsolePort : 8080 ,
553558 LocalArtifactMirrorPort : 8081 ,
554559 GlobalCIDR : "10.0.0.0/16" ,
@@ -592,7 +597,7 @@ func TestGetInstallationConfig(t *testing.T) {
592597 require .NoError (t , err )
593598
594599 // Verify the installation data matches what we expect
595- assert .Equal (t , initialConfig . DataDirectory , config .DataDirectory )
600+ assert .Equal (t , rc . EmbeddedClusterHomeDirectory () , config .DataDirectory )
596601 assert .Equal (t , initialConfig .AdminConsolePort , config .AdminConsolePort )
597602 assert .Equal (t , initialConfig .LocalArtifactMirrorPort , config .LocalArtifactMirrorPort )
598603 assert .Equal (t , initialConfig .GlobalCIDR , config .GlobalCIDR )
@@ -606,7 +611,8 @@ func TestGetInstallationConfig(t *testing.T) {
606611 netUtils .On ("DetermineBestNetworkInterface" ).Return ("eth0" , nil ).Once ()
607612
608613 rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
609- rc .SetDataDir (t .TempDir ())
614+ defaultTempDir := t .TempDir ()
615+ rc .SetDataDir (defaultTempDir )
610616
611617 // Create a fresh config manager without writing anything
612618 emptyInstallationManager := installation .NewInstallationManager (
@@ -653,7 +659,8 @@ func TestGetInstallationConfig(t *testing.T) {
653659 require .NoError (t , err )
654660
655661 // Verify the installation data contains defaults or empty values
656- assert .Equal (t , "/var/lib/embedded-cluster" , config .DataDirectory )
662+ // Note: DataDirectory gets overridden with the temp directory from RuntimeConfig
663+ assert .Equal (t , rc .EmbeddedClusterHomeDirectory (), config .DataDirectory )
657664 assert .Equal (t , 30000 , config .AdminConsolePort )
658665 assert .Equal (t , 50000 , config .LocalArtifactMirrorPort )
659666 assert .Equal (t , "10.244.0.0/16" , config .GlobalCIDR )
@@ -992,7 +999,8 @@ func TestInstallWithAPIClient(t *testing.T) {
992999
9931000 // Create a runtimeconfig to be used in the install process
9941001 rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
995- rc .SetDataDir (t .TempDir ())
1002+ tempDir := t .TempDir ()
1003+ rc .SetDataDir (tempDir )
9961004
9971005 // Create a mock hostutils
9981006 mockHostUtils := & hostutils.MockHostUtils {}
@@ -1012,7 +1020,7 @@ func TestInstallWithAPIClient(t *testing.T) {
10121020
10131021 // Set some initial config
10141022 initialConfig := types.InstallationConfig {
1015- DataDirectory : "/tmp/test-data-for-client" ,
1023+ DataDirectory : rc . EmbeddedClusterHomeDirectory () ,
10161024 AdminConsolePort : 9080 ,
10171025 LocalArtifactMirrorPort : 9081 ,
10181026 GlobalCIDR : "192.168.0.0/16" ,
@@ -1058,7 +1066,8 @@ func TestInstallWithAPIClient(t *testing.T) {
10581066 require .NoError (t , err , "GetInstallationConfig should succeed" )
10591067
10601068 // Verify values
1061- assert .Equal (t , "/tmp/test-data-for-client" , config .DataDirectory )
1069+ // Note: DataDirectory gets overridden with the temp directory from RuntimeConfig
1070+ assert .Equal (t , rc .EmbeddedClusterHomeDirectory (), config .DataDirectory )
10621071 assert .Equal (t , 9080 , config .AdminConsolePort )
10631072 assert .Equal (t , 9081 , config .LocalArtifactMirrorPort )
10641073 assert .Equal (t , "192.168.0.0/16" , config .GlobalCIDR )
@@ -1084,6 +1093,9 @@ func TestInstallWithAPIClient(t *testing.T) {
10841093 NetworkInterface : "eth0" ,
10851094 }
10861095
1096+ // Update runtime config to match expected data directory for this test
1097+ rc .SetDataDir (config .DataDirectory )
1098+
10871099 // Configure the installation using the client
10881100 _ , err = c .ConfigureInstallation (config )
10891101 require .NoError (t , err , "ConfigureInstallation should succeed with valid config" )
@@ -1102,7 +1114,7 @@ func TestInstallWithAPIClient(t *testing.T) {
11021114 // Get the config to verify it persisted
11031115 newConfig , err := c .GetInstallationConfig ()
11041116 require .NoError (t , err , "GetInstallationConfig should succeed after setting config" )
1105- assert .Equal (t , config . DataDirectory , newConfig .DataDirectory )
1117+ assert .Equal (t , rc . EmbeddedClusterHomeDirectory () , newConfig .DataDirectory )
11061118 assert .Equal (t , config .AdminConsolePort , newConfig .AdminConsolePort )
11071119 assert .Equal (t , config .NetworkInterface , newConfig .NetworkInterface )
11081120
0 commit comments