diff --git a/cmd/kubeadm/app/cmd/reset_test.go b/cmd/kubeadm/app/cmd/reset_test.go index deb305debe3..66662f33347 100644 --- a/cmd/kubeadm/app/cmd/reset_test.go +++ b/cmd/kubeadm/app/cmd/reset_test.go @@ -34,17 +34,18 @@ import ( "k8s.io/kubernetes/cmd/kubeadm/app/constants" ) +var defaultURLScheme = kubeadmapiv1.DefaultContainerRuntimeURLScheme var testResetConfig = fmt.Sprintf(`apiVersion: %s kind: ResetConfiguration force: true dryRun: true cleanupTmpDir: true -criSocket: unix:///var/run/fake.sock +criSocket: %s:///var/run/fake.sock certificatesDir: /etc/kubernetes/pki2 ignorePreflightErrors: - a - b -`, kubeadmapiv1.SchemeGroupVersion.String()) +`, kubeadmapiv1.SchemeGroupVersion.String(), defaultURLScheme) func TestNewResetData(t *testing.T) { // create temp directory @@ -105,7 +106,7 @@ func TestNewResetData(t *testing.T) { name: "fails if preflight ignores all but has individual check", flags: map[string]string{ options.IgnorePreflightErrors: "all,something-else", - options.NodeCRISocket: "unix:///var/run/crio/crio.sock", + options.NodeCRISocket: fmt.Sprintf("%s:///var/run/crio/crio.sock", defaultURLScheme), }, expectError: "don't specify individual checks if 'all' is used", }, @@ -113,7 +114,7 @@ func TestNewResetData(t *testing.T) { name: "pre-flights errors from CLI args", flags: map[string]string{ options.IgnorePreflightErrors: "a,b", - options.NodeCRISocket: "unix:///var/run/crio/crio.sock", + options.NodeCRISocket: fmt.Sprintf("%s:///var/run/crio/crio.sock", defaultURLScheme), }, validate: expectedResetIgnorePreflightErrors(sets.New("a", "b")), }, @@ -124,8 +125,8 @@ func TestNewResetData(t *testing.T) { options.CfgPath: configFilePath, }, data: &resetData{ - certificatesDir: "/etc/kubernetes/pki2", // cover the case that default is overridden as well - criSocketPath: "unix:///var/run/fake.sock", // cover the case that default is overridden as well + certificatesDir: "/etc/kubernetes/pki2", // cover the case that default is overridden as well + criSocketPath: fmt.Sprintf("%s:///var/run/fake.sock", defaultURLScheme), // cover the case that default is overridden as well ignorePreflightErrors: sets.New("a", "b"), forceReset: true, dryRun: true, @@ -134,7 +135,7 @@ func TestNewResetData(t *testing.T) { TypeMeta: metav1.TypeMeta{Kind: "", APIVersion: ""}, Force: true, CertificatesDir: "/etc/kubernetes/pki2", - CRISocket: "unix:///var/run/fake.sock", + CRISocket: fmt.Sprintf("%s:///var/run/fake.sock", defaultURLScheme), IgnorePreflightErrors: []string{"a", "b"}, CleanupTmpDir: true, DryRun: true, @@ -176,7 +177,7 @@ func TestNewResetData(t *testing.T) { name: "--cri-socket flag is not allowed to mix with config", flags: map[string]string{ options.CfgPath: configFilePath, - options.NodeCRISocket: "unix:///var/run/bogus.sock", + options.NodeCRISocket: fmt.Sprintf("%s:///var/run/bogus.sock", defaultURLScheme), }, expectError: "can not mix '--config' with arguments", }, diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 0bb57058a7e..46f395ef5aa 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -684,10 +684,20 @@ func Test_InFlightPods(t *testing.T) { for _, p := range test.initialPods { obj = append(obj, p) } - q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), obj, WithQueueingHintMapPerProfile(test.queueingHintMap)) + fakeClock := testingclock.NewFakeClock(time.Now()) + q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), obj, WithQueueingHintMapPerProfile(test.queueingHintMap), WithClock(fakeClock)) + // When a Pod is added to the queue, the QueuedPodInfo will have a new timestamp. + // On Windows, time.Now() is not as precise, 2 consecutive calls may return the same timestamp. + // Thus, all the QueuedPodInfos can have the same timestamps, which can be an issue + // when we're expecting them to be popped in a certain order (the Less function + // sorts them by Timestamps if they have the same Pod Priority). + // Using a fake clock for the queue and incrementing it after each added Pod will + // solve this issue on Windows unit test runs. + // For more details on the Windows clock resolution issue, see: https://github.com/golang/go/issues/8687 for _, p := range test.initialPods { q.Add(logger, p) + fakeClock.Step(time.Second) } for _, action := range test.actions {