From 0ce86eb5531bd187458f24799272a60a0ad690b6 Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Wed, 12 Aug 2020 14:28:40 -0700 Subject: [PATCH] Make CSI mock driver log parse more flexible --- test/e2e/storage/csi_mock_volume.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/e2e/storage/csi_mock_volume.go b/test/e2e/storage/csi_mock_volume.go index 0039308ab73..7fd4976a855 100644 --- a/test/e2e/storage/csi_mock_volume.go +++ b/test/e2e/storage/csi_mock_volume.go @@ -69,6 +69,8 @@ const ( driverPodName = "csi-mockplugin-0" // Name of CSI driver container name driverContainerName = "mock" + // Prefix of the mock driver grpc log + grpcCallPrefix = "gRPCCall:" ) // csiCall represents an expected call from Kubernetes to CSI mock driver and @@ -1360,10 +1362,11 @@ func parseMockLogs(cs clientset.Interface, namespace, driverPodName, driverConta logLines := strings.Split(log, "\n") var calls []mockCSICall for _, line := range logLines { - if !strings.HasPrefix(line, "gRPCCall:") { + index := strings.Index(line, grpcCallPrefix) + if index == -1 { continue } - line = strings.TrimPrefix(line, "gRPCCall:") + line = line[index+len(grpcCallPrefix):] call := mockCSICall{ json: string(line), }