-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unittests: Fixes unit tests for Windows (part 3) #110403
Conversation
46a99f2
to
ca9690a
Compare
/test pull-kubernetes-e2e-capz-windows-containerd |
/priority important-soon |
/priority important-soon I'd let sig windows triage it |
@endocrimes since you are looking at other windows unit tests PR, do you want this one (feel free to unassign)? /assign @endocrimes |
/retest |
ea8ec70
to
4ce9d54
Compare
1e6f14c
to
bd39672
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, it would make things easier to review if the test fixes were split up into separate PRs based on type of change, for example, one PR to fix file paths, one PR to fix error codes, one PR to fix timestamps, etc.
@@ -47,6 +47,9 @@ func createProductNameFile() (string, error) { | |||
// referenced by gceProductNameFile being removed, which is the opposite of | |||
// the other tests | |||
func TestMetadata(t *testing.T) { | |||
if !onGCEVM() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unrelated to windows tests. Can we move this to another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #113138
@@ -205,7 +205,7 @@ func (m *Stub) Register(kubeletEndpoint, resourceName string, pluginSockDir stri | |||
client := pluginapi.NewRegistrationClient(conn) | |||
reqt := &pluginapi.RegisterRequest{ | |||
Version: pluginapi.Version, | |||
Endpoint: path.Base(m.socket), | |||
Endpoint: filepath.Base(m.socket), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it is changing some product code. Is there a corresponding unit test for this? Maybe it is better to move this to a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will separate this is a different PR.
pkg/kubelet/kubelet_pods.go
Outdated
@@ -122,7 +121,7 @@ func (kl *Kubelet) makeBlockVolumes(pod *v1.Pod, container *v1.Container, podVol | |||
} | |||
// Get a symbolic link associated to a block device under pod device path | |||
dirPath, volName := vol.BlockVolumeMapper.GetPodDeviceMapPath() | |||
symlinkPath := path.Join(dirPath, volName) | |||
symlinkPath := filepath.Join(dirPath, volName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question. Any unit tests to cover this? May be better as a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move to a separate PR.
@@ -44,18 +43,17 @@ func init() { | |||
flag.Set("alsologtostderr", fmt.Sprintf("%t", true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The init() routine in general seems odd. I wonder if we can remove it (in a separate PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it is pretty useful. It increases the log verbosity, which would make debugging there plugin tests easier, there would be more useful logs collected, especially since there were some issues with plugins before.
pluginName := fmt.Sprintf("example-plugin") | ||
p := pluginwatcher.NewTestExamplePlugin(pluginName, registerapi.DevicePlugin, socketPath, supportedVersions...) | ||
require.NoError(t, p.Serve("v1beta1", "v1beta2")) | ||
timestampBeforeRegistration := time.Now() | ||
// On Windows, time.Now() is not as precise, which means that 2 consecutive calls may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this could result in real problems in the code? It looks like some timestamp comparisons are done in the reconcier: https://github.com/kubernetes/kubernetes/blob/bd39672559f332d37fb335025d972ea2f2811dc2/pkg/kubelet/pluginmanager/reconciler/reconciler.go#L128
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the clock resolution is not as fine grained on Windows as on Linux. Because of this, if a plugin has been reregsitered within a 1-15ms window, the reregistration workflow won't be applied, it won't be detected as being reregistered.
I've moved this to a separate PR, where I'll looking more into it: #113253
isDSR: false, | ||
hns: newFakeHNS(), | ||
endPointsRefCount: make(endPointsReferenceCountMap), | ||
forwardHealthCheckVip: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the fowardHealthCheckVip
option is configurable. Is it that there are test cases that require this flag to be set, or that this is a required field for all cases?
@@ -168,6 +168,10 @@ func (pl *TestPlugin) Less(*framework.QueuedPodInfo, *framework.QueuedPodInfo) b | |||
} | |||
|
|||
func (pl *TestPlugin) Score(ctx context.Context, state *framework.CycleState, p *v1.Pod, nodeName string) (int64, *framework.Status) { | |||
// NOTE: The tests expect some non-zero latency to occur while running these methods. On Windows, time.Now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also result in product issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separated into a different PR: #113253
needs a rebase |
bd39672
to
17e8ade
Compare
17e8ade
to
9824feb
Compare
Currently, there are some unit tests that are failing on Windows due to various reasons: - paths not properly joined (filepath.Join should be used). - Proxy Mode IPVS not supported on Windows. - DeadlineExceeded can occur when trying to read data from an UDP socket. This can be used to detect whether the port was closed or not. - In Windows, with long file name support enabled, file names can have up to 32,767 characters. In this case, the error windows.ERROR_FILENAME_EXCED_RANGE will be encountered instead. - files not closed, which means that they cannot be removed / renamed. - time.Now() is not as precise on Windows, which means that 2 consecutive calls may return the same timestamp. - path.Base() will return the same path. filepath.Base() should be used instead. - path.Join() will always join the paths with a / instead of the OS specific separator. filepath.Join() should be used instead.
9824feb
to
9f95b7b
Compare
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
isDSR: false, | ||
hns: newFakeHNS(), | ||
endPointsRefCount: make(endPointsReferenceCountMap), | ||
forwardHealthCheckVip: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We end up setting this to True for all test cases. Is there any value in testing with it set to False?
/approve |
@thockin, can you take another look? Ty! |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: claudiubelu, endocrimes, marosset, mrunalp, msau42, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind failing-test
/sig windows
/sig testing
What this PR does / why we need it:
Currently, there are some unit tests that are failing on Windows due to various reasons:
windows.ERROR_FILENAME_EXCED_RANGE
will be encountered instead.time.Now()
is not as precise on Windows, which means that 2 consecutive calls may return the same timestamp.path.Base()
will return the same path.filepath.Base()
should be used instead.Which issue(s) this PR fixes:
Related: #51540
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: