diff --git a/pkg/kubelet/kuberuntime/legacy_test.go b/pkg/kubelet/kuberuntime/legacy_test.go index a3508bdc0c8..31e4d6967f8 100644 --- a/pkg/kubelet/kuberuntime/legacy_test.go +++ b/pkg/kubelet/kuberuntime/legacy_test.go @@ -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)) +}