Beispiel #1
0
        public void MountReusesLocalCacheKeyWhenGitObjectsRootDeleted()
        {
            GVFSFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment();

            enlistment.UnmountGVFS();

            // Find the current git objects root and ensure it's on disk
            string objectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot).ShouldNotBeNull();

            objectsRoot.ShouldBeADirectory(this.fileSystem);

            string mappingFilePath     = Path.Combine(enlistment.LocalCacheRoot, "mapping.dat");
            string mappingFileContents = this.fileSystem.ReadAllText(mappingFilePath);

            mappingFileContents.Length.ShouldNotEqual(0, "mapping.dat should not be empty");

            // Delete the git objects root folder, mount should re-create it and the mapping.dat file should not change
            CmdRunner.DeleteDirectoryWithUnlimitedRetries(objectsRoot);

            enlistment.MountGVFS();

            GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot).ShouldEqual(objectsRoot);
            objectsRoot.ShouldBeADirectory(this.fileSystem);
            mappingFilePath.ShouldBeAFile(this.fileSystem).WithContents(mappingFileContents);

            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment);
        }
Beispiel #2
0
        public void DeleteCacheDuringHydrations()
        {
            GVFSFunctionalTestEnlistment enlistment1 = this.CloneAndMountEnlistment();

            string objectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment1.DotGVFSRoot).ShouldNotBeNull();

            objectsRoot.ShouldBeADirectory(this.fileSystem);

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

            while (!task1.IsCompleted)
            {
                try
                {
                    // Delete objectsRoot rather than this.localCachePath as the blob sizes database cannot be deleted while GVFS is mounted
                    CmdRunner.DeleteDirectoryWithUnlimitedRetries(objectsRoot);
                    Thread.Sleep(100);
                }
                catch (IOException)
                {
                    // Hydration may have handles into the cache, so failing this delete is expected.
                }
            }

            task1.Exception.ShouldBeNull();

            enlistment1.Status().ShouldContain("Mount status: Ready");
        }
Beispiel #3
0
        public void DeleteObjectsCacheAndCacheMappingBeforeMount()
        {
            GVFSFunctionalTestEnlistment enlistment1 = this.CloneAndMountEnlistment();
            GVFSFunctionalTestEnlistment enlistment2 = this.CloneAndMountEnlistment();

            enlistment1.UnmountGVFS();

            string objectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment1.DotGVFSRoot).ShouldNotBeNull();

            objectsRoot.ShouldBeADirectory(this.fileSystem);
            CmdRunner.DeleteDirectoryWithUnlimitedRetries(objectsRoot);

            string metadataPath = Path.Combine(this.localCachePath, "mapping.dat");

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

            enlistment1.MountGVFS();

            Task task1 = Task.Run(() => this.HydrateRootFolder(enlistment1));
            Task task2 = Task.Run(() => this.HydrateRootFolder(enlistment2));

            task1.Wait();
            task2.Wait();
            task1.Exception.ShouldBeNull();
            task2.Exception.ShouldBeNull();

            enlistment1.Status().ShouldContain("Mount status: Ready");
            enlistment2.Status().ShouldContain("Mount status: Ready");

            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment1);
            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment2);
        }
Beispiel #4
0
 private void DeleteDirectoryWithUnlimitedRetries(string path)
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         CmdRunner.DeleteDirectoryWithUnlimitedRetries(path);
     }
     else
     {
         // TODO(Mac): See if we can use BashRunner.DeleteDirectoryWithRetry on Windows as well
         BashRunner.DeleteDirectoryWithUnlimitedRetries(path);
     }
 }
Beispiel #5
0
 public static void DeleteTestDirectory(string repoPath)
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         // Use cmd.exe to delete the enlistment as it properly handles tombstones and reparse points
         CmdRunner.DeleteDirectoryWithUnlimitedRetries(repoPath);
     }
     else
     {
         BashRunner.DeleteDirectoryWithUnlimitedRetries(repoPath);
     }
 }
Beispiel #6
0
 public void Delete()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.RootPath);
     }
     else
     {
         // TODO(Mac): See if we can use BashRunner.DeleteDirectoryWithRetry on Windows as well
         BashRunner.DeleteDirectoryWithUnlimitedRetries(this.RootPath);
     }
 }
Beispiel #7
0
        public void DeleteEnlistment()
        {
            TestResultsHelper.OutputGVFSLogs(this);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // Use cmd.exe to delete the enlistment as it properly handles tombstones and reparse points
                CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.EnlistmentRoot);
            }
            else
            {
                // TODO(Mac): Figure out why the call to DeleteDirectoryWithRetry is not returning
                // BashRunner.DeleteDirectoryWithRetry(this.EnlistmentRoot);
            }
        }
Beispiel #8
0
        public void MountUsesNewLocalCacheKeyWhenLocalCacheDeleted()
        {
            GVFSFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment();

            enlistment.UnmountGVFS();

            // Find the current git objects root and ensure it's on disk
            string objectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot).ShouldNotBeNull();

            objectsRoot.ShouldBeADirectory(this.fileSystem);

            string mappingFilePath     = Path.Combine(enlistment.LocalCacheRoot, "mapping.dat");
            string mappingFileContents = this.fileSystem.ReadAllText(mappingFilePath);

            mappingFileContents.Length.ShouldNotEqual(0, "mapping.dat should not be empty");

            // Delete the local cache folder, mount should re-create it and generate a new mapping file and local cache key
            CmdRunner.DeleteDirectoryWithUnlimitedRetries(enlistment.LocalCacheRoot);

            enlistment.MountGVFS();

            // Mount should recreate the local cache root
            enlistment.LocalCacheRoot.ShouldBeADirectory(this.fileSystem);

            // Determine the new local cache key
            string    newMappingFileContents = mappingFilePath.ShouldBeAFile(this.fileSystem).WithContents();
            const int GuidStringLength       = 32;
            string    mappingFileKey         = "A {\"Key\":\"https://gvfs.visualstudio.com/ci/_git/fortests\",\"Value\":\"";
            int       localKeyIndex          = newMappingFileContents.IndexOf(mappingFileKey);
            string    newCacheKey            = newMappingFileContents.Substring(localKeyIndex + mappingFileKey.Length, GuidStringLength);

            // Validate the new objects root is on disk and uses the new key
            objectsRoot.ShouldNotExistOnDisk(this.fileSystem);
            string newObjectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot);

            newObjectsRoot.ShouldNotEqual(objectsRoot);
            newObjectsRoot.ShouldContain(newCacheKey);
            newObjectsRoot.ShouldBeADirectory(this.fileSystem);

            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment);
        }
Beispiel #9
0
 [Category(Categories.MacTODO.NeedsDehydrate)]  // Call CmdRunner which is windows specific
 public void DehydrateShouldSucceedEvenIfObjectCacheIsDeleted()
 {
     this.Enlistment.UnmountGVFS();
     CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.Enlistment.GetObjectRoot(this.fileSystem));
     this.DehydrateShouldSucceed("The repo was successfully dehydrated and remounted", confirm: true, noStatus: true);
 }
Beispiel #10
0
 public void DeleteControlRepo()
 {
     CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.fastFetchControlRoot);
 }
Beispiel #11
0
 public void TearDownTests()
 {
     CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.fastFetchRepoRoot);
 }
Beispiel #12
0
 // Override OnTearDownEnlistmentsDeleted rathern than using [TearDown] as the enlistments need to be unmounted before
 // localCacheParentPath can be deleted (as the SQLite blob sizes database cannot be deleted while GVFS is mounted)
 protected override void OnTearDownEnlistmentsDeleted()
 {
     CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.localCacheParentPath);
 }