static void TestMethod_TestIndividualFailures() { var sDirectory = Testing.SetUpSynctestEnvironment(); CCreateSyncResultsSet results; CCreateSyncResultsSet.showWarnings = false; using (Stream iStream2 = File.Open(sDirectory + "\\src\\Licenses\\OpenSsl-License.txt", FileMode.Append, FileAccess.Write, FileShare.None)) { var config = GetRealConfig(sDirectory, 4 /*nThreads*/); config.m_nRetries = "1"; config.m_waitBetweenRetries = "1"; string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, false /*preview*/, false); results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, false /*preview*/); File.Delete(sLogFilename); } CCreateSyncResultsSet.showWarnings = true; Utils.AssertEq(0, results.items.Count); Utils.AssertEq(true, results.sSummary.Contains("Summary indicated failures")); Utils.AssertEq(true, results.sSummary.Contains("*EXTRA File")); Utils.AssertEq(true, results.sSummary.Contains("it is being used by another process")); Utils.AssertEq(true, results.sSummary.Contains("RETRY LIMIT EXCEEDED")); Utils.AssertEq(true, results.sSummary.Contains("Bytes :")); }
void RunCopyingOnSeparateThread() { foreach (var config in this.configs) { CCreateSyncResultsSet results = null; string sExceptionOccurred = null; try { string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, preview, false); results = CCreateSyncResultsSet.ParseFromLogFile( config, sLogFilename, preview); } catch (Exception e) { sExceptionOccurred = e.ToString(); } Action action = delegate() { OnRunComplete(results, sExceptionOccurred); }; btnToTemporarilyDisable.BeginInvoke(action); } // Don't restore btn text until all configs were processed Action restoreBtnText = delegate() { btnToTemporarilyDisable.Text = sPreviousButtonName; btnToTemporarilyDisable.Enabled = true; }; btnToTemporarilyDisable.BeginInvoke(restoreBtnText); }
public FormSyncItems(CCreateSyncResultsSet results, RbcpyGlobalSettings globalSettings, bool bPreview) { InitializeComponent(); m_results = results; m_globalSettings = globalSettings; m_bPreview = bPreview; if (bPreview) { this.Text = "Preview"; this.lblNameOfAction.Text = "Preview:"; } else { this.Text = "Results"; this.lblNameOfAction.Text = "Results:"; btnRun.Text = "Sync Complete"; btnRun.Enabled = false; btnIncludeBoth.Enabled = false; btnCompareWinmerge.Enabled = false; btnLeftToRight.Enabled = btnRightToLeft.Enabled = false; btnShowLeft.Enabled = btnShowRight.Enabled = false; } listView.UseCompatibleStateImageBehavior = false; listView.SmallImageList = imageList1; txtSummary.ReadOnly = true; txtSummary.Text = results.sSummary; ReAddItems(); ShowSummary(); txtSummary.Select(0, 0); listView.Focus(); }
public static CCreateSyncResultsSet ParseFromLogFile(SyncConfiguration config, string sLogFilename, bool bPreview) { CCreateSyncResultsSet ret = new CCreateSyncResultsSet(); ret.config = config; ret.sLogFilename = sLogFilename; if (!File.Exists(sLogFilename)) { ret.sSummary = ("Unknown failure. Log file not found."); return(ret); } int nTotalLinesWithDashes = CountSections(sLogFilename); if (nTotalLinesWithDashes < 3) { ret.sSummary = ("Unknown failure. In the log file, less than 3 separator lines."); return(ret); } else if (nTotalLinesWithDashes == 3) // looks like errors occurred... { ret.sSummary = RetrieveTextPastSectionNumber(sLogFilename, 3, "Because there are only 3 separator lines, looks like errors occurred:"); return(ret); } StringBuilder sbSummary; bool bFailuresSeen; List <CCreateSyncItem> items = ParseFromLogFileContents(config, sLogFilename, out bFailuresSeen, out sbSummary, bPreview); ret.items = items; if (bFailuresSeen) { // show the entire results in the summary if a failure occurs ret.items.Clear(); ret.sSummary = RetrieveTextPastSectionNumber(sLogFilename, 3, "Summary indicated failures (can be caused by broken symlinks, we recommend ensuring no symlinks are present in target):"); return(ret); } if (nTotalLinesWithDashes > 4) { sbSummary.AppendLine("Note, more than 4 lines with dashes (" + nTotalLinesWithDashes + ")"); } ret.sSummary = sbSummary.ToString(); ret.sSummary = ret.sSummary.Replace("FAILED", "Failed"); // delete Speed: section int indexSpeed = ret.sSummary.IndexOf("Speed :"); if (indexSpeed != -1) { ret.sSummary = ret.sSummary.Substring(0, indexSpeed).Trim(); } return(ret); }
void OnRunComplete(CCreateSyncResultsSet results, string sExceptionOccurred) { if (sExceptionOccurred != null) { MessageBox.Show("Exception: " + sExceptionOccurred); } if (results != null) { var child = new FormSyncItems(results, globalSettings, preview); child.Show(); } }
static void TestMethod_TestGlobalFailure() { var config = new SyncConfiguration(); config.m_src = "notexist1"; config.m_destination = "notexist2"; config.m_mirror = true; config.m_copySubDirsAndEmptySubdirs = true; string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, true /*preview*/, false); var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, true /*preview*/); Utils.AssertEq(0, results.items.Count); Utils.AssertEq(true, results.sSummary.Contains("looks like errors occurred:")); Utils.AssertEq(true, results.sSummary.Contains("The system cannot find the file specified.")); File.Delete(sLogFilename); }
private static void TestSyncPreview(string sDirectory, int nThreads) { var config = GetRealConfig(sDirectory, nThreads); string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, true /*preview*/, false); var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, true /*preview*/); // the number of skipped dirs is 3 instead of the 2 it used to be, but not important right now Utils.AssertEq("Total Copied Skipped Mismatch Failed Extras\r\n Dirs : 5 5 3 0 0 2\r\n Files : 22 8 14 0 0 2\r\n Bytes : 632.0 k 126.6 k 505.4 k 0 0 30.7 k", results.sSummary.Trim()); File.Delete(sLogFilename); { CCreateSyncItem.SortFromColumnNumber(results.items, 3); // sort by path ascending var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Create \Images\a.png Create \Images\addir\a.PNG Delete \Images\new.png Delete \Images\remdir\c.png Create \Licenses\.weirdext Update \Licenses\Apr-License.txt Update() \Licenses\Cyrus-Sasl-License.txt Create \Licenses\noext Update() \Licenses\OpenSsl-License.txt Update \Licenses\Serf-License.txt" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } { CCreateSyncItem.SortFromColumnNumber(results.items, -3); // sort by path descending var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Update \Licenses\Serf-License.txt Update() \Licenses\OpenSsl-License.txt Create \Licenses\noext Update() \Licenses\Cyrus-Sasl-License.txt Update \Licenses\Apr-License.txt Create \Licenses\.weirdext Delete \Images\remdir\c.png Delete \Images\new.png Create \Images\addir\a.PNG Create \Images\a.png" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } { CCreateSyncItem.SortFromColumnNumber(results.items, 1); // sort by type where Update() != Update var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Create \Images\a.png Create \Images\addir\a.PNG Create \Licenses\.weirdext Create \Licenses\noext Delete \Images\new.png Delete \Images\remdir\c.png Update \Licenses\Apr-License.txt Update \Licenses\Serf-License.txt Update() \Licenses\Cyrus-Sasl-License.txt Update() \Licenses\OpenSsl-License.txt" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } { CCreateSyncItem.SortFromColumnNumber(results.items, 2); // sort by type where Update() == Update var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString(); var sGot = String.Join("\n", resultsFilteredStrings); var sExpected = @"Create \Images\a.png Create \Images\addir\a.PNG Create \Licenses\.weirdext Create \Licenses\noext Delete \Images\new.png Delete \Images\remdir\c.png Update \Licenses\Apr-License.txt Update() \Licenses\Cyrus-Sasl-License.txt Update() \Licenses\OpenSsl-License.txt Update \Licenses\Serf-License.txt" .Replace("\r\n", "\n"); Utils.AssertEq(sExpected, sGot); } }
static void TestActualSync(string sDirectory, int nThreads) { var config = GetRealConfig(sDirectory, nThreads); string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, false /*preview*/, false); var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, false /*preview*/); File.Delete(sLogFilename); // the number of skipped dirs is 3 instead of the 2 it used to be, but not important right now Utils.AssertEq("Total Copied Skipped Mismatch Failed Extras\r\n Dirs : 5 5 3 0 0 2\r\n Files : 22 8 14 0 0 2\r\n Bytes : 632.0 k 126.6 k 505.4 k 0 0 30.7 k", results.sSummary.Trim()); // check files string[] filesExpected = @"..\..\test\testsync\dest ..\..\test\testsync\dest\Images ..\..\test\testsync\dest\Images\a.png ..\..\test\testsync\dest\Images\addempty ..\..\test\testsync\dest\Images\addir ..\..\test\testsync\dest\Images\addir\a.PNG ..\..\test\testsync\dest\Images\b.png ..\..\test\testsync\dest\Images\c.png ..\..\test\testsync\dest\Images\d.png ..\..\test\testsync\dest\Images\DB44-20-x64.jpg ..\..\test\testsync\dest\Images\e.png ..\..\test\testsync\dest\Images\f.gif ..\..\test\testsync\dest\Licenses ..\..\test\testsync\dest\Licenses\.weirdext ..\..\test\testsync\dest\Licenses\Apr-License.txt ..\..\test\testsync\dest\Licenses\Apr-Util-License.txt ..\..\test\testsync\dest\Licenses\BerkeleyDB-License.txt ..\..\test\testsync\dest\Licenses\Cyrus-Sasl-License.txt ..\..\test\testsync\dest\Licenses\GetText-Runtime-License.txt ..\..\test\testsync\dest\Licenses\noext ..\..\test\testsync\dest\Licenses\OpenSsl-License.txt ..\..\test\testsync\dest\Licenses\Serf-License.txt ..\..\test\testsync\dest\Licenses\SharpSvn-License.txt ..\..\test\testsync\dest\Licenses\Subversion-License.txt ..\..\test\testsync\dest\loren.html ..\..\test\testsync\dest\loren.txt ..\..\test\testsync\dest\pic1.png ..\..\test\testsync\src ..\..\test\testsync\src\Images ..\..\test\testsync\src\Images\a.png ..\..\test\testsync\src\Images\addempty ..\..\test\testsync\src\Images\addir ..\..\test\testsync\src\Images\addir\a.PNG ..\..\test\testsync\src\Images\b.png ..\..\test\testsync\src\Images\c.png ..\..\test\testsync\src\Images\d.png ..\..\test\testsync\src\Images\DB44-20-x64.jpg ..\..\test\testsync\src\Images\e.png ..\..\test\testsync\src\Images\f.gif ..\..\test\testsync\src\Licenses ..\..\test\testsync\src\Licenses\.weirdext ..\..\test\testsync\src\Licenses\Apr-License.txt ..\..\test\testsync\src\Licenses\Apr-Util-License.txt ..\..\test\testsync\src\Licenses\BerkeleyDB-License.txt ..\..\test\testsync\src\Licenses\Cyrus-Sasl-License.txt ..\..\test\testsync\src\Licenses\GetText-Runtime-License.txt ..\..\test\testsync\src\Licenses\noext ..\..\test\testsync\src\Licenses\OpenSsl-License.txt ..\..\test\testsync\src\Licenses\Serf-License.txt ..\..\test\testsync\src\Licenses\SharpSvn-License.txt ..\..\test\testsync\src\Licenses\Subversion-License.txt ..\..\test\testsync\src\loren.html ..\..\test\testsync\src\loren.txt ..\..\test\testsync\src\pic1.png".Replace("\r\n", "\n").Replace(@"..\..\test\testsync\", sDirectory + "\\").Split(new char[] { '\n' }); List <string> filesGot = Directory.GetFileSystemEntries(sDirectory, "*", SearchOption.AllDirectories).ToList(); filesGot.Sort(); Testing.AssertStringArrayEqual(filesExpected, filesGot); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\OpenSsl-License.txt").Length, 6286L); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Apr-License.txt").Length, 18324L); Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Serf-License.txt").Length, 11562L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\OpenSsl-License.txt").Length, 6286L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Apr-License.txt").Length, 18324L); Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Serf-License.txt").Length, 11562L); }