Repository: kopia/kopia
Pull request #3990 (2024-07-17 03:30:24)

refactor(general): `setCacheSizeHardLimit` helper in robustness

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/kopia/kopia/pull/3990?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.20%. Comparing base [(`cb455c6`)](https://app.codecov.io/gh/kopia/kopia/commit/cb455c699a04e54cb47e25a676d7d65063ce883e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) to head [(`86a6c34`)](https://app.codecov.io/gh/kopia/kopia/commit/86a6c3488a2b61a0287f084c546943dbe6a9f56b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).
> Report is 201 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3990      +/-   ##
==========================================
+ Coverage   75.86%   77.20%   +1.33%     
==========================================
  Files         470      483      +13     
  Lines       37301    28851    -8450     
==========================================
- Hits        28299    22274    -6025     
+ Misses       7071     4669    -2402     
+ Partials     1931     1908      -23     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/kopia/kopia/pull/3990?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).


Patch:
diff --git a/go.mod b/go.mod
index 4e193ebc..8ed4c975 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ toolchain go1.22.5
 
 require (
 	cloud.google.com/go/storage v1.43.0
-	github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0
+	github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0
 	github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
 	github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2
 	github.com/alecthomas/kingpin/v2 v2.4.0
@@ -76,7 +76,7 @@ require (
 	cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
 	cloud.google.com/go/compute/metadata v0.4.0 // indirect
 	cloud.google.com/go/iam v1.1.10 // indirect
-	github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 // indirect
+	github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
 	github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
 	github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 // indirect
 	github.com/alessio/shellescape v1.4.1 // indirect
diff --git a/go.sum b/go.sum
index dc56d6a6..e2ff2c4f 100644
--- a/go.sum
+++ b/go.sum
@@ -13,12 +13,12 @@ cloud.google.com/go/longrunning v0.5.9 h1:haH9pAuXdPAMqHvzX0zlWQigXT7B0+CL4/2nXX
 cloud.google.com/go/longrunning v0.5.9/go.mod h1:HD+0l9/OOW0za6UWdKJtXoFAX/BGg/3Wj8p10NeWF7c=
 cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs=
 cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0=
-github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 h1:1nGuui+4POelzDwI7RG56yfQJHCnKvwfMoU7VsEp+Zg=
-github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0/go.mod h1:99EvauvlcJ1U06amZiksfYz/3aFGyIhWGHVyiZXtBAI=
+github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww=
+github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0=
 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc=
 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg=
-github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 h1:H+U3Gk9zY56G3u872L82bk4thcsy2Gghb9ExT4Zvm1o=
-github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0/go.mod h1:mgrmMSgaLp9hmax62XQTd0N4aAqSE5E0DulSpVYK7vc=
+github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
+github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0 h1:AifHbc4mg0x9zW52WOpKbsHaDKuRhlI7TVl47thgQ70=
 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0/go.mod h1:T5RfihdXtBDxt1Ch2wobif3TvzTdumDy29kahv6AV9A=
 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2 h1:YUUxeiOWgdAQE3pXt2H7QXzZs0q8UBjgRbl56qo8GYM=


Test patch:
diff --git a/tests/robustness/multiclient_test/framework/harness.go b/tests/robustness/multiclient_test/framework/harness.go
index 7f533064..3d08663a 100644
--- a/tests/robustness/multiclient_test/framework/harness.go
+++ b/tests/robustness/multiclient_test/framework/harness.go
@@ -145,16 +145,14 @@ func (th *TestHarness) getSnapshotter() bool {
 
 	if err = s.ConnectOrCreateRepo(th.dataRepoPath); err != nil {
 		log.Println("Error initializing kopia Snapshotter:", err)
+
 		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)
+	if err = s.setCacheSizeLimits(contentCacheLimitMB, metadataCacheLimitMB); err != nil {
+		log.Println("Error setting hard cache size limits for kopia snapshotter:", err)
+
 		return false
 	}
 
diff --git a/tests/robustness/multiclient_test/framework/snapshotter.go b/tests/robustness/multiclient_test/framework/snapshotter.go
index 59b96551..3ab63eb6 100644
--- a/tests/robustness/multiclient_test/framework/snapshotter.go
+++ b/tests/robustness/multiclient_test/framework/snapshotter.go
@@ -72,20 +72,12 @@ 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 {
+// setCacheSizeLimits sets hard size limits for the content and metadata caches
+// on an already connected repository.
+func (mcs *MultiClientSnapshotter) setCacheSizeLimits(contentLimitSizeMB, metadataLimitSizeMB 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))
+		metadataCacheLimitMBFlag, strconv.Itoa(metadataLimitSizeMB),
+		contentCacheLimitMBFlag, strconv.Itoa(contentLimitSizeMB))
 
 	return err
 }