diff --git a/cmd/command/log_test.go b/cmd/command/log_test.go index 85e8876e656fdd156fcf4a67969b4a1d56335d2f..b439ee621afdb6514845c8e16dc759ba18244430 100644 --- a/cmd/command/log_test.go +++ b/cmd/command/log_test.go @@ -17,6 +17,7 @@ package command import ( "bytes" + "os" "strings" "testing" @@ -42,5 +43,8 @@ func TestLoggerHookFire(t *testing.T) { func TestSetuploggerHook(t *testing.T) { restore := SetuploggerHook("sss") + if err := os.RemoveAll("sss"); err != nil { + t.Logf("Failed to remove cluster folder: %v", err) + } defer restore() } diff --git a/pkg/cert/GenerateAllFiles_test.go b/pkg/cert/GenerateAllFiles_test.go index d2f66b6409d90d0b04d35682cc51b09fbef2db53..05170c8598aa76e84264c9bc9f6825c1afbf52cf 100644 --- a/pkg/cert/GenerateAllFiles_test.go +++ b/pkg/cert/GenerateAllFiles_test.go @@ -54,7 +54,7 @@ func TestOsmanager(t *testing.T) { PersistDir: "/", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } diff --git a/pkg/configmanager/manager_test.go b/pkg/configmanager/manager_test.go index 4d441703351d4cc9674fad981b58fc499b120fce..67a2dccd6a6ad8b9246f799905b8e34f3fc783f0 100644 --- a/pkg/configmanager/manager_test.go +++ b/pkg/configmanager/manager_test.go @@ -18,6 +18,7 @@ package configmanager import ( "nestos-kubernetes-deployer/cmd/command/opts" "nestos-kubernetes-deployer/pkg/configmanager/asset" + "nestos-kubernetes-deployer/pkg/configmanager/globalconfig" "testing" ) @@ -84,6 +85,11 @@ func TestConfigmanager(t *testing.T) { }, } + gc, err := globalconfig.InitGlobalConfig(opts) + if err != nil || gc == nil { + t.Fatalf("InitGlobalConfig returned an error: %v", err) + } + clusterconfig, err := GetClusterConfig("cluster") if err != nil { t.Fatal(err) diff --git a/pkg/httpserver/httpserver_test.go b/pkg/httpserver/httpserver_test.go index dd7020749570c23d151f8e15e255a9232b48c97e..784613d21d14994f0946e8b4c1b0e98c75f3840e 100644 --- a/pkg/httpserver/httpserver_test.go +++ b/pkg/httpserver/httpserver_test.go @@ -25,7 +25,7 @@ import ( ) func TestHTTPServer(t *testing.T) { - hs := NewHTTPService("9080") + hs := NewHTTPService("1234") t.Run("TestAddFileToCache", func(t *testing.T) { var content = []byte("test") @@ -85,19 +85,19 @@ func TestHTTPServer(t *testing.T) { }() time.Sleep(1 * time.Second) - _, err := http.Get("http://localhost:9080/testfile") + _, err := http.Get("http://localhost:1234/testfile") if err != nil { t.Log("test fail", err) return } - _, err = http.Get("http://localhost:9080/dir" + os.TempDir()) + _, err = http.Get("http://localhost:1234/dir" + os.TempDir()) if err != nil { t.Log("test fail", err) return } - _, err = http.Get("http://localhost:9080" + constants.RpmPackageList) + _, err = http.Get("http://localhost:1234" + constants.RpmPackageList) if err != nil { t.Log("test fail", err) return diff --git a/pkg/osmanager/bootconfig/cloudinit/cloudinit_test.go b/pkg/osmanager/bootconfig/cloudinit/cloudinit_test.go index c00572c5503f95ad6d8a3b0cc0279f41bd3f47cb..0261fcd47c5c89072ed99c07c3a8e30d6ea51353 100644 --- a/pkg/osmanager/bootconfig/cloudinit/cloudinit_test.go +++ b/pkg/osmanager/bootconfig/cloudinit/cloudinit_test.go @@ -85,5 +85,9 @@ func TestCloudinit(t *testing.T) { return } t.Log("success") + + if err := os.RemoveAll(clusterAsset.ClusterID); err != nil { + t.Logf("Failed to remove cluster folder: %v", err) + } }) } diff --git a/pkg/osmanager/bootconfig/ignition/ignition_test.go b/pkg/osmanager/bootconfig/ignition/ignition_test.go index e3e186ae54863f2fd680aa6cd1f1f598878714bd..fe02fe112507638f29a34d3f9d670990342cdcde 100644 --- a/pkg/osmanager/bootconfig/ignition/ignition_test.go +++ b/pkg/osmanager/bootconfig/ignition/ignition_test.go @@ -52,7 +52,7 @@ func TestIgnition(t *testing.T) { PersistDir: "./", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } @@ -66,6 +66,9 @@ func TestIgnition(t *testing.T) { return } t.Log("success") + if err := os.RemoveAll(clusterAsset.ClusterID); err != nil { + t.Logf("Failed to remove cluster folder: %v", err) + } }) t.Run("GenerateBootConfig_fail", func(t *testing.T) { diff --git a/pkg/osmanager/bootconfig/kickstart/kickstart_test.go b/pkg/osmanager/bootconfig/kickstart/kickstart_test.go index 3683dd92ea8401835e1a1e62672810d5c51f86d5..d271ad100e8c0502fdd121f7b3df90023375cd28 100644 --- a/pkg/osmanager/bootconfig/kickstart/kickstart_test.go +++ b/pkg/osmanager/bootconfig/kickstart/kickstart_test.go @@ -52,7 +52,7 @@ func TestKickstart(t *testing.T) { PersistDir: "./", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } @@ -66,6 +66,10 @@ func TestKickstart(t *testing.T) { return } t.Log("success") + + if err := os.RemoveAll(clusterAsset.ClusterID); err != nil { + t.Logf("Failed to remove cluster folder: %v", err) + } }) t.Run("GenerateBootConfig_fail", func(t *testing.T) { diff --git a/pkg/osmanager/bootconfig/tools_test.go b/pkg/osmanager/bootconfig/tools_test.go index 8296fb2bed1cbc0006cd1c41ea24f39e629ecfa8..f91f6834d748da3efa425723b730aea92ef49fa4 100644 --- a/pkg/osmanager/bootconfig/tools_test.go +++ b/pkg/osmanager/bootconfig/tools_test.go @@ -51,7 +51,7 @@ func TestTool(t *testing.T) { PersistDir: "/", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } diff --git a/pkg/osmanager/generalos/generalos_test.go b/pkg/osmanager/generalos/generalos_test.go index 14caef3021b9e5facf1dc6b113fa7bab62dc80f6..4ff2a7b92339f86a6191ed11cce7b6939a9bd183 100644 --- a/pkg/osmanager/generalos/generalos_test.go +++ b/pkg/osmanager/generalos/generalos_test.go @@ -90,7 +90,7 @@ func TestGeneralos(t *testing.T) { PersistDir: "/", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } diff --git a/pkg/osmanager/nestos/nestos_test.go b/pkg/osmanager/nestos/nestos_test.go index 84b9e0fa58728f31b36250b39073ff1028128094..25c687d01fb94160f6fdc8fdc0565036c59352cc 100644 --- a/pkg/osmanager/nestos/nestos_test.go +++ b/pkg/osmanager/nestos/nestos_test.go @@ -90,7 +90,7 @@ func TestNestOS(t *testing.T) { PersistDir: "/", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } diff --git a/pkg/osmanager/osmanager_test.go b/pkg/osmanager/osmanager_test.go index 32bd60493b68de9582b2f380d7c1e91c3c72244b..8879e5668971f29eaa5ec7e91fd6bb8f7d518e55 100644 --- a/pkg/osmanager/osmanager_test.go +++ b/pkg/osmanager/osmanager_test.go @@ -90,7 +90,7 @@ func TestOsmanager(t *testing.T) { PersistDir: "/", BootstrapUrl: globalconfig.BootstrapUrl{ BootstrapIgnHost: "127.0.0.1", - BootstrapIgnPort: "9080", + BootstrapIgnPort: "1234", }, } diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index d21de685177bf224596bc63e01b3969b9da9f176..a2732143c1e7f9e7ad9b3351675194b5fc4b25c0 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -77,7 +77,7 @@ func TestGetLocalIP(t *testing.T) { } func TestIsPortOpen(t *testing.T) { - port := "8080" + port := "6789" if !IsPortOpen(port) { t.Errorf("expected port %s to be open", port) }