コード例 #1
0
        public void SecondCloneSucceedsWithMissingTrees()
        {
            string newCachePath = Path.Combine(this.localCacheParentPath, ".customGvfsCache2");
            GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment(localCacheRoot: newCachePath);

            File.ReadAllText(Path.Combine(enlistment1.RepoRoot, WellKnownFile));

            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment1);

            string packDir = Path.Combine(enlistment1.GetObjectRoot(this.fileSystem), "pack");

            string[] packDirFiles = Directory.EnumerateFiles(packDir, "*", SearchOption.AllDirectories).ToArray();
            for (int i = 0; i < packDirFiles.Length; i++)
            {
                this.fileSystem.DeleteFile(Path.Combine(packDir, packDirFiles[i]));
            }

            // Enumerate the root directory, populating the tip commit and root tree
            this.fileSystem.EnumerateDirectory(enlistment1.RepoRoot);

            GVFSFunctionalTestEnlistment enlistment2 = this.CreateNewEnlistment(localCacheRoot: newCachePath);

            this.fileSystem.EnumerateDirectory(enlistment2.RepoRoot);
        }
コード例 #2
0
ファイル: SharedCacheTests.cs プロジェクト: smodin/GVFS
        public void DeleteCacheAtOffsetBetweenHydrations()
        {
            GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment(this.pathToObjectCache);

            Task task1 = Task.Run(() =>
            {
                this.HydrateEntireRepo(enlistment1);
            });

            while (!task1.IsCompleted)
            {
                try
                {
                    this.DeleteSharedCache();
                    Thread.Sleep(100);
                }
                catch (IOException)
                {
                    // Hydration may have handles into the cache, so failing this delete is expected.
                }
            }

            enlistment1.Status().ShouldContain("Mount status: Ready");
        }
コード例 #3
0
        public virtual void CreateEnlistment()
        {
            string pathToGvfs = Path.Combine(TestContext.CurrentContext.TestDirectory, Properties.Settings.Default.PathToGVFS);

            this.Enlistment = GVFSFunctionalTestEnlistment.CloneAndMount(pathToGvfs);
        }
コード例 #4
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);
            }
        }
コード例 #5
0
ファイル: CloneTests.cs プロジェクト: Monkeybin11/VFSForGit
        public void CloneToPathWithSpaces()
        {
            GVFSFunctionalTestEnlistment enlistment = GVFSFunctionalTestEnlistment.CloneAndMountEnlistmentWithSpacesInPath(GVFSTestConfig.PathToGVFS);

            enlistment.UnmountAndDeleteAll();
        }
コード例 #6
0
 public TestPath(GVFSFunctionalTestEnlistment enlistment, string basePath)
 {
     this.BasePath    = basePath;
     this.VirtualPath = enlistment.GetVirtualPathTo(basePath);
     this.BackingPath = enlistment.GetBackingPathTo(basePath);
 }
コード例 #7
0
 public virtual void CreateEnlistment()
 {
     this.Enlistment = GVFSFunctionalTestEnlistment.CloneAndMount(GVFSTestConfig.PathToGVFS);
 }