test(general): Use new kopia upgrade cli in robustness upgrade tests (#2355)

* Use new kopia upgrade cli

* Clean up environement variable

* Clean up environement variable

* Clean up debugging change

* Fix lint errors

* Fix lint errors
This commit is contained in:
chaitalisg
2022-09-20 14:00:53 -07:00
committed by GitHub
parent a0a711cda1
commit b626f148ee
2 changed files with 17 additions and 1 deletions

View File

@@ -70,6 +70,9 @@ func TestMain(m *testing.M) {
curr := rs.ContentFormat.MutableParameters.Version
log.Println("Upgraded repository format:", curr)
// Reset the env variable.
os.Setenv("KOPIA_UPGRADE_LOCK_ENABLED", "")
}
// run the tests
@@ -216,6 +219,8 @@ func (th *kopiaRobustnessTestHarness) getEngine() bool {
}
func (th *kopiaRobustnessTestHarness) cleanup(ctx context.Context) (retErr error) {
os.Setenv("KOPIA_UPGRADE_LOCK_ENABLED", "")
if th.engine != nil {
retErr = th.engine.Shutdown(ctx)
}

View File

@@ -8,6 +8,7 @@
"encoding/json"
"io"
"log"
"os"
"os/exec"
"strconv"
@@ -200,7 +201,17 @@ func (ks *KopiaSnapshotter) GetRepositoryStatus() (cli.RepositoryStatus, error)
// UpgradeRepository upgrades the given kopia repository
// from current format version to latest stable format version.
func (ks *KopiaSnapshotter) UpgradeRepository() error {
_, _, err := ks.snap.Run("repository", "set-parameters", "--upgrade")
// This variable is also reset in cleanup function
// in case the test fails
os.Setenv("KOPIA_UPGRADE_LOCK_ENABLED", "1")
_, _, err := ks.snap.Run("repository", "upgrade",
"--upgrade-owner-id", "robustness-tests",
"--io-drain-timeout", "30s", "--allow-unsafe-upgrade",
"--status-poll-interval", "1s")
// cleanup
os.Setenv("KOPIA_UPGRADE_LOCK_ENABLED", "")
return err
}