public void FetchOneFileWithNoBackupOverNetwork() { // This is a real run (so it is slow), and it will fetch data over the network. var d = new DirectoryInfo("FetchOneFileWithNoBackupOverNetwork"); if (d.Exists) { d.Delete(true); } d.Create(); var c = GenerateLocalConfigWithWorkingRemote(d); Locator.DisableAllLocators(true); var l = LocalMachine.GetLocation(c); var r = l.GetDSInfo("user.gwatts:user.gwatts.301295.EVNT.1"); Assert.AreEqual(1, l.GetDS(r, rep => Console.WriteLine(rep), fslist => fslist.Take(1).ToArray(), null, 0).Length); var dsdir = d.SubDir("user.gwatts.301295.EVNT.1"); Assert.IsTrue(dsdir.Exists); Assert.AreEqual(1, dsdir.EnumerateFiles("*.root.*", SearchOption.AllDirectories).Count()); // Next, make sure that there are no files left over up on the remote machine. var username = c["LinuxUserName"]; var machine = c["LinuxHost"]; using (var s = new SSHConnection(machine, username)) { bool stillThere = false; s.ExecuteCommand(string.Format("ls {0}", c["LinuxTempLocation"]), outLine => { Console.WriteLine("output of ls: " + outLine); stillThere |= !outLine.Contains("cannot access"); } ); Assert.IsFalse(stillThere); } }
public void DownloadToLinuxDirectoryThatIsAWindowsDirectoryAndAreadyCreated() { // Seen in the wild. A crash (or other interruption) means the dataset directory has // been created, but is empty (for whatever reason). In that particular case, we should // treat it as not there. var dsinfo = MakeDSInfo("ds1.1.1"); var d = new DirectoryInfo("DownloadToLinuxDirectoryThatIsAWindowsDirectory"); if (d.Exists) { d.Delete(true); } d.Create(); var dsdir = d.SubDir(dsinfo.Name); dsdir.Create(); var ld = new LinuxMirrorDownloaderPretend(d, dsinfo.Name); var gf = new GRIDFetchToLinuxVisibleOnWindows(d, ld, "/bogus/files/store"); var r = gf.GetDS(dsinfo); Assert.IsNotNull(r); Assert.AreEqual(5, r.Length); Assert.AreEqual("/bogus/files/store/ds1.1.1", ld.LinuxDest); }
public void LoadNewFilesToLocalWhenEmptyDirectory() { // Seen in the wild. Local directory is actually there for the dataset, but // empty due to an earlier crash. Make sure the copy still occurs. AtlasWorkFlows.Utils.IPLocationTests.SetIpName("pc.cern.ch"); var dsname = "ds1.1.1"; var d1 = utils.BuildSampleDirectoryBeforeBuild("LoadNewFilesToLocalWhenMissingRemote", dsname); var d2 = new DirectoryInfo("LoadNewFilesToLocalWhenMissingLocal"); if (d2.Exists) { d2.Delete(true); } d2.Create(); d2.Refresh(); d2.SubDir("ds1.1.1").Create(); Locator._getLocations = () => utils.GetLocal(d1, d2); var locator = new Locator(); var l = locator.FindLocation("MyTestLocalLocation"); var r = l.GetDSInfo("ds1.1.1"); Assert.IsFalse(r.IsLocal(null)); var files = l.GetDS(r, null, null, null, 0); Assert.AreEqual(5, files.Length); Assert.IsTrue(files[0].LocalPath.Contains("LoadNewFilesToLocalWhenMissingLocal")); Assert.AreEqual("ds1.1.1", d2.EnumerateDirectories().First().Name); }