Пример #1
0
        public void MountFailsUpgradingFromInvalidUpgradePath(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            string headCommitId = GitProcess.Invoke(this.Enlistment.RepoRoot, "rev-parse HEAD");

            this.Enlistment.UnmountGSD();

            string majorVersion;
            string minorVersion;

            GSDHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGSDRoot, out majorVersion, out minorVersion);

            int majorVersionNum;
            int minorVersionNum;

            int.TryParse(majorVersion.ShouldNotBeNull(), out majorVersionNum).ShouldEqual(true);
            int.TryParse(minorVersion.ShouldNotBeNull(), out minorVersionNum).ShouldEqual(true);

            // 1 will always be below the minumum support version number
            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, "1", "0");
            this.MountShouldFail("Breaking change to GSD disk layout has been made since cloning", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, majorVersionNum.ToString(), minorVersionNum.ToString());
            this.Enlistment.MountGSD();
        }
Пример #2
0
        public void MountFailsWhenNoGitObjectsRootInRepoMetadata()
        {
            this.Enlistment.UnmountGSD();

            string majorVersion;
            string minorVersion;

            GSDHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGSDRoot, out majorVersion, out minorVersion);
            majorVersion.ShouldNotBeNull();
            minorVersion.ShouldNotBeNull();

            string localCacheRoot = GSDHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGSDRoot).ShouldNotBeNull();

            string metadataPath       = Path.Combine(this.Enlistment.DotGSDRoot, GSDHelpers.RepoMetadataName);
            string metadataBackupPath = metadataPath + ".backup";

            this.fileSystem.MoveFile(metadataPath, metadataBackupPath);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, majorVersion, minorVersion);
            GSDHelpers.SaveLocalCacheRoot(this.Enlistment.DotGSDRoot, localCacheRoot);

            this.MountShouldFail("Failed to determine git objects root from repo metadata");

            this.fileSystem.DeleteFile(metadataPath);
            this.fileSystem.MoveFile(metadataBackupPath, metadataPath);

            this.Enlistment.MountGSD();
        }
Пример #3
0
 public void MountFailsIfBeforeMinimumVersion()
 {
     // Mount should fail if on disk version is below minimum supported version
     this.Enlistment.UnmountGSD();
     GSDHelpers.SaveDiskLayoutVersion(
         this.Enlistment.DotGSDRoot,
         (this.currentDiskMinimumMajorVersion - 1).ToString(),
         CurrentDiskLayoutMinorVersion.ToString());
     this.Enlistment.TryMountGSD().ShouldBeFalse("Mount should fail because we are before minimum version");
 }
Пример #4
0
        public void MountSucceedsIfMinorVersionHasAdvancedButNotMajorVersion()
        {
            // Advance the minor version, mount should still work
            this.Enlistment.UnmountGSD();
            GSDHelpers.SaveDiskLayoutVersion(
                this.Enlistment.DotGSDRoot,
                this.currentDiskMajorVersion.ToString(),
                (CurrentDiskLayoutMinorVersion + 1).ToString());
            this.Enlistment.TryMountGSD().ShouldBeTrue("Mount should succeed because only the minor version advanced");

            // Advance the major version, mount should fail
            this.Enlistment.UnmountGSD();
            GSDHelpers.SaveDiskLayoutVersion(
                this.Enlistment.DotGSDRoot,
                (this.currentDiskMajorVersion + 1).ToString(),
                CurrentDiskLayoutMinorVersion.ToString());
            this.Enlistment.TryMountGSD().ShouldBeFalse("Mount should fail because the major version has advanced");
        }
Пример #5
0
        public void MountFailsAfterBreakingDowngrade(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGSD();

            string majorVersion;
            string minorVersion;

            GSDHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGSDRoot, out majorVersion, out minorVersion);

            int majorVersionNum;
            int minorVersionNum;

            int.TryParse(majorVersion.ShouldNotBeNull(), out majorVersionNum).ShouldEqual(true);
            int.TryParse(minorVersion.ShouldNotBeNull(), out minorVersionNum).ShouldEqual(true);

            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, (majorVersionNum + 1).ToString(), "0");

            this.MountShouldFail("do not allow mounting after downgrade", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, majorVersionNum.ToString(), minorVersionNum.ToString());
            this.Enlistment.MountGSD();
        }