From 4df989d7195c2eddbaf60c46177cb19224517f62 Mon Sep 17 00:00:00 2001 From: Jurj Andrei George Date: Wed, 11 Jan 2023 19:11:19 +0200 Subject: [PATCH] Skip failing Windows unit tests As discussed during the SIG Testing meeting on January 10, 2023, failing Windows unit tests are now skipped. These changes should be reverted when the unit tests wil get fixed. Mentioned SIG Testing meeting: https://docs.google.com/document/d/1z8MQpr_jTwhmjLMUaqQyBk1EYG_Y_3D4y4YdMJ7V1Kk/edit#heading=h.qwblxf2uhgoo --- pkg/apis/batch/validation/validation_test.go | 39 +++++++------- .../checkpoint/store/fsstore_test.go | 15 ++++-- .../configfiles/configfiles_test.go | 51 +++++++++++++------ pkg/kubelet/network/dns/dns_test.go | 8 +++ .../cache/actual_state_of_world_test.go | 6 +++ .../cache/desired_state_of_world_test.go | 6 +++ .../reconciler/reconciler_test.go | 16 ++++++ .../stats/cadvisor_stats_provider_test.go | 6 +++ 8 files changed, 110 insertions(+), 37 deletions(-) diff --git a/pkg/apis/batch/validation/validation_test.go b/pkg/apis/batch/validation/validation_test.go index af2a17b9406..8ac6af9593b 100644 --- a/pkg/apis/batch/validation/validation_test.go +++ b/pkg/apis/batch/validation/validation_test.go @@ -1618,23 +1618,6 @@ func TestValidateCronJob(t *testing.T) { }, }, }, - "spec.timeZone: Invalid value: \"Continent/Zone \": unknown time zone Continent/Zone ": { - ObjectMeta: metav1.ObjectMeta{ - Name: "mycronjob", - Namespace: metav1.NamespaceDefault, - UID: types.UID("1a2b3c"), - }, - Spec: batch.CronJobSpec{ - Schedule: "0 * * * *", - TimeZone: &timeZoneBadSuffix, - ConcurrencyPolicy: batch.AllowConcurrent, - JobTemplate: batch.JobTemplateSpec{ - Spec: batch.JobSpec{ - Template: validPodTemplateSpec, - }, - }, - }, - }, "spec.timeZone: Invalid value: \"Continent/InvalidZone\": unknown time zone Continent/InvalidZone": { ObjectMeta: metav1.ObjectMeta{ Name: "mycronjob", @@ -1900,6 +1883,28 @@ func TestValidateCronJob(t *testing.T) { }, } + // NOTE: The following test doesn't fail on Windows. + // When opening a file on Windows, syscall.Open is called, which will trim the whitespace suffix. + if runtime.GOOS != "windows" { + errorCases["spec.timeZone: Invalid value: \"Continent/Zone \": unknown time zone Continent/Zone "] = batch.CronJob{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mycronjob", + Namespace: metav1.NamespaceDefault, + UID: types.UID("1a2b3c"), + }, + Spec: batch.CronJobSpec{ + Schedule: "0 * * * *", + TimeZone: &timeZoneBadSuffix, + ConcurrencyPolicy: batch.AllowConcurrent, + JobTemplate: batch.JobTemplateSpec{ + Spec: batch.JobSpec{ + Template: validPodTemplateSpec, + }, + }, + }, + } + } + for k, v := range errorCases { t.Run(k, func(t *testing.T) { errs := ValidateCronJobCreate(&v, corevalidation.PodValidationOptions{}) diff --git a/pkg/kubelet/kubeletconfig/checkpoint/store/fsstore_test.go b/pkg/kubelet/kubeletconfig/checkpoint/store/fsstore_test.go index 05944f17c9f..d27c250bed1 100644 --- a/pkg/kubelet/kubeletconfig/checkpoint/store/fsstore_test.go +++ b/pkg/kubelet/kubeletconfig/checkpoint/store/fsstore_test.go @@ -20,6 +20,7 @@ import ( "fmt" "path/filepath" "reflect" + "runtime" "testing" "time" @@ -257,14 +258,20 @@ func TestFsStoreLoad(t *testing.T) { uid types.UID resourceVersion string err string + skipOnWindows bool }{ - {"checkpoint exists", uid, resourceVersion, ""}, - {"checkpoint does not exist", "bogus-uid", "bogus-resourceVersion", "no checkpoint for source"}, - {"ambiguous UID", "", "bogus-resourceVersion", "empty UID is ambiguous"}, - {"ambiguous ResourceVersion", "bogus-uid", "", "empty ResourceVersion is ambiguous"}, + {"checkpoint exists", uid, resourceVersion, "", true}, + {"checkpoint does not exist", "bogus-uid", "bogus-resourceVersion", "no checkpoint for source", false}, + {"ambiguous UID", "", "bogus-resourceVersion", "empty UID is ambiguous", false}, + {"ambiguous ResourceVersion", "bogus-uid", "", "empty ResourceVersion is ambiguous", false}, } for _, c := range cases { t.Run(c.desc, func(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if c.skipOnWindows && runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + source, _, err := checkpoint.NewRemoteConfigSource(&apiv1.NodeConfigSource{ ConfigMap: &apiv1.ConfigMapNodeConfigSource{ Name: "name", diff --git a/pkg/kubelet/kubeletconfig/configfiles/configfiles_test.go b/pkg/kubelet/kubeletconfig/configfiles/configfiles_test.go index b11581c1e8f..fe9bba43c4a 100644 --- a/pkg/kubelet/kubeletconfig/configfiles/configfiles_test.go +++ b/pkg/kubelet/kubeletconfig/configfiles/configfiles_test.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "path/filepath" + goruntime "runtime" "testing" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -38,11 +39,12 @@ const kubeletFile = "kubelet" func TestLoad(t *testing.T) { cases := []struct { - desc string - file *string - expect *kubeletconfig.KubeletConfiguration - err string - strictErr bool + desc string + file *string + expect *kubeletconfig.KubeletConfiguration + err string + strictErr bool + skipOnWindows bool }{ // missing file { @@ -93,12 +95,14 @@ func TestLoad(t *testing.T) { desc: "default from yaml", file: newString(`kind: KubeletConfiguration apiVersion: kubelet.config.k8s.io/v1beta1`), - expect: newConfig(t), + expect: newConfig(t), + skipOnWindows: true, }, { - desc: "default from json", - file: newString(`{"kind":"KubeletConfiguration","apiVersion":"kubelet.config.k8s.io/v1beta1"}`), - expect: newConfig(t), + desc: "default from json", + file: newString(`{"kind":"KubeletConfiguration","apiVersion":"kubelet.config.k8s.io/v1beta1"}`), + expect: newConfig(t), + skipOnWindows: true, }, // relative path @@ -112,6 +116,7 @@ staticPodPath: %s`, relativePath)), kc.StaticPodPath = filepath.Join(configDir, relativePath) return kc }(), + skipOnWindows: true, }, { desc: "json, relative path is resolved", @@ -121,6 +126,7 @@ staticPodPath: %s`, relativePath)), kc.StaticPodPath = filepath.Join(configDir, relativePath) return kc }(), + skipOnWindows: true, }, { // This should fail from v1beta2+ @@ -136,6 +142,7 @@ staticPodPath: %s/foo`, relativePath, relativePath)), kc.StaticPodPath = filepath.Join(configDir, relativePath, "foo") return kc }(), + skipOnWindows: true, }, { // This should fail from v1beta2+ @@ -145,12 +152,18 @@ apiVersion: kubelet.config.k8s.io/v1beta1 foo: bar`), // err: "found unknown field: foo", // strictErr: true, - expect: newConfig(t), + expect: newConfig(t), + skipOnWindows: true, }, } for _, c := range cases { t.Run(c.desc, func(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if c.skipOnWindows && goruntime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + fs := utilfs.NewTempFs() fs.MkdirAll(configDir, 0777) path := filepath.Join(configDir, kubeletFile) @@ -181,13 +194,14 @@ foo: bar`), func TestResolveRelativePaths(t *testing.T) { absolutePath := filepath.Join(configDir, "absolute") cases := []struct { - desc string - path string - expect string + desc string + path string + expect string + skipOnWindows bool }{ - {"empty path", "", ""}, - {"absolute path", absolutePath, absolutePath}, - {"relative path", relativePath, filepath.Join(configDir, relativePath)}, + {"empty path", "", "", false}, + {"absolute path", absolutePath, absolutePath, true}, + {"relative path", relativePath, filepath.Join(configDir, relativePath), false}, } paths := kubeletconfig.KubeletConfigurationPathRefs(newConfig(t)) @@ -196,6 +210,11 @@ func TestResolveRelativePaths(t *testing.T) { } for _, c := range cases { t.Run(c.desc, func(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if c.skipOnWindows && goruntime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + // set the path, resolve it, and check if it resolved as we would expect *(paths[0]) = c.path resolveRelativePaths(paths, configDir) diff --git a/pkg/kubelet/network/dns/dns_test.go b/pkg/kubelet/network/dns/dns_test.go index e1c3c69c54e..2832881a66f 100644 --- a/pkg/kubelet/network/dns/dns_test.go +++ b/pkg/kubelet/network/dns/dns_test.go @@ -20,6 +20,7 @@ import ( "fmt" "net" "os" + goruntime "runtime" "strconv" "strings" "testing" @@ -456,19 +457,26 @@ func TestGetPodDNS(t *testing.T) { testCases := []struct { desc string expandedDNSConfig bool + skipOnWindows bool }{ { desc: "Not ExpandedDNSConfig", expandedDNSConfig: false, + skipOnWindows: true, }, { desc: "ExpandedDNSConfig", expandedDNSConfig: true, + skipOnWindows: true, }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if tc.skipOnWindows && goruntime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ExpandedDNSConfig, tc.expandedDNSConfig)() testGetPodDNS(t) }) diff --git a/pkg/kubelet/pluginmanager/cache/actual_state_of_world_test.go b/pkg/kubelet/pluginmanager/cache/actual_state_of_world_test.go index aacd5f00227..df836475a24 100644 --- a/pkg/kubelet/pluginmanager/cache/actual_state_of_world_test.go +++ b/pkg/kubelet/pluginmanager/cache/actual_state_of_world_test.go @@ -17,6 +17,7 @@ limitations under the License. package cache import ( + "runtime" "testing" "time" @@ -117,6 +118,11 @@ func Test_ASW_RemovePlugin_Positive(t *testing.T) { // Verifies PluginExistsWithCorrectTimestamp returns false for an existing // plugin with the wrong timestamp func Test_ASW_PluginExistsWithCorrectTimestamp_Negative_WrongTimestamp(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + // First, add a plugin asw := NewActualStateOfWorld() pluginInfo := PluginInfo{ diff --git a/pkg/kubelet/pluginmanager/cache/desired_state_of_world_test.go b/pkg/kubelet/pluginmanager/cache/desired_state_of_world_test.go index 24caa040982..807ca40d4dd 100644 --- a/pkg/kubelet/pluginmanager/cache/desired_state_of_world_test.go +++ b/pkg/kubelet/pluginmanager/cache/desired_state_of_world_test.go @@ -17,6 +17,7 @@ limitations under the License. package cache import ( + "runtime" "testing" "github.com/stretchr/testify/require" @@ -53,6 +54,11 @@ func Test_DSW_AddOrUpdatePlugin_Positive_NewPlugin(t *testing.T) { // Verifies the timestamp the existing plugin is updated // Verifies newly added plugin returns true for PluginExists() func Test_DSW_AddOrUpdatePlugin_Positive_ExistingPlugin(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + dsw := NewDesiredStateOfWorld() socketPath := "/var/lib/kubelet/device-plugins/test-plugin.sock" // Adding the plugin for the first time diff --git a/pkg/kubelet/pluginmanager/reconciler/reconciler_test.go b/pkg/kubelet/pluginmanager/reconciler/reconciler_test.go index e0c95eb1a1d..8790c94333c 100644 --- a/pkg/kubelet/pluginmanager/reconciler/reconciler_test.go +++ b/pkg/kubelet/pluginmanager/reconciler/reconciler_test.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "testing" "time" @@ -167,6 +168,11 @@ func Test_Run_Positive_DoNothing(t *testing.T) { // Calls Run() // Verifies the actual state of world contains that plugin func Test_Run_Positive_Register(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + defer cleanup(t) dsw := cache.NewDesiredStateOfWorld() @@ -212,6 +218,11 @@ func Test_Run_Positive_Register(t *testing.T) { // Deletes plugin from desired state of world. // Verifies that plugin no longer exists in actual state of world. func Test_Run_Positive_RegisterThenUnregister(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + defer cleanup(t) dsw := cache.NewDesiredStateOfWorld() @@ -268,6 +279,11 @@ func Test_Run_Positive_RegisterThenUnregister(t *testing.T) { // Verifies that the plugin is reregistered. // Verifies the plugin with updated timestamp now in actual state of world. func Test_Run_Positive_ReRegister(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + defer cleanup(t) dsw := cache.NewDesiredStateOfWorld() diff --git a/pkg/kubelet/stats/cadvisor_stats_provider_test.go b/pkg/kubelet/stats/cadvisor_stats_provider_test.go index 25decaafe86..523cdd036c8 100644 --- a/pkg/kubelet/stats/cadvisor_stats_provider_test.go +++ b/pkg/kubelet/stats/cadvisor_stats_provider_test.go @@ -18,6 +18,7 @@ package stats import ( "context" + "runtime" "testing" "github.com/golang/mock/gomock" @@ -39,6 +40,11 @@ import ( ) func TestFilterTerminatedContainerInfoAndAssembleByPodCgroupKey(t *testing.T) { + // Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023 + if runtime.GOOS == "windows" { + t.Skip("Skipping test that fails on Windows") + } + const ( seedPastPod0Infra = 1000 seedPastPod0Container0 = 2000