Skip to content

Commit

Permalink
Remove redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
udnay committed Feb 11, 2025
1 parent 7218974 commit b685b03
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions test/cached_csi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,82 +119,6 @@ func TestCachedCSIDriverMountsCache(t *testing.T) {
require.NoError(t, err)
}

func TestCachedCSIDriverMountsCacheAtSuffix(t *testing.T) {
tc := util.NewTestCtx(t, auth.Admin, 1)
defer tc.Close()

writeProject(tc, 1, 2)
writeObject(tc, 1, 1, i(2), "a", "a v1")
aHash := writePackedFiles(tc, 1, 1, nil, "pack/a")
bHash := writePackedFiles(tc, 1, 1, nil, "pack/b")
version, err := db.CreateCache(tc.Context(), tc.Connect(), "", 100)
require.NoError(t, err)

tmpDir := emptyTmpDir(t)
defer os.RemoveAll(tmpDir)

cached, _, close := createTestCachedServer(tc, tmpDir)
defer close()

err = cached.Prepare(tc.Context())
require.NoError(t, err, "cached.Prepare must succeed")

targetDir := path.Join(tmpDir, "vol-target")

stagingDir := path.Join(tmpDir, "vol-staging-target")
_, err = cached.NodePublishVolume(tc.Context(), &csi.NodePublishVolumeRequest{
VolumeId: "foobar",
StagingTargetPath: stagingDir,
TargetPath: targetDir,
VolumeCapability: &csi.VolumeCapability{},
VolumeContext: map[string]string{},
})
require.NoError(t, err)

verifyDir(t, path.Join(tmpDir, "vol-target"), -1, map[string]expectedFile{
fmt.Sprintf("dl_cache/objects/%v/pack/a/1", aHash): {content: "pack/a/1 v1"},
fmt.Sprintf("dl_cache/objects/%v/pack/a/2", aHash): {content: "pack/a/2 v1"},
fmt.Sprintf("dl_cache/objects/%v/pack/b/1", bHash): {content: "pack/b/1 v1"},
fmt.Sprintf("dl_cache/objects/%v/pack/b/2", bHash): {content: "pack/b/2 v1"},
"dl_cache/versions": {content: fmt.Sprintf("%v\n", version)},
})

// Check to see that we have created the upper and work directories
require.DirExists(t, path.Join(tmpDir, api.UPPER_DIR))
require.DirExists(t, path.Join(tmpDir, api.WORK_DIR))

upperInfo, err := os.Stat(path.Join(tmpDir, api.UPPER_DIR))
require.NoError(t, err)
require.Equal(t, formatFileMode(os.FileMode(0777)), formatFileMode(upperInfo.Mode()&os.ModePerm))

workInfo, err := os.Stat(path.Join(tmpDir, api.WORK_DIR))
require.NoError(t, err)
require.Equal(t, formatFileMode(os.FileMode(0777)), formatFileMode(workInfo.Mode()&os.ModePerm))

fileInfo, err := os.Stat(targetDir)
require.NoError(t, err)

// the target dir *should* be world writable -- we're going to use it as a scratch space to do useful stuff with the cache
require.Equal(t, formatFileMode(os.FileMode(0777)), formatFileMode(fileInfo.Mode()&os.ModePerm))

// the cache dir should *not* be writable -- it's managed by the CSI and must remain pristine
cacheFileInfo, err := os.Stat(path.Join(targetDir, "dl_cache"))
require.NoError(t, err)
require.Equal(t, formatFileMode(os.FileMode(0755)), formatFileMode(cacheFileInfo.Mode()&os.ModePerm))

// files inside cache dir should *not* be writable -- it's managed by the CSI and must remain pristine
cacheFileInfo, err = os.Stat(path.Join(targetDir, fmt.Sprintf("dl_cache/objects/%v/pack/a/1", aHash)))
require.NoError(t, err)
require.Equal(t, formatFileMode(os.FileMode(0755)), formatFileMode(cacheFileInfo.Mode()))
require.Equal(t, targetDir, path.Join(tmpDir, "vol-target"))

_, err = cached.NodeUnpublishVolume(tc.Context(), &csi.NodeUnpublishVolumeRequest{
VolumeId: "foobar",
TargetPath: targetDir,
})
require.NoError(t, err)
}

func TestCachedCSIDriverProbeFailsUntilPrepared(t *testing.T) {
tc := util.NewTestCtx(t, auth.Admin, 1)
defer tc.Close()
Expand Down

0 comments on commit b685b03

Please sign in to comment.