(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestBlobShardsModify(t *testing.T) { |
| 15 | env := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, testenv.NewInProcRunner(t)) |
| 16 | |
| 17 | env.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", env.RepoDir) |
| 18 | |
| 19 | someQBlob := strings.Split(env.RunAndExpectSuccess(t, "blob", "list", "--prefix=q")[0], " ")[0] |
| 20 | |
| 21 | // verify default sharding is 1,3 |
| 22 | require.FileExists(t, filepath.Join(env.RepoDir, someQBlob[0:1], someQBlob[1:4], someQBlob[4:]+sharded.CompleteBlobSuffix)) |
| 23 | require.FileExists(t, filepath.Join(env.RepoDir, "kopia.repository.f")) |
| 24 | |
| 25 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--default-shards=5,5", "--i-am-sure-kopia-is-not-running") |
| 26 | |
| 27 | // verify new sharding is 5,5 |
| 28 | require.FileExists(t, filepath.Join(env.RepoDir, someQBlob[0:5], someQBlob[5:10], someQBlob[10:]+sharded.CompleteBlobSuffix)) |
| 29 | require.NoFileExists(t, filepath.Join(env.RepoDir, someQBlob[0:3], someQBlob[3:6], someQBlob[6:]+sharded.CompleteBlobSuffix)) |
| 30 | require.FileExists(t, filepath.Join(env.RepoDir, "kopia.repository.f")) |
| 31 | |
| 32 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--unsharded-length=0", "--i-am-sure-kopia-is-not-running") |
| 33 | |
| 34 | require.FileExists(t, filepath.Join(env.RepoDir, someQBlob[0:5], someQBlob[5:10], someQBlob[10:]+sharded.CompleteBlobSuffix)) |
| 35 | require.FileExists(t, filepath.Join(env.RepoDir, "kopia/.repo/sitory.f")) |
| 36 | require.NoFileExists(t, filepath.Join(env.RepoDir, "kopia.repository.f")) |
| 37 | |
| 38 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=kop=2,,,2", "--i-am-sure-kopia-is-not-running") |
| 39 | require.FileExists(t, filepath.Join(env.RepoDir, "ko/pi/a.repository.f")) |
| 40 | require.NoFileExists(t, filepath.Join(env.RepoDir, "kopia.repository.f")) |
| 41 | |
| 42 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--remove-override=nosuchprefix", "--remove-override=kop", "--i-am-sure-kopia-is-not-running") |
| 43 | require.FileExists(t, filepath.Join(env.RepoDir, "kopia/.repo/sitory.f")) |
| 44 | |
| 45 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--i-am-sure-kopia-is-not-running") |
| 46 | |
| 47 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=kop=flat", "--i-am-sure-kopia-is-not-running", "--dry-run") |
| 48 | require.FileExists(t, filepath.Join(env.RepoDir, "kopia/.repo/sitory.f")) |
| 49 | |
| 50 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=kop=flat", "--i-am-sure-kopia-is-not-running") |
| 51 | require.FileExists(t, filepath.Join(env.RepoDir, "kopia.repository.f")) |
| 52 | |
| 53 | env.RunAndExpectSuccess(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=kop=4,4", "--i-am-sure-kopia-is-not-running") |
| 54 | require.FileExists(t, filepath.Join(env.RepoDir, "kopi/a.re/pository.f")) |
| 55 | |
| 56 | // some invalid cases |
| 57 | env.RunAndExpectFailure(t, "blob", "shards", "modify", "--path", env.RepoDir, "--default-shards=invalid", "--i-am-sure-kopia-is-not-running") |
| 58 | env.RunAndExpectFailure(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=x", "--i-am-sure-kopia-is-not-running") |
| 59 | env.RunAndExpectFailure(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=x=aaa", "--i-am-sure-kopia-is-not-running") |
| 60 | env.RunAndExpectFailure(t, "blob", "shards", "modify", "--path", env.RepoDir, "--override=2,-1", "--i-am-sure-kopia-is-not-running") |
| 61 | } |
nothing calls this directly
no test coverage detected