Skip to content

Commit

Permalink
csi: fix filesystem write paths in e2e tests
Browse files Browse the repository at this point in the history
The writer jobs for the CSI e2e tests will write to locations in the
alloc dir and not arbitrary locations at the root. This changeset
mounts the CSI volume at a location within the alloc dir, uses the
alloc ID as a better-namespaced identifier of the file we write, and
corrects the shell used by the busybox container.
  • Loading branch information
tgross committed Mar 17, 2020
1 parent 5033464 commit 1bc808b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
34 changes: 17 additions & 17 deletions e2e/csi/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func (tc *CSIVolumesTest) TestEBSVolumeClaim(f *framework.F) {
uuid := uuid.Generate()

// deploy the controller plugin job
controllerJobID := "aws-ebs-plugin-controller" + uuid[0:8]
controllerJobID := "aws-ebs-plugin-controller-" + uuid[0:8]
tc.jobIds = append(tc.jobIds, controllerJobID)
e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/plugin-aws-ebs-controller.nomad", controllerJobID, "")

// deploy the node plugins job
nodesJobID := "aws-ebs-plugin-nodes" + uuid[0:8]
nodesJobID := "aws-ebs-plugin-nodes-" + uuid[0:8]
tc.jobIds = append(tc.jobIds, nodesJobID)
e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/plugin-aws-ebs-nodes.nomad", nodesJobID, "")
Expand Down Expand Up @@ -106,25 +106,25 @@ func (tc *CSIVolumesTest) TestEBSVolumeClaim(f *framework.F) {
defer nomadClient.CSIVolumes().Deregister(volID, nil)

// deploy a job that writes to the volume
writeJobID := "write-" + uuid[0:8]
e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
writeJobID := "write-ebs-" + uuid[0:8]
writeAllocs := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/use-ebs-volume.nomad", writeJobID, "")

// we could mount the EBS volume with multi-attach, but we
// want this test to exercise the unpublish workflow.
nomadClient.Jobs().Deregister(writeJobID, true, nil)

// deploy a job so we can read from the volume
readJobID := "read-" + uuid[0:8]
allocs := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
readJobID := "read-ebs-" + uuid[0:8]
readAllocs := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/use-ebs-volume.nomad", readJobID, "")
defer nomadClient.Jobs().Deregister(readJobID, true, nil)

// read data from volume and assert the writer wrote a file to it
alloc, _, err := nomadClient.Allocations().Info(allocs[0].ID, nil)
readAlloc, _, err := nomadClient.Allocations().Info(readAllocs[0].ID, nil)
require.NoError(err)
expectedPath := "/test/" + writeJobID
_, _, err = nomadClient.AllocFS().Stat(alloc, expectedPath, nil)
expectedPath := "test/" + writeAllocs[0].ID // relative to alloc dir
_, _, err = nomadClient.AllocFS().Stat(readAlloc, expectedPath, nil)
require.NoError(err)
}

Expand All @@ -138,7 +138,7 @@ func (tc *CSIVolumesTest) TestEFSVolumeClaim(f *framework.F) {
uuid := uuid.Generate()

// deploy the node plugins job (no need for a controller for EFS)
nodesJobID := "aws-efs-plugin-nodes" + uuid[0:8]
nodesJobID := "aws-efs-plugin-nodes-" + uuid[0:8]
tc.jobIds = append(tc.jobIds, nodesJobID)
e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/plugin-aws-efs-nodes.nomad", nodesJobID, "")
Expand Down Expand Up @@ -172,24 +172,24 @@ func (tc *CSIVolumesTest) TestEFSVolumeClaim(f *framework.F) {
defer nomadClient.CSIVolumes().Deregister(volID, nil)

// deploy a job that writes to the volume
writeJobID := "write-" + uuid[0:8]
e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
writeJobID := "write-efs-" + uuid[0:8]
writeAllocs := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/use-efs-volume-write.nomad", writeJobID, "")
defer nomadClient.Jobs().Deregister(writeJobID, true, nil)

// deploy a job that reads from the volume. we don't stop the
// writer job in this case because we want to exercise
// a multiple-access mode
readJobID := "read-" + uuid[0:8]
allocs := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
readJobID := "read-efs-" + uuid[0:8]
readAllocs := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient,
"csi/input/use-efs-volume-read.nomad", readJobID, "")
defer nomadClient.Jobs().Deregister(readJobID, true, nil)

// read data from volume and assert the writer wrote a file to it
alloc, _, err := nomadClient.Allocations().Info(allocs[0].ID, nil)
readAlloc, _, err := nomadClient.Allocations().Info(readAllocs[0].ID, nil)
require.NoError(err)
expectedPath := "/test/" + writeJobID
_, _, err = nomadClient.AllocFS().Stat(alloc, expectedPath, nil)
expectedPath := "test/" + writeAllocs[0].ID // relative to alloc dir
_, _, err = nomadClient.AllocFS().Stat(readAlloc, expectedPath, nil)
require.NoError(err)
}

Expand Down
6 changes: 3 additions & 3 deletions e2e/csi/input/use-ebs-volume.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ job "use-ebs-volume" {

config {
image = "busybox:1"
command = "bash"
args = ["-c", "touch /test/${NOMAD_JOB_NAME}; sleep 3600"]
command = "/bin/sh"
args = ["-c", "touch /alloc/test/${NOMAD_ALLOC_ID}; sleep 3600"]
}

volume_mount {
volume = "test"
destination = "/test"
destination = "${NOMAD_ALLOC_DIR}/test"
read_only = false
}

Expand Down
4 changes: 2 additions & 2 deletions e2e/csi/input/use-efs-volume-read.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ job "use-efs-volume" {

config {
image = "busybox:1"
command = "bash"
command = "/bin/sh"
args = ["-c", "sleep 3600"]
}

volume_mount {
volume = "test"
destination = "/test"
destination = "${NOMAD_ALLOC_DIR}/test"
read_only = true
}

Expand Down
6 changes: 3 additions & 3 deletions e2e/csi/input/use-efs-volume-write.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ job "use-efs-volume" {

config {
image = "busybox:1"
command = "bash"
args = ["-c", "touch /test/${NOMAD_JOB_NAME}; sleep 3600"]
command = "/bin/sh"
args = ["-c", "touch /alloc/test/${NOMAD_ALLOC_ID}; sleep 3600"]
}

volume_mount {
volume = "test"
destination = "/test"
destination = "${NOMAD_ALLOC_DIR}/test"
read_only = false
}

Expand Down

0 comments on commit 1bc808b

Please sign in to comment.