Skip to content

Commit e23a26a

Browse files
committed
Update to new javascript
1 parent a4f0808 commit e23a26a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/e2e/storage/csi_mock_volume.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
583583

584584
ginkgo.Context("CSI NodeStage error cases [Slow]", func() {
585585
// Global variable in all scripts (called before each test)
586-
globalScript := `counter=0;`
586+
globalScript := `counter=0; console.log("globals loaded", OK, INVALIDARGUMENT)`
587587
trackedCalls := []string{
588588
"NodeStageVolume",
589589
"NodeUnstageVolume",
@@ -604,7 +604,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
604604
{expectedMethod: "NodeStageVolume", expectedError: codes.OK, deletePod: true},
605605
{expectedMethod: "NodeUnstageVolume", expectedError: codes.OK},
606606
},
607-
nodeStageScript: `__grpcCode.OK;`,
607+
nodeStageScript: `OK;`,
608608
},
609609
{
610610
// Kubelet should repeat NodeStage as long as the pod exists
@@ -617,7 +617,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
617617
{expectedMethod: "NodeUnstageVolume", expectedError: codes.OK},
618618
},
619619
// Fail first 3 NodeStage requests, 4th succeeds
620-
nodeStageScript: `console.log("Counter:", ++counter); if (counter < 4) { __grpcCode.INVALIDARGUMENT; } else { __grpcCode.OK; }`,
620+
nodeStageScript: `console.log("Counter:", ++counter); if (counter < 4) { INVALIDARGUMENT; } else { OK; }`,
621621
},
622622
{
623623
// Kubelet should repeat NodeStage as long as the pod exists
@@ -630,7 +630,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
630630
{expectedMethod: "NodeUnstageVolume", expectedError: codes.OK},
631631
},
632632
// Fail first 3 NodeStage requests, 4th succeeds
633-
nodeStageScript: `console.log("Counter:", ++counter); if (counter < 4) { __grpcCode.DEADLINEEXCEEDED; } else { __grpcCode.OK; }`,
633+
nodeStageScript: `console.log("Counter:", ++counter); if (counter < 4) { DEADLINEEXCEEDED; } else { OK; }`,
634634
},
635635
{
636636
// After NodeUnstage with ephemeral error, the driver may continue staging the volume.
@@ -644,7 +644,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
644644
{expectedMethod: "NodeStageVolume", expectedError: codes.DeadlineExceeded, deletePod: true},
645645
{expectedMethod: "NodeUnstageVolume", expectedError: codes.OK},
646646
},
647-
nodeStageScript: `__grpcCode.DEADLINEEXCEEDED;`,
647+
nodeStageScript: `DEADLINEEXCEEDED;`,
648648
},
649649
{
650650
// After NodeUnstage with final error, kubelet can be sure the volume is not staged.
@@ -656,16 +656,16 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
656656
// This matches all repeated NodeStage calls with InvalidArgument error (due to exp. backoff).
657657
{expectedMethod: "NodeStageVolume", expectedError: codes.InvalidArgument, deletePod: true},
658658
},
659-
nodeStageScript: `__grpcCode.INVALIDARGUMENT;`,
659+
nodeStageScript: `INVALIDARGUMENT;`,
660660
},
661661
}
662662
for _, t := range tests {
663663
test := t
664664
ginkgo.It(test.name, func() {
665665
scripts := map[string]string{
666-
"Globals": globalScript,
667-
"NodeStageVolumeStart": test.nodeStageScript,
668-
"NodeUnstageVolumeStart": test.nodeUnstageScript,
666+
"globals": globalScript,
667+
"nodeStageVolumeStart": test.nodeStageScript,
668+
"nodeUnstageVolumeStart": test.nodeUnstageScript,
669669
}
670670
init(testParameters{
671671
disableAttach: true,
@@ -706,7 +706,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
706706
}
707707

708708
ginkgo.By("Deleting the previously created pod")
709-
err := e2epod.DeletePodWithWait(m.cs, pod)
709+
err = e2epod.DeletePodWithWait(m.cs, pod)
710710
framework.ExpectNoError(err, "while deleting")
711711

712712
ginkgo.By("Waiting for all remaining expected CSI calls")
@@ -865,7 +865,7 @@ type mockCSICall struct {
865865
Request struct {
866866
VolumeContext map[string]string `json:"volume_context"`
867867
}
868-
Error struct {
868+
FullError struct {
869869
Code codes.Code `json:"code"`
870870
Message string `json:"message"`
871871
}
@@ -988,7 +988,7 @@ func compareCSICalls(trackedCalls []string, expectedCallSequence []csiCall, cs c
988988
if !tracked.Has(c.Method) {
989989
continue
990990
}
991-
if c.Method != last.Method || c.Error.Code != last.Error.Code {
991+
if c.Method != last.Method || c.FullError.Code != last.FullError.Code {
992992
last = c
993993
calls = append(calls, c)
994994
}
@@ -998,14 +998,14 @@ func compareCSICalls(trackedCalls []string, expectedCallSequence []csiCall, cs c
998998
for i, c := range calls {
999999
if i >= len(expectedCallSequence) {
10001000
// Log all unexpected calls first, return error below outside the loop.
1001-
framework.Logf("Unexpected CSI driver call: %s (%d)", c.Method, c.Error)
1001+
framework.Logf("Unexpected CSI driver call: %s (%d)", c.Method, c.FullError)
10021002
continue
10031003
}
10041004

10051005
// Compare current call with expected call
10061006
expectedCall := expectedCallSequence[i]
1007-
if c.Method != expectedCall.expectedMethod || c.Error.Code != expectedCall.expectedError {
1008-
return i, fmt.Errorf("Unexpected CSI call %d: expected %s (%d), got %s (%d)", i, expectedCall.expectedMethod, expectedCall.expectedError, c.Method, c.Error.Code)
1007+
if c.Method != expectedCall.expectedMethod || c.FullError.Code != expectedCall.expectedError {
1008+
return i, fmt.Errorf("Unexpected CSI call %d: expected %s (%d), got %s (%d)", i, expectedCall.expectedMethod, expectedCall.expectedError, c.Method, c.FullError.Code)
10091009
}
10101010
}
10111011
if len(calls) > len(expectedCallSequence) {

0 commit comments

Comments
 (0)