mirror of https://github.com/k3s-io/k3s
Merge pull request #59027 from YuxiJin-tobeyjin/add-ut-for-legacyLogSymlink
Automatic merge from submit-queue (batch tested with PRs 59027, 62333, 57661, 62086, 61584). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add UT case to cover the func legacyLogSymlink in legacy.go **What this PR does / why we need it**: Add UT case to cover the func legacyLogSymlink in legacy.go. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note "NONE" ```pull/8/head
commit
6816227dfc
|
@ -45,3 +45,14 @@ func TestLogSymLink(t *testing.T) {
|
|||
expectedPath := path.Join(containerLogsDir, fmt.Sprintf("%s_%s-%s", podFullName, containerName, dockerId)[:251]+".log")
|
||||
as.Equal(expectedPath, logSymlink(containerLogsDir, podFullName, containerName, dockerId))
|
||||
}
|
||||
|
||||
func TestLegacyLogSymLink(t *testing.T) {
|
||||
as := assert.New(t)
|
||||
containerID := randStringBytes(80)
|
||||
containerName := randStringBytes(70)
|
||||
podName := randStringBytes(128)
|
||||
podNamespace := randStringBytes(10)
|
||||
// The file name cannot exceed 255 characters. Since .log suffix is required, the prefix cannot exceed 251 characters.
|
||||
expectedPath := path.Join(legacyContainerLogsDir, fmt.Sprintf("%s_%s_%s-%s", podName, podNamespace, containerName, containerID)[:251]+".log")
|
||||
as.Equal(expectedPath, legacyLogSymlink(containerID, containerName, podName, podNamespace))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue