mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-23 18:40:53 +00:00
fix csi attach ut print
This commit is contained in:
parent
ed3912e9e3
commit
0209ce9137
@ -110,13 +110,13 @@ func TestAttacherAttach(t *testing.T) {
|
|||||||
|
|
||||||
// attacher loop
|
// attacher loop
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
t.Log("test case: ", tc.name)
|
t.Logf("test case: %s", tc.name)
|
||||||
spec := volume.NewSpecFromPersistentVolume(makeTestPV(fmt.Sprintf("test-pv%d", i), 10, tc.driverName, tc.volumeName), false)
|
spec := volume.NewSpecFromPersistentVolume(makeTestPV(fmt.Sprintf("test-pv%d", i), 10, tc.driverName, tc.volumeName), false)
|
||||||
|
|
||||||
go func(id, nodename string, fail bool) {
|
go func(id, nodename string, fail bool) {
|
||||||
attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename))
|
attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename))
|
||||||
if !fail && err != nil {
|
if !fail && err != nil {
|
||||||
t.Error("was not expecting failure, but got err: ", err)
|
t.Errorf("expecting no failure, but got err: %v", err)
|
||||||
}
|
}
|
||||||
if attachID != id && !fail {
|
if attachID != id && !fail {
|
||||||
t.Errorf("expecting attachID %v, got %v", id, attachID)
|
t.Errorf("expecting attachID %v, got %v", id, attachID)
|
||||||
@ -178,7 +178,7 @@ func TestAttacherWaitForVolumeAttachment(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
t.Logf("running test: %v", tc.name)
|
t.Logf("running test: %s", tc.name)
|
||||||
pvName := fmt.Sprintf("test-pv-%d", i)
|
pvName := fmt.Sprintf("test-pv-%d", i)
|
||||||
volID := fmt.Sprintf("test-vol-%d", i)
|
volID := fmt.Sprintf("test-vol-%d", i)
|
||||||
attachID := getAttachmentName(volID, testDriver, nodeName)
|
attachID := getAttachmentName(volID, testDriver, nodeName)
|
||||||
|
@ -52,12 +52,12 @@ func TestClientAssertSupportedVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Log("case: ", tc.testName)
|
t.Logf("test case: %s", tc.testName)
|
||||||
client := setupClient(t)
|
client := setupClient(t)
|
||||||
client.idClient.(*fake.IdentityClient).SetNextError(tc.err)
|
client.idClient.(*fake.IdentityClient).SetNextError(tc.err)
|
||||||
err := client.AssertSupportedVersion(grpctx.Background(), tc.ver)
|
err := client.AssertSupportedVersion(grpctx.Background(), tc.ver)
|
||||||
if tc.mustFail && err == nil {
|
if tc.mustFail && err == nil {
|
||||||
t.Error("must fail, but err = nil")
|
t.Error("test must fail, but err = nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,12 +74,12 @@ func TestClientNodeProbe(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Log("case: ", tc.testName)
|
t.Logf("test case: %s", tc.testName)
|
||||||
client := setupClient(t)
|
client := setupClient(t)
|
||||||
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
|
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
|
||||||
err := client.NodeProbe(grpctx.Background(), tc.ver)
|
err := client.NodeProbe(grpctx.Background(), tc.ver)
|
||||||
if tc.mustFail && err == nil {
|
if tc.mustFail && err == nil {
|
||||||
t.Error("must fail, but err = nil")
|
t.Error("test must fail, but err = nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ func TestClientNodePublishVolume(t *testing.T) {
|
|||||||
client := setupClient(t)
|
client := setupClient(t)
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Log("case: ", tc.name)
|
t.Logf("test case: %s", tc.name)
|
||||||
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
|
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
|
||||||
err := client.NodePublishVolume(
|
err := client.NodePublishVolume(
|
||||||
grpctx.Background(),
|
grpctx.Background(),
|
||||||
@ -117,7 +117,7 @@ func TestClientNodePublishVolume(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if tc.mustFail && err == nil {
|
if tc.mustFail && err == nil {
|
||||||
t.Error("must fail, but err is nil: ", err)
|
t.Error("test must fail, but err is nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,11 +139,11 @@ func TestClientNodeUnpublishVolume(t *testing.T) {
|
|||||||
client := setupClient(t)
|
client := setupClient(t)
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Log("case: ", tc.name)
|
t.Logf("test case: %s", tc.name)
|
||||||
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
|
client.nodeClient.(*fake.NodeClient).SetNextError(tc.err)
|
||||||
err := client.NodeUnpublishVolume(grpctx.Background(), tc.volID, tc.targetPath)
|
err := client.NodeUnpublishVolume(grpctx.Background(), tc.volID, tc.targetPath)
|
||||||
if tc.mustFail && err == nil {
|
if tc.mustFail && err == nil {
|
||||||
t.Error("must fail, but err is nil: ", err)
|
t.Error("test must fail, but err is nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user