@@ -287,6 +287,10 @@ func TestConfigureInstallation(t *testing.T) {
287
287
t .Run (tc .name , func (t * testing.T ) {
288
288
// Create a runtime config
289
289
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
+ }
290
294
291
295
// Create an install controller with the config manager
292
296
installController , err := linuxinstall .NewInstallController (
@@ -342,7 +346,7 @@ func TestConfigureInstallation(t *testing.T) {
342
346
err = json .NewDecoder (rec .Body ).Decode (& status )
343
347
require .NoError (t , err )
344
348
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
346
350
// so the state might have moved from running to a final state before we get the response.
347
351
assert .NotEqual (t , types .StatePending , status .State )
348
352
}
@@ -363,7 +367,7 @@ func TestConfigureInstallation(t *testing.T) {
363
367
// Verify that the config is in the store
364
368
storedConfig , err := installController .GetInstallationConfig (t .Context ())
365
369
require .NoError (t , err )
366
- assert .Equal (t , tc . config . DataDirectory , storedConfig .DataDirectory )
370
+ assert .Equal (t , rc . EmbeddedClusterHomeDirectory () , storedConfig .DataDirectory )
367
371
assert .Equal (t , tc .config .AdminConsolePort , storedConfig .AdminConsolePort )
368
372
369
373
// Verify that the runtime config is updated
@@ -372,7 +376,7 @@ func TestConfigureInstallation(t *testing.T) {
372
376
assert .Equal (t , tc .config .LocalArtifactMirrorPort , rc .LocalArtifactMirrorPort ())
373
377
}
374
378
375
- // Verify host confiuration was performed for successful tests
379
+ // Verify host configuration was performed for successful tests
376
380
tc .mockHostUtils .AssertExpectations (t )
377
381
tc .mockNetUtils .AssertExpectations (t )
378
382
@@ -534,7 +538,8 @@ func TestConfigureInstallationControllerError(t *testing.T) {
534
538
// Test the getInstall endpoint returns installation data correctly
535
539
func TestGetInstallationConfig (t * testing.T ) {
536
540
rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
537
- rc .SetDataDir (t .TempDir ())
541
+ tempDir := t .TempDir ()
542
+ rc .SetDataDir (tempDir )
538
543
539
544
// Create a config manager
540
545
installationManager := installation .NewInstallationManager ()
@@ -548,7 +553,7 @@ func TestGetInstallationConfig(t *testing.T) {
548
553
549
554
// Set some initial config
550
555
initialConfig := types.InstallationConfig {
551
- DataDirectory : "/tmp/test-data" ,
556
+ DataDirectory : rc . EmbeddedClusterHomeDirectory () ,
552
557
AdminConsolePort : 8080 ,
553
558
LocalArtifactMirrorPort : 8081 ,
554
559
GlobalCIDR : "10.0.0.0/16" ,
@@ -592,7 +597,7 @@ func TestGetInstallationConfig(t *testing.T) {
592
597
require .NoError (t , err )
593
598
594
599
// Verify the installation data matches what we expect
595
- assert .Equal (t , initialConfig . DataDirectory , config .DataDirectory )
600
+ assert .Equal (t , rc . EmbeddedClusterHomeDirectory () , config .DataDirectory )
596
601
assert .Equal (t , initialConfig .AdminConsolePort , config .AdminConsolePort )
597
602
assert .Equal (t , initialConfig .LocalArtifactMirrorPort , config .LocalArtifactMirrorPort )
598
603
assert .Equal (t , initialConfig .GlobalCIDR , config .GlobalCIDR )
@@ -606,7 +611,8 @@ func TestGetInstallationConfig(t *testing.T) {
606
611
netUtils .On ("DetermineBestNetworkInterface" ).Return ("eth0" , nil ).Once ()
607
612
608
613
rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
609
- rc .SetDataDir (t .TempDir ())
614
+ defaultTempDir := t .TempDir ()
615
+ rc .SetDataDir (defaultTempDir )
610
616
611
617
// Create a fresh config manager without writing anything
612
618
emptyInstallationManager := installation .NewInstallationManager (
@@ -653,7 +659,8 @@ func TestGetInstallationConfig(t *testing.T) {
653
659
require .NoError (t , err )
654
660
655
661
// 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 )
657
664
assert .Equal (t , 30000 , config .AdminConsolePort )
658
665
assert .Equal (t , 50000 , config .LocalArtifactMirrorPort )
659
666
assert .Equal (t , "10.244.0.0/16" , config .GlobalCIDR )
@@ -992,7 +999,8 @@ func TestInstallWithAPIClient(t *testing.T) {
992
999
993
1000
// Create a runtimeconfig to be used in the install process
994
1001
rc := runtimeconfig .New (nil , runtimeconfig .WithEnvSetter (& testEnvSetter {}))
995
- rc .SetDataDir (t .TempDir ())
1002
+ tempDir := t .TempDir ()
1003
+ rc .SetDataDir (tempDir )
996
1004
997
1005
// Create a mock hostutils
998
1006
mockHostUtils := & hostutils.MockHostUtils {}
@@ -1012,7 +1020,7 @@ func TestInstallWithAPIClient(t *testing.T) {
1012
1020
1013
1021
// Set some initial config
1014
1022
initialConfig := types.InstallationConfig {
1015
- DataDirectory : "/tmp/test-data-for-client" ,
1023
+ DataDirectory : rc . EmbeddedClusterHomeDirectory () ,
1016
1024
AdminConsolePort : 9080 ,
1017
1025
LocalArtifactMirrorPort : 9081 ,
1018
1026
GlobalCIDR : "192.168.0.0/16" ,
@@ -1058,7 +1066,8 @@ func TestInstallWithAPIClient(t *testing.T) {
1058
1066
require .NoError (t , err , "GetInstallationConfig should succeed" )
1059
1067
1060
1068
// 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 )
1062
1071
assert .Equal (t , 9080 , config .AdminConsolePort )
1063
1072
assert .Equal (t , 9081 , config .LocalArtifactMirrorPort )
1064
1073
assert .Equal (t , "192.168.0.0/16" , config .GlobalCIDR )
@@ -1084,6 +1093,9 @@ func TestInstallWithAPIClient(t *testing.T) {
1084
1093
NetworkInterface : "eth0" ,
1085
1094
}
1086
1095
1096
+ // Update runtime config to match expected data directory for this test
1097
+ rc .SetDataDir (config .DataDirectory )
1098
+
1087
1099
// Configure the installation using the client
1088
1100
_ , err = c .ConfigureInstallation (config )
1089
1101
require .NoError (t , err , "ConfigureInstallation should succeed with valid config" )
@@ -1102,7 +1114,7 @@ func TestInstallWithAPIClient(t *testing.T) {
1102
1114
// Get the config to verify it persisted
1103
1115
newConfig , err := c .GetInstallationConfig ()
1104
1116
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 )
1106
1118
assert .Equal (t , config .AdminConsolePort , newConfig .AdminConsolePort )
1107
1119
assert .Equal (t , config .NetworkInterface , newConfig .NetworkInterface )
1108
1120
0 commit comments