diff --git a/tests/robustness/multiclient_test/framework/harness.go b/tests/robustness/multiclient_test/framework/harness.go index 36f2ff99f..7f5330648 100644 --- a/tests/robustness/multiclient_test/framework/harness.go +++ b/tests/robustness/multiclient_test/framework/harness.go @@ -23,8 +23,10 @@ ) const ( - dataSubPath = "robustness-data" - metadataSubPath = "robustness-metadata" + dataSubPath = "robustness-data" + metadataSubPath = "robustness-metadata" + contentCacheLimitMB = 500 + metadataCacheLimitMB = 500 ) var repoPathPrefix = flag.String("repo-path-prefix", "", "Point the robustness tests at this path prefix") @@ -146,6 +148,16 @@ func (th *TestHarness) getSnapshotter() bool { return false } + // Set size limits for content cache and metadata cache for repository under test. + if err = s.setContentCacheSizeLimit(contentCacheLimitMB); err != nil { + log.Println("Error setting content cache size limits for kopia Snapshotter:", err) + return false + } + if err = s.setMetadataCacheSizeLimit(metadataCacheLimitMB); err != nil { + log.Println("Error setting metadata cache size limits for kopia Snapshotter:", err) + return false + } + return true } diff --git a/tests/robustness/multiclient_test/framework/snapshotter.go b/tests/robustness/multiclient_test/framework/snapshotter.go index c73e52a30..59b965514 100644 --- a/tests/robustness/multiclient_test/framework/snapshotter.go +++ b/tests/robustness/multiclient_test/framework/snapshotter.go @@ -16,6 +16,11 @@ "github.com/kopia/kopia/tests/robustness/snapmeta" ) +const ( + contentCacheLimitMBFlag = "--content-cache-size-limit-mb" + metadataCacheLimitMBFlag = "--metadata-cache-size-limit-mb" +) + // MultiClientSnapshotter manages a set of client Snapshotter instances and // implements the Snapshotter interface itself. Snapshotter methods must be // provided with a client-wrapped context so the MultiClientSnapshotter can @@ -67,6 +72,24 @@ func (mcs *MultiClientSnapshotter) ConnectOrCreateRepo(repoPath string) error { return err } +// setCacheSizeLimits sets the content cache size limits for an existing repository +// the repository server is connected to. +func (mcs *MultiClientSnapshotter) setContentCacheSizeLimit(contentCacheSizeLimitMB int) error { + _, _, err := mcs.server.Run("cache", "set", + contentCacheLimitMBFlag, strconv.Itoa(contentCacheSizeLimitMB), + ) + + return err +} + +// setMetadataCacheSizeLimit sets the metadata cache size limits for an existing repository, the repository server is connected to. +func (mcs *MultiClientSnapshotter) setMetadataCacheSizeLimit(metadataCacheSizeLimitMB int) error { + _, _, err := mcs.server.Run("cache", "set", + metadataCacheLimitMBFlag, strconv.Itoa(metadataCacheSizeLimitMB)) + + return err +} + // ServerCmd returns the server command. func (mcs *MultiClientSnapshotter) ServerCmd() *exec.Cmd { return mcs.server.ServerCmd()