Ejemplo n.º 1
0
        public void MountUpgradesFromEsentDatabasesToFlatDatabases()
        {
            this.Enlistment.UnmountGVFS();

            // Delete the existing background ops data
            string flatBackgroundPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.BackgroundOpsFile);

            flatBackgroundPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(flatBackgroundPath);

            // Delete the existing placeholder data
            string flatPlaceholdersPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.PlaceholderListFile);

            flatPlaceholdersPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(flatPlaceholdersPath);

            GVFSHelpers.CreateEsentBackgroundOpsDatabase(this.Enlistment.DotGVFSRoot);
            GVFSHelpers.CreateEsentPlaceholderDatabase(this.Enlistment.DotGVFSRoot);

            // Nine is the last version with ESENT BackgroundOps and Placeholders DBs
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "9");
            this.Enlistment.MountGVFS();

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot)
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutVersion);

            flatBackgroundPath.ShouldBeAFile(this.fileSystem);
            flatPlaceholdersPath.ShouldBeAFile(this.fileSystem);
        }
Ejemplo n.º 2
0
        public void MountFailsWhenNoGitObjectsRootInRepoMetadata()
        {
            this.Enlistment.UnmountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);
            majorVersion.ShouldNotBeNull();
            minorVersion.ShouldNotBeNull();

            string localCacheRoot = GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();

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

            this.fileSystem.MoveFile(metadataPath, metadataBackupPath);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, majorVersion, minorVersion);
            GVFSHelpers.SaveLocalCacheRoot(this.Enlistment.DotGVFSRoot, localCacheRoot);

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

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

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 3
0
        private void RunEsentRepoMetadataUpgradeTest(string sourceVersion)
        {
            this.Enlistment.UnmountGVFS();

            // Delete the existing repo metadata
            string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            versionJsonPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(versionJsonPath);

            GVFSHelpers.SaveDiskLayoutVersionAsEsentDatabase(this.Enlistment.DotGVFSRoot, sourceVersion);
            string esentDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.EsentRepoMetadataFolder);

            esentDatabasePath.ShouldBeADirectory(this.fileSystem);

            // We should be able to mount, and there should no longer be any Esent Repo Metadata
            this.Enlistment.MountGVFS();
            esentDatabasePath.ShouldNotExistOnDisk(this.fileSystem);
            versionJsonPath.ShouldBeAFile(this.fileSystem);

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot)
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutVersion, "Disk layout version should be upgraded to the latest");

            GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot)
            .ShouldEqual(string.Empty, "LocalCacheRoot should be an empty string when upgrading from a version prior to 12");

            // We're starting with fresh enlisments, and so the legacy cache location: <root>\.gvfs\gitObjectCache should not be on disk
            Path.Combine(this.Enlistment.DotGVFSRoot, @".gvfs\gitObjectCache").ShouldNotExistOnDisk(this.fileSystem);

            // The upgrader should set GitObjectsRoot to src\.git\objects (because the legacy cache location is not on disk)
            GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot)
            .ShouldNotBeNull("GitObjectsRoot should not be null")
            .ShouldEqual(Path.Combine(this.Enlistment.RepoRoot, @".git\objects"));
        }
Ejemplo n.º 4
0
        public void MountSucceedsUpgradeToAlwaysExclude()
        {
            this.Enlistment.UnmountGVFS();

            string originalVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    originalVersionNum;

            int.TryParse(originalVersion, out originalVersionNum).ShouldEqual(true);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (AlwaysExcludeOnDiskVersion - 1).ToString());
            string excludeVirtualPath       = this.Enlistment.GetVirtualPathTo(ExcludePath);
            string alwaysExcludeVirtualPath = this.Enlistment.GetVirtualPathTo(AlwaysExcludePath);

            excludeVirtualPath.ShouldBeAFile(this.fileSystem);
            alwaysExcludeVirtualPath.ShouldBeAFile(this.fileSystem);
            string originalAlwaysExcludeContents = this.fileSystem.ReadAllText(alwaysExcludeVirtualPath);

            this.fileSystem.DeleteFile(excludeVirtualPath);
            this.fileSystem.MoveFile(alwaysExcludeVirtualPath, excludeVirtualPath);

            this.Enlistment.MountGVFS();
            this.Enlistment.UnmountGVFS();

            excludeVirtualPath.ShouldBeAFile(this.fileSystem);
            alwaysExcludeVirtualPath.ShouldBeAFile(this.fileSystem);
            originalAlwaysExcludeContents.ShouldEqual(this.fileSystem.ReadAllText(alwaysExcludeVirtualPath));

            string finalVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    finalVersionNum;

            int.TryParse(finalVersion, out finalVersionNum).ShouldEqual(true);

            finalVersion.ShouldEqual(originalVersion);

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 5
0
        public void MountFailsWhenNoOnDiskVersion()
        {
            this.Enlistment.UnmountGVFS();

            // Get the current disk layout version
            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);

            // Move the RepoMetadata database to a temp folder
            string versionDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataDatabaseName);

            versionDatabasePath.ShouldBeADirectory(this.fileSystem);

            string tempDatabasePath = versionDatabasePath + "_MountFailsWhenNoOnDiskVersion";

            tempDatabasePath.ShouldNotExistOnDisk(this.fileSystem);

            this.fileSystem.MoveDirectory(versionDatabasePath, tempDatabasePath);
            versionDatabasePath.ShouldNotExistOnDisk(this.fileSystem);

            this.MountShouldFail("Enlistment disk layout version not found");

            // Move the RepoMetadata database back
            this.fileSystem.MoveDirectory(tempDatabasePath, versionDatabasePath);
            tempDatabasePath.ShouldNotExistOnDisk(this.fileSystem);
            versionDatabasePath.ShouldBeADirectory(this.fileSystem);

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 6
0
        public void MountFailsUpgradingFromInvalidUpgradePath(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            string headCommitId = GitProcess.Invoke(this.Enlistment.RepoRoot, "rev-parse HEAD");

            this.Enlistment.UnmountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, 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
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "1", "0");
            this.MountShouldFail("Breaking change to GVFS disk layout has been made since cloning", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, majorVersionNum.ToString(), minorVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 7
0
        public void MountFailsUpgradingFromCommitProjectionVersionWhereProjectedCommitIdDoesNotMatchHEAD(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            string headCommitId = GitProcess.Invoke(this.Enlistment.RepoRoot, "rev-parse HEAD");

            this.Enlistment.UnmountGVFS();

            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (ProjectGitIndexOnDiskVersion - 1).ToString());

            string gvfsHeadPath = Path.Combine(this.Enlistment.DotGVFSRoot, "GVFS_HEAD");

            gvfsHeadPath.ShouldNotExistOnDisk(this.fileSystem);

            // 575d597cf09b2cd1c0ddb4db21ce96979010bbcb is an earlier commit in the FunctionalTests/20170310 branch
            this.fileSystem.WriteAllText(gvfsHeadPath, "575d597cf09b2cd1c0ddb4db21ce96979010bbcb");

            this.MountShouldFail("Failed to mount", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            this.fileSystem.DeleteFile(gvfsHeadPath);
            this.fileSystem.WriteAllText(gvfsHeadPath, headCommitId);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
            gvfsHeadPath.ShouldNotExistOnDisk(this.fileSystem);
        }
Ejemplo n.º 8
0
        public void DehydrateShouldFailOnWrongDiskLayoutVersion()
        {
            this.Enlistment.UnmountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);

            int majorVersionNum;
            int minorVersionNum;

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

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (majorVersionNum - 1).ToString(), "0");
            this.DehydrateShouldFail("disk layout version doesn't match current version", noStatus: true);

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (majorVersionNum + 1).ToString(), "0");
            this.DehydrateShouldFail("Changes to GVFS disk layout do not allow mounting after downgrade.", noStatus: true);

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, majorVersionNum.ToString(), minorVersionNum.ToString());

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 9
0
        public void MountSetsGitObjectsRootToLegacyDotGVFSCache()
        {
            this.Enlistment.UnmountGVFS();

            // Delete the existing repo metadata
            string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            versionJsonPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(versionJsonPath);

            // "11" was the last version before the introduction of a volume wide GVFS cache
            string metadataPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "11");

            // Create the legacy cache location: <root>\.gvfs\gitObjectCache
            string legacyGitObjectsCachePath = Path.Combine(this.Enlistment.DotGVFSRoot, "gitObjectCache");

            this.fileSystem.CreateDirectory(legacyGitObjectsCachePath);

            this.Enlistment.MountGVFS();

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot)
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutVersion, "Disk layout version should be upgraded to the latest");

            GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot)
            .ShouldEqual(string.Empty, "LocalCacheRoot should be an empty string when upgrading from a version prior to 12");

            GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot)
            .ShouldEqual(legacyGitObjectsCachePath);
        }
Ejemplo n.º 10
0
        public void DehydrateShouldFailIfLocalCacheNotInMetadata()
        {
            this.Enlistment.UnmountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);
            string objectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();

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

            this.fileSystem.MoveFile(metadataPath, metadataBackupPath);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, majorVersion, minorVersion);
            GVFSHelpers.SaveGitObjectsRoot(this.Enlistment.DotGVFSRoot, objectsRoot);

            this.DehydrateShouldFail("Failed to determine local cache path from repo metadata", noStatus: true);

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

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 11
0
        public void MountUpgradesFromPriorToPlaceholderCreationsBlockedForGit()
        {
            this.Enlistment.UnmountGVFS();

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "10");

            this.Enlistment.MountGVFS();

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot)
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutVersion);
        }
Ejemplo n.º 12
0
        private void ValidatePersistedVersionMatchesCurrentVersion()
        {
            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);

            majorVersion
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutMajorVersion, "Disk layout version should be upgraded to the latest");

            minorVersion
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutMinorVersion, "Disk layout version should be upgraded to the latest");
        }
Ejemplo n.º 13
0
        public void MountFailsAfterBreakingDowngrade(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGVFS();

            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (currentVersionNum + 1).ToString());

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

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 14
0
        public void DehydrateShouldFailOnWrongDiskLayoutVersion()
        {
            this.Enlistment.UnmountGVFS();

            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (currentVersionNum - 1).ToString());
            this.DehydrateShouldFail("disk layout version doesn't match current version", noStatus: true);

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (currentVersionNum + 1).ToString());
            this.DehydrateShouldFail("disk layout version doesn't match current version", noStatus: true);

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString());

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 15
0
        public void MountSucceedsUpgradingFromCommitProjectionVersionWhereProjectedCommitIdMatchesHEAD(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGVFS();

            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (ProjectGitIndexOnDiskVersion - 1).ToString());

            string alwaysExcludeVirtualPath = this.Enlistment.GetVirtualPathTo(AlwaysExcludePath);

            this.fileSystem.DeleteFile(alwaysExcludeVirtualPath);

            this.Enlistment.MountGVFS();
            this.Enlistment.UnmountGVFS();

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 16
0
        public void MountFailsWhenNoOnDiskVersion()
        {
            this.Enlistment.UnmountGVFS();

            // Get the current disk layout version
            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);

            int majorVersionNum;
            int minorVersionNum;

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

            // Move the RepoMetadata database to a temp file
            string versionDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            versionDatabasePath.ShouldBeAFile(this.fileSystem);

            string tempDatabasePath = versionDatabasePath + "_MountFailsWhenNoOnDiskVersion";

            tempDatabasePath.ShouldNotExistOnDisk(this.fileSystem);

            this.fileSystem.MoveFile(versionDatabasePath, tempDatabasePath);
            versionDatabasePath.ShouldNotExistOnDisk(this.fileSystem);

            this.MountShouldFail("Failed to upgrade repo disk layout");

            // Move the RepoMetadata database back
            this.fileSystem.DeleteFile(versionDatabasePath);
            this.fileSystem.MoveFile(tempDatabasePath, versionDatabasePath);
            tempDatabasePath.ShouldNotExistOnDisk(this.fileSystem);
            versionDatabasePath.ShouldBeAFile(this.fileSystem);

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 17
0
        public void DehydrateShouldFailIfGitObjectsRootNotInMetadata()
        {
            this.Enlistment.UnmountGVFS();

            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            string localCacheRoot = GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();

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

            this.fileSystem.MoveFile(metadataPath, metadataBackupPath);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersion);
            GVFSHelpers.SaveLocalCacheRoot(this.Enlistment.DotGVFSRoot, localCacheRoot);

            this.DehydrateShouldFail("Failed to determine git objects root from repo metadata", noStatus: true);

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

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 18
0
        public void MountFailsWhenNoLocalCacheRootInRepoMetadata()
        {
            this.Enlistment.UnmountGVFS();

            string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();
            string objectsRoot    = GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot).ShouldNotBeNull();

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

            this.fileSystem.MoveFile(metadataPath, metadataBackupPath);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersion);
            GVFSHelpers.SaveGitObjectsRoot(this.Enlistment.DotGVFSRoot, objectsRoot);

            this.MountShouldFail("Failed to determine local cache path from repo metadata");

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

            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 19
0
        private void RunEsentRepoMetadataUpgradeTest(string sourceVersion)
        {
            this.Enlistment.UnmountGVFS();

            // Delete the existing repo metadata
            string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            versionJsonPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(versionJsonPath);

            GVFSHelpers.SaveDiskLayoutVersionAsEsentDatabase(this.Enlistment.DotGVFSRoot, sourceVersion);
            string esentDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.EsentRepoMetadataFolder);

            esentDatabasePath.ShouldBeADirectory(this.fileSystem);

            // We should be able to mount, and there should no longer be any Esent Repo Metadata
            this.Enlistment.MountGVFS();
            esentDatabasePath.ShouldNotExistOnDisk(this.fileSystem);
            versionJsonPath.ShouldBeAFile(this.fileSystem);

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot)
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutVersion, "Disk layout version should be upgraded to the latest");
        }
Ejemplo n.º 20
0
        public void MountUpgradesPreSharedCacheLocalSizes()
        {
            this.Enlistment.UnmountGVFS();

            // Delete the existing repo metadata
            string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            versionJsonPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(versionJsonPath);

            // "11" was the last version before the introduction of a volume wide GVFS cache
            string metadataPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "11", "0");

            // Create the legacy cache location: <root>\.gvfs\gitObjectCache
            string legacyGitObjectsCachePath = Path.Combine(this.Enlistment.DotGVFSRoot, "gitObjectCache");

            this.fileSystem.CreateDirectory(legacyGitObjectsCachePath);

            // Create a legacy PersistedDictionary sizes database
            List <KeyValuePair <string, long> > entries = new List <KeyValuePair <string, long> >()
            {
                new KeyValuePair <string, long>(new string('0', 40), 1),
                new KeyValuePair <string, long>(new string('1', 40), 2),
                new KeyValuePair <string, long>(new string('2', 40), 4),
                new KeyValuePair <string, long>(new string('3', 40), 8),
            };

            ESENTDatabase.CreateEsentBlobSizesDatabase(this.Enlistment.DotGVFSRoot, entries);

            this.Enlistment.MountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);

            majorVersion
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutMajorVersion, "Disk layout version should be upgraded to the latest");

            minorVersion
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(CurrentDiskLayoutMinorVersion, "Disk layout version should be upgraded to the latest");

            GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot)
            .ShouldEqual(string.Empty, "LocalCacheRoot should be an empty string when upgrading from a version prior to 12");

            GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot)
            .ShouldEqual(legacyGitObjectsCachePath);

            string newBlobSizesRoot = Path.Combine(this.Enlistment.DotGVFSRoot, DatabasesFolderName, BlobSizesCacheName);

            GVFSHelpers.GetPersistedBlobSizesRoot(this.Enlistment.DotGVFSRoot)
            .ShouldEqual(newBlobSizesRoot);

            string blobSizesDbPath = Path.Combine(newBlobSizesRoot, BlobSizesDBFileName);

            newBlobSizesRoot.ShouldBeADirectory(this.fileSystem);
            blobSizesDbPath.ShouldBeAFile(this.fileSystem);

            foreach (KeyValuePair <string, long> entry in entries)
            {
                GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value);
            }
        }
Ejemplo n.º 21
0
        public void MountUpgradesLocalSizesToSharedCache()
        {
            GVFSFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment();

            enlistment.UnmountGVFS();

            string localCacheRoot = GVFSHelpers.GetPersistedLocalCacheRoot(enlistment.DotGVFSRoot);
            string gitObjectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot);

            // Delete the existing repo metadata
            string versionJsonPath = Path.Combine(enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            versionJsonPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(versionJsonPath);

            // "13.0" was the last version before blob sizes were moved out of Esent
            string metadataPath = Path.Combine(enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(enlistment.DotGVFSRoot, "13", "0");
            GVFSHelpers.SaveLocalCacheRoot(enlistment.DotGVFSRoot, localCacheRoot);
            GVFSHelpers.SaveGitObjectsRoot(enlistment.DotGVFSRoot, gitObjectsRoot);

            // Create a legacy PersistedDictionary sizes database
            List <KeyValuePair <string, long> > entries = new List <KeyValuePair <string, long> >()
            {
                new KeyValuePair <string, long>(new string('0', 40), 1),
                new KeyValuePair <string, long>(new string('1', 40), 2),
                new KeyValuePair <string, long>(new string('2', 40), 4),
                new KeyValuePair <string, long>(new string('3', 40), 8),
            };

            GVFSHelpers.CreateEsentBlobSizesDatabase(enlistment.DotGVFSRoot, entries);

            enlistment.MountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(enlistment.DotGVFSRoot, out majorVersion, out minorVersion);

            majorVersion
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(DiskLayoutUpgradeTests.CurrentDiskLayoutMajorVersion, "Disk layout version should be upgraded to the latest");

            minorVersion
            .ShouldBeAnInt("Disk layout version should always be an int")
            .ShouldEqual(DiskLayoutUpgradeTests.CurrentDiskLayoutMinorVersion, "Disk layout version should be upgraded to the latest");

            string newBlobSizesRoot = Path.Combine(Path.GetDirectoryName(gitObjectsRoot), DiskLayoutUpgradeTests.BlobSizesCacheName);

            GVFSHelpers.GetPersistedBlobSizesRoot(enlistment.DotGVFSRoot)
            .ShouldEqual(newBlobSizesRoot);

            string blobSizesDbPath = Path.Combine(newBlobSizesRoot, DiskLayoutUpgradeTests.BlobSizesDBFileName);

            newBlobSizesRoot.ShouldBeADirectory(this.fileSystem);
            blobSizesDbPath.ShouldBeAFile(this.fileSystem);

            foreach (KeyValuePair <string, long> entry in entries)
            {
                GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value);
            }

            // Upgrade a second repo, and make sure all sizes from both upgrades are in the shared database

            GVFSFunctionalTestEnlistment enlistment2 = this.CloneAndMountEnlistment();

            enlistment2.UnmountGVFS();

            // Delete the existing repo metadata
            versionJsonPath = Path.Combine(enlistment2.DotGVFSRoot, GVFSHelpers.RepoMetadataName);
            versionJsonPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(versionJsonPath);

            // "13.0" was the last version before blob sizes were moved out of Esent
            metadataPath = Path.Combine(enlistment2.DotGVFSRoot, GVFSHelpers.RepoMetadataName);
            this.fileSystem.CreateEmptyFile(metadataPath);
            GVFSHelpers.SaveDiskLayoutVersion(enlistment2.DotGVFSRoot, "13", "0");
            GVFSHelpers.SaveLocalCacheRoot(enlistment2.DotGVFSRoot, localCacheRoot);
            GVFSHelpers.SaveGitObjectsRoot(enlistment2.DotGVFSRoot, gitObjectsRoot);

            // Create a legacy PersistedDictionary sizes database
            List <KeyValuePair <string, long> > additionalEntries = new List <KeyValuePair <string, long> >()
            {
                new KeyValuePair <string, long>(new string('4', 40), 16),
                new KeyValuePair <string, long>(new string('5', 40), 32),
                new KeyValuePair <string, long>(new string('6', 40), 64),
            };

            GVFSHelpers.CreateEsentBlobSizesDatabase(enlistment2.DotGVFSRoot, additionalEntries);

            enlistment2.MountGVFS();

            foreach (KeyValuePair <string, long> entry in entries)
            {
                GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value);
            }

            foreach (KeyValuePair <string, long> entry in additionalEntries)
            {
                GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value);
            }
        }