Skip to content

Commit

Permalink
Fix races in snapshot integration test (#146)
Browse files Browse the repository at this point in the history
This test failed more often than not in my local testing.
Previously we only waited for the pod to be running
which didn't guarantee the file had been created, nor
that it had been sync'ed to the block device.
  • Loading branch information
jcodybaker committed Apr 26, 2019
1 parent f0f9e08 commit 9e9f3f5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/kubernetes/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,24 @@ func TestSnapshot_Create(t *testing.T) {
Name: "my-csi-app-2",
},
Spec: v1.PodSpec{
// Write the data in an InitContainer so that we can guarantee
// it's been written before we reach running in the main container.
InitContainers: []v1.Container{
{
Name: "my-csi",
Image: "busybox",
VolumeMounts: []v1.VolumeMount{
{
MountPath: "/data",
Name: volumeName,
},
},
Command: []string{
"sh", "-c",
"echo testcanary > /data/canary && sync",
},
},
},
Containers: []v1.Container{
{
Name: "my-csi-app",
Expand All @@ -370,7 +388,7 @@ func TestSnapshot_Create(t *testing.T) {
},
Command: []string{
"sh", "-c",
"echo testcanary > /data/canary && sleep 1000000",
"sleep 1000000",
},
},
},
Expand Down

0 comments on commit 9e9f3f5

Please sign in to comment.