Skip to content

Commit

Permalink
unittests: Skip failing Windows tests
Browse files Browse the repository at this point in the history
Some of the unit tests are currently failing on Windows.

Skip them for now, and remove the skips later, once the underlying issues
have been resolved.
  • Loading branch information
claudiubelu committed Apr 4, 2024
1 parent 531726e commit 6cfc7bd
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 7 deletions.
13 changes: 13 additions & 0 deletions cmd/import-boss/main_test.go
Expand Up @@ -19,6 +19,7 @@ package main
import (
"path/filepath"
"reflect"
goruntime "runtime"
"strings"
"testing"

Expand Down Expand Up @@ -120,6 +121,10 @@ func TestHasTestFiles(t *testing.T) {
}

func TestPackageDir(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
cases := []struct {
input *packages.Package
expect string
Expand Down Expand Up @@ -152,6 +157,10 @@ func TestPackageDir(t *testing.T) {
}

func TestHasPathPrefix(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
cases := []struct {
base string
pfx string
Expand Down Expand Up @@ -219,6 +228,10 @@ func checkAllErrorStrings(t *testing.T, errs []error, expect []string) {
}

func TestSimpleForward(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
pkgs, err := loadPkgs("./testdata/simple-fwd/aaa")
if err != nil {
t.Fatalf("unexpected failure: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions cmd/kubeadm/app/cmd/reset_test.go
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"path/filepath"
goruntime "runtime"
"strings"
"testing"

Expand Down Expand Up @@ -47,6 +48,10 @@ ignorePreflightErrors:
`, kubeadmapiv1.SchemeGroupVersion.String())

func TestNewResetData(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
// create temp directory
tmpDir, err := os.MkdirTemp("", "kubeadm-reset-test")
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions cmd/kubeadm/app/phases/certs/renewal/readwriter_test.go
Expand Up @@ -23,6 +23,7 @@ import (
"net"
"os"
"path/filepath"
goruntime "runtime"
"testing"

"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -202,6 +203,10 @@ func writeTestKubeconfig(t *testing.T, dir, name string, caCert *x509.Certificat
}

func TestFileExists(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
tmpdir, err := os.MkdirTemp("", "")
if err != nil {
t.Fatalf("Couldn't create tmpdir: %v", err)
Expand Down Expand Up @@ -303,6 +308,10 @@ func TestPKICertificateReadWriterExists(t *testing.T) {
}

func TestKubeConfigReadWriterExists(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
tmpdir, err := os.MkdirTemp("", "")
if err != nil {
t.Fatalf("Couldn't create tmpdir: %v", err)
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/podautoscaler/horizontal_test.go
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"math"
goruntime "runtime"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -2816,6 +2817,10 @@ func TestUpscaleCap(t *testing.T) {
}

func TestUpscaleCapGreaterThanMaxReplicas(t *testing.T) {
// TODO: Remove skip once this issue is resolvedi: https://github.com/kubernetes/kubernetes/issues/124083
if goruntime.GOOS == "windows" {
t.Skip("Skip flaking test on Windows.")
}
tc := testCase{
minReplicas: 1,
maxReplicas: 20,
Expand Down Expand Up @@ -2847,6 +2852,10 @@ func TestUpscaleCapGreaterThanMaxReplicas(t *testing.T) {
}

func TestMoreReplicasThanSpecNoScale(t *testing.T) {
// TODO: Remove skip once this issue is resolvedi: https://github.com/kubernetes/kubernetes/issues/124083
if goruntime.GOOS == "windows" {
t.Skip("Skip flaking test on Windows.")
}
tc := testCase{
minReplicas: 1,
maxReplicas: 8,
Expand Down
9 changes: 8 additions & 1 deletion pkg/controller/tainteviction/taint_eviction_test.go
Expand Up @@ -19,6 +19,7 @@ package tainteviction
import (
"context"
"fmt"
goruntime "runtime"
"sort"
"testing"
"time"
Expand Down Expand Up @@ -247,6 +248,7 @@ func TestUpdatePod(t *testing.T) {
expectPatch bool
expectDelete bool
enablePodDisruptionConditions bool
skipOnWindows bool
}{
{
description: "scheduling onto tainted Node results in patch and delete when PodDisruptionConditions enabled",
Expand Down Expand Up @@ -295,12 +297,17 @@ func TestUpdatePod(t *testing.T) {
taintedNodes: map[string][]corev1.Taint{
"node1": {createNoExecuteTaint(1)},
},
expectDelete: true,
expectDelete: true,
skipOnWindows: true,
},
}

for _, item := range testCases {
t.Run(item.description, func(t *testing.T) {
if item.skipOnWindows && goruntime.GOOS == "windows" {
// TODO: remove skip once the flaking test has been fixed.
t.Skip("Skip flaking test on Windows.")
}
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodDisruptionConditions, item.enablePodDisruptionConditions)()
ctx, cancel := context.WithCancel(context.Background())
fakeClientset := fake.NewSimpleClientset(&corev1.PodList{Items: []corev1.Pod{*item.prevPod}})
Expand Down
16 changes: 12 additions & 4 deletions pkg/kubelet/apis/config/validation/validation_test.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package validation_test

import (
goruntime "runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -86,14 +87,16 @@ func TestValidateKubeletConfiguration(t *testing.T) {
logsapi.AddFeatureGates(featureGate)

cases := []struct {
name string
configure func(config *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration
errMsg string
name string
configure func(config *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration
errMsg string
skipOnWindows bool
}{{
name: "Success",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
return conf
},
skipOnWindows: true,
}, {
name: "invalid NodeLeaseDurationSeconds",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
Expand Down Expand Up @@ -289,7 +292,8 @@ func TestValidateKubeletConfiguration(t *testing.T) {
conf.SerializeImagePulls = true
return conf
},
errMsg: "invalid configuration: maxParallelImagePulls cannot be larger than 1 unless SerializeImagePulls (--serialize-image-pulls) is set to false",
errMsg: "invalid configuration: maxParallelImagePulls cannot be larger than 1 unless SerializeImagePulls (--serialize-image-pulls) is set to false",
skipOnWindows: true,
}, {
name: "valid MaxParallelImagePulls and SerializeImagePulls combination",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
Expand Down Expand Up @@ -603,6 +607,10 @@ func TestValidateKubeletConfiguration(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if tc.skipOnWindows && goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
errs := validation.ValidateKubeletConfiguration(tc.configure(successConfig.DeepCopy()), featureGate)

if len(tc.errMsg) == 0 {
Expand Down
10 changes: 8 additions & 2 deletions pkg/kubelet/kuberuntime/kuberuntime_container_test.go
Expand Up @@ -247,8 +247,9 @@ func TestToKubeContainerStatusWithResources(t *testing.T) {
)

for desc, test := range map[string]struct {
input *runtimeapi.ContainerStatus
expected *kubecontainer.Status
input *runtimeapi.ContainerStatus
expected *kubecontainer.Status
skipOnWindows bool
}{
"container reporting cpu and memory": {
input: &runtimeapi.ContainerStatus{
Expand Down Expand Up @@ -289,6 +290,7 @@ func TestToKubeContainerStatusWithResources(t *testing.T) {
MemoryLimit: resource.NewQuantity(524288000, resource.BinarySI),
},
},
skipOnWindows: true,
},
"container reporting cpu only": {
input: &runtimeapi.ContainerStatus{
Expand Down Expand Up @@ -357,6 +359,10 @@ func TestToKubeContainerStatusWithResources(t *testing.T) {
},
} {
t.Run(desc, func(t *testing.T) {
if test.skipOnWindows && goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
actual := toKubeContainerStatus(test.input, cid.Type)
assert.Equal(t, test.expected, actual, desc)
})
Expand Down
3 changes: 3 additions & 0 deletions pkg/kubelet/kuberuntime/kuberuntime_container_windows_test.go
Expand Up @@ -151,6 +151,9 @@ func TestCalculateCPUMaximum(t *testing.T) {
}

func TestCalculateWindowsResources(t *testing.T) {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")

_, _, fakeRuntimeSvc, err := createTestRuntimeManager()
require.NoError(t, err)

Expand Down
5 changes: 5 additions & 0 deletions pkg/kubelet/kuberuntime/logs/logs_test.go
Expand Up @@ -24,6 +24,7 @@ import (
"io"
"os"
"path/filepath"
goruntime "runtime"
"testing"
"time"

Expand Down Expand Up @@ -214,6 +215,10 @@ func TestReadLogs(t *testing.T) {
}

func TestReadRotatedLog(t *testing.T) {
if goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
tmpDir := t.TempDir()
file, err := os.CreateTemp(tmpDir, "logfile")
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/kubelet/stats/cri_stats_provider_test.go
Expand Up @@ -336,6 +336,10 @@ func TestCRIListPodStats(t *testing.T) {
}

func TestListPodStatsStrictlyFromCRI(t *testing.T) {
if runtime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
ctx := context.Background()
var (
imageFsMountpoint = "/test/mount/point"
Expand Down
7 changes: 7 additions & 0 deletions pkg/kubelet/userns/userns_manager_test.go
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"os"
goruntime "runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -288,6 +289,7 @@ func TestGetOrCreateUserNamespaceMappings(t *testing.T) {
runtimeUserns bool
runtimeHandler string
success bool
skipOnWindows bool
}{
{
name: "no user namespace",
Expand Down Expand Up @@ -321,6 +323,7 @@ func TestGetOrCreateUserNamespaceMappings(t *testing.T) {
expMode: runtimeapi.NamespaceMode_POD,
runtimeUserns: true,
success: true,
skipOnWindows: true,
},
{
name: "user namespace, but no runtime support",
Expand All @@ -345,6 +348,10 @@ func TestGetOrCreateUserNamespaceMappings(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if tc.skipOnWindows && goruntime.GOOS == "windows" {
// TODO: remove skip once the failing test has been fixed.
t.Skip("Skip failing test on Windows.")
}
// These tests will create the userns file, so use an existing podDir.
testUserNsPodsManager := &testUserNsPodsManager{
podDir: t.TempDir(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/kubelet/winstats/perfcounters_test.go
Expand Up @@ -35,6 +35,8 @@ func TestPerfCounter(t *testing.T) {
}{
"CPU Query": {
counter: cpuQuery,
// TODO: remove skip once the test flake for CPU Query has been fixed.
skipCheck: true,
},
"Memory Prvate Working Set Query": {
counter: memoryPrivWorkingSetQuery,
Expand Down
4 changes: 4 additions & 0 deletions pkg/proxy/apis/config/validation/validation_test.go
Expand Up @@ -825,6 +825,10 @@ func TestValidateKubeProxyConntrackConfiguration(t *testing.T) {
}

func TestValidateProxyMode(t *testing.T) {
// TODO: remove skip once the test has been fixed.
if runtime.GOOS == "windows" {
t.Skip("Skipping failing test on Windows.")
}
newPath := field.NewPath("KubeProxyConfiguration")
successCases := []kubeproxyconfig.ProxyMode{""}
expectedNonExistentErrorMsg := "must be iptables, ipvs or blank (blank means the best-available proxy [currently iptables])"
Expand Down

0 comments on commit 6cfc7bd

Please sign in to comment.