From dc873efc60371b330437f4c110e2add8e49a37ca Mon Sep 17 00:00:00 2001 From: YuxiJin-tobeyjin Date: Tue, 30 Jan 2018 15:25:59 +0800 Subject: [PATCH] add-ut-for-legacyLogSymlink --- pkg/kubelet/kuberuntime/legacy_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)) +}