-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
123 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using FluentAssertions; | ||
using LiteDB.Engine; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Xunit; | ||
|
||
namespace LiteDB.Tests.Issues | ||
{ | ||
public class Issue2417_Tests | ||
{ | ||
[Fact] | ||
public void Rebuild_Detected_Infinite_Loop() | ||
{ | ||
var original = "../../../Resources/Issue2417_MyData.db"; | ||
|
||
using (var filename = new TempFile(original)) | ||
{ | ||
var settings = new EngineSettings | ||
{ | ||
Filename = filename, | ||
AutoRebuild = true, | ||
}; | ||
|
||
try | ||
{ | ||
using (var db = new LiteEngine(settings)) | ||
{ | ||
// infinite loop here | ||
var col = db.Query("customers", Query.All()).ToList(); | ||
|
||
// never run here | ||
Assert.Fail("not expected"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Assert.True(ex is LiteException lex && lex.ErrorCode == 999); | ||
} | ||
|
||
using (var db = new LiteEngine(settings)) | ||
{ | ||
var col = db.Query("customers", Query.All()).ToList().Count; | ||
var errors = db.Query("_rebuild_errors", Query.All()).ToList().Count; | ||
|
||
col.Should().Be(4); | ||
errors.Should().Be(0); | ||
} | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Rebuild_Detected_Infinite_Loop_With_Password() | ||
{ | ||
var original = "../../../Resources/Issue2417_TestCacheDb.db"; | ||
|
||
using (var filename = new TempFile(original)) | ||
{ | ||
var settings = new EngineSettings | ||
{ | ||
Filename = filename, | ||
Password = "bzj2NplCbVH/bB8fxtjEC7u0unYdKHJVSmdmPgArRBwmmGw0+Wd2tE+b2zRMFcHAzoG71YIn/2Nq1EMqa5JKcQ==", | ||
AutoRebuild = true, | ||
}; | ||
|
||
try | ||
{ | ||
using (var db = new LiteEngine(settings)) | ||
{ | ||
// infinite loop here | ||
var col = db.Query("hubData$AppOperations", Query.All()).ToList(); | ||
|
||
// never run here | ||
Assert.Fail("not expected"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Assert.True(ex is LiteException lex && lex.ErrorCode == 999); | ||
} | ||
|
||
using (var db = new LiteEngine(settings)) | ||
{ | ||
var col = db.Query("hubData$AppOperations", Query.All()).ToList().Count; | ||
var errors = db.Query("_rebuild_errors", Query.All()).ToList().Count; | ||
|
||
col.Should().Be(408); | ||
errors.Should().Be(0); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
File renamed without changes.
Binary file renamed
BIN
+640 KB
LiteDB.Tests/Resources/Loop.db → ....Tests/Resources/Issue2417_TestCacheDb.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters