From a7d7aa61a244b83b2b650a1495493bf5f4700562 Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 10:41:18 +0200 Subject: [PATCH 01/10] Fixed issue with overwritten files having invalid tokens --- src/ArrowDbCore/FileSerializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrowDbCore/FileSerializer.cs b/src/ArrowDbCore/FileSerializer.cs index 1caae67..f424fca 100644 --- a/src/ArrowDbCore/FileSerializer.cs +++ b/src/ArrowDbCore/FileSerializer.cs @@ -40,7 +40,7 @@ public ValueTask> DeserializeAsync() { /// public ValueTask SerializeAsync(ConcurrentDictionary data) { - using var file = File.OpenWrite(_path); + using var file = File.Create(_path); JsonSerializer.Serialize(file, data, _jsonTypeInfo); return ValueTask.CompletedTask; } From e67ffae23920381d12ad0c27449ba4b6a0bd0f46 Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 10:41:40 +0200 Subject: [PATCH 02/10] Added key generation function --- src/ArrowDbCore/ArrowDb.Factory.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/ArrowDbCore/ArrowDb.Factory.cs b/src/ArrowDbCore/ArrowDb.Factory.cs index bce9036..2bb2739 100644 --- a/src/ArrowDbCore/ArrowDb.Factory.cs +++ b/src/ArrowDbCore/ArrowDb.Factory.cs @@ -31,4 +31,31 @@ public static async ValueTask CreateCustom(IDbSerializer serializer) { var data = await serializer.DeserializeAsync(); return new ArrowDb(data, serializer); } + + /// + /// Generates a typed key for the specified specific key in a very efficient manner + /// + /// The type of the value + /// The key that is specific to the value + /// The buffer to use for the generation + /// + /// A key that is formatted as ":" + /// + public static ReadOnlySpan GenerateTypedKey(ReadOnlySpan specificKey, Span buffer) { + var typeName = TypeNameCache.TypeName; + var length = typeName.Length + 1 + specificKey.Length; // type:specificKey + ArgumentOutOfRangeException.ThrowIfGreaterThan(length, buffer.Length); + typeName.CopyTo(buffer); + buffer[typeName.Length] = ':'; + specificKey.CopyTo(buffer.Slice(typeName.Length + 1)); + return buffer.Slice(0, length); + } + + // A static class that caches type names during runtime + private static class TypeNameCache { + /// + /// The name of the type of T + /// + public static readonly string TypeName = typeof(T).Name; + } } From bbdb4daaa2cd80984b53343c665de801330a8b2e Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 10:42:40 +0200 Subject: [PATCH 03/10] Downstreamed compiler optimization --- src/ArrowDbCore/ArrowDb.Read.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrowDbCore/ArrowDb.Read.cs b/src/ArrowDbCore/ArrowDb.Read.cs index ae74729..9d01550 100644 --- a/src/ArrowDbCore/ArrowDb.Read.cs +++ b/src/ArrowDbCore/ArrowDb.Read.cs @@ -29,7 +29,7 @@ public bool TryGetValue(ReadOnlySpan key, JsonTypeInfo jso value = default!; return false; } - value = JsonSerializer.Deserialize(existingReference.AsSpan(), jsonTypeInfo)!; + value = JsonSerializer.Deserialize(new ReadOnlySpan(existingReference), jsonTypeInfo)!; return !EqualityComparer.Default.Equals(value, default); } From fb7c4d0df1244cbef0dec019ab35fced3ce90970 Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 10:42:46 +0200 Subject: [PATCH 04/10] Updated version --- src/ArrowDbCore/ArrowDbCore.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrowDbCore/ArrowDbCore.csproj b/src/ArrowDbCore/ArrowDbCore.csproj index d07fcd8..daa9f17 100644 --- a/src/ArrowDbCore/ArrowDbCore.csproj +++ b/src/ArrowDbCore/ArrowDbCore.csproj @@ -4,7 +4,7 @@ net9.0 enable enable - 1.0.0.0 + 1.1.0.0 true From f55dd908d83b798c3a6e3da71ea5134df5c9436d Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 20:09:21 +0200 Subject: [PATCH 05/10] Added durability tests --- ArrowDbCore.sln | 7 +++ src/ArrowDbCore/ArrowDbCore.csproj | 3 ++ .../ArrowDbCore.Tests.Durability.csproj | 27 +++++++++++ .../ArrowDbCore.Tests.Durability/JContext.cs | 7 +++ .../ArrowDbCore.Tests.Durability/LargeFile.cs | 45 ++++++++++++++++++ tests/ArrowDbCore.Tests.Durability/Person.cs | 8 ++++ .../ReadWriteCycles.cs | 46 +++++++++++++++++++ tests/ArrowDbCore.Tests.Unit/KeyGeneration.cs | 31 +++++++++++++ 8 files changed, 174 insertions(+) create mode 100644 tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj create mode 100644 tests/ArrowDbCore.Tests.Durability/JContext.cs create mode 100644 tests/ArrowDbCore.Tests.Durability/LargeFile.cs create mode 100644 tests/ArrowDbCore.Tests.Durability/Person.cs create mode 100644 tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs create mode 100644 tests/ArrowDbCore.Tests.Unit/KeyGeneration.cs diff --git a/ArrowDbCore.sln b/ArrowDbCore.sln index 786006a..2235349 100644 --- a/ArrowDbCore.sln +++ b/ArrowDbCore.sln @@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArrowDbCore.Benchmarks", "benchmarks\ArrowDbCore.Benchmarks\ArrowDbCore.Benchmarks.csproj", "{419CA340-26F0-4FC1-83AC-D06A93AAB190}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArrowDbCore.Tests.Durability", "tests\ArrowDbCore.Tests.Durability\ArrowDbCore.Tests.Durability.csproj", "{BD64C8CB-1B06-4F78-890A-F830ED2EF982}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,10 +38,15 @@ Global {419CA340-26F0-4FC1-83AC-D06A93AAB190}.Debug|Any CPU.Build.0 = Debug|Any CPU {419CA340-26F0-4FC1-83AC-D06A93AAB190}.Release|Any CPU.ActiveCfg = Release|Any CPU {419CA340-26F0-4FC1-83AC-D06A93AAB190}.Release|Any CPU.Build.0 = Release|Any CPU + {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {23F42F88-1579-4087-ABF2-814EDBD53F59} = {822210FC-B851-4C2C-AEAE-250F17687CC3} {CDBBF9DF-5F8B-41C0-AAE7-2EC157C3BA1D} = {4ED1B77D-F425-487C-B32C-53F92A8E5A2E} {419CA340-26F0-4FC1-83AC-D06A93AAB190} = {9844EA79-5000-4276-A2C4-D7BA430F18B4} + {BD64C8CB-1B06-4F78-890A-F830ED2EF982} = {4ED1B77D-F425-487C-B32C-53F92A8E5A2E} EndGlobalSection EndGlobal diff --git a/src/ArrowDbCore/ArrowDbCore.csproj b/src/ArrowDbCore/ArrowDbCore.csproj index daa9f17..8b14edd 100644 --- a/src/ArrowDbCore/ArrowDbCore.csproj +++ b/src/ArrowDbCore/ArrowDbCore.csproj @@ -39,6 +39,9 @@ <_Parameter1>ArrowDbCore.Tests.Unit + + <_Parameter1>ArrowDbCore.Tests.Durability + \ No newline at end of file diff --git a/tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj b/tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj new file mode 100644 index 0000000..e211a5e --- /dev/null +++ b/tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj @@ -0,0 +1,27 @@ + + + + net9.0 + enable + enable + false + + + + + + + + + + + + + + + + + + + + diff --git a/tests/ArrowDbCore.Tests.Durability/JContext.cs b/tests/ArrowDbCore.Tests.Durability/JContext.cs new file mode 100644 index 0000000..6cc56df --- /dev/null +++ b/tests/ArrowDbCore.Tests.Durability/JContext.cs @@ -0,0 +1,7 @@ +using System.Text.Json.Serialization; + +namespace ArrowDbCore.Tests.Durability; + +[JsonSourceGenerationOptions(WriteIndented = false, NumberHandling = JsonNumberHandling.AllowReadingFromString, UseStringEnumConverter = true)] +[JsonSerializable(typeof(Person))] +public partial class JContext : JsonSerializerContext { } \ No newline at end of file diff --git a/tests/ArrowDbCore.Tests.Durability/LargeFile.cs b/tests/ArrowDbCore.Tests.Durability/LargeFile.cs new file mode 100644 index 0000000..9b5e0a0 --- /dev/null +++ b/tests/ArrowDbCore.Tests.Durability/LargeFile.cs @@ -0,0 +1,45 @@ +using Bogus; + +namespace ArrowDbCore.Tests.Durability; + +public class LargeFile { + [Fact] + public async Task LargeFile_Passes_OneReadWriteCycle() { + const int itemCount = 500_000; + + var faker = new Faker(); + faker.UseSeed(1337); + faker.RuleFor(p => p.Name, (f, _) => f.Name.FullName()); + faker.RuleFor(p => p.Age, (f, _) => f.Random.Int(1, 100)); + faker.RuleFor(p => p.BirthDate, (f, _) => f.Date.Past(1, DateTime.Now.AddYears(-100))); + faker.RuleFor(p => p.IsMarried, (f, _) => f.Random.Bool()); + + var buffer = new char[256]; + + var path = Sharpify.Utils.Env.PathInBaseDirectory("long-test.db"); + try { + // load the db + var db = await ArrowDb.CreateFromFile(path); + // clear + db.Clear(); + // add items + for (var j = 0; j < itemCount; j++) { + var person = faker.Generate(); + var key = ArrowDb.GenerateTypedKey(person.Name, buffer); + db.Upsert(key, person, JContext.Default.Person); + } + // save + await db.SerializeAsync(); + var actualCount = db.Count; + // try to load again + var db2 = await ArrowDb.CreateFromFile(path); + Assert.Equal(actualCount, db2.Count); + } finally { + if (File.Exists(path)) { + File.Delete(path); + } + } + + // this test fails if an exception is thrown + } +} \ No newline at end of file diff --git a/tests/ArrowDbCore.Tests.Durability/Person.cs b/tests/ArrowDbCore.Tests.Durability/Person.cs new file mode 100644 index 0000000..12c0b2d --- /dev/null +++ b/tests/ArrowDbCore.Tests.Durability/Person.cs @@ -0,0 +1,8 @@ +namespace ArrowDbCore.Tests.Durability; + +public class Person { + public string Name { get; set; } = string.Empty; + public int Age { get; set; } + public DateTime BirthDate { get; set; } + public bool IsMarried { get; set; } +} diff --git a/tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs b/tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs new file mode 100644 index 0000000..723f02b --- /dev/null +++ b/tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs @@ -0,0 +1,46 @@ +using Bogus; + +namespace ArrowDbCore.Tests.Durability; + +public class ReadWriteCycles +{ + [Fact] + public async Task FileIO_Passes_ReadWriteCycles() + { + const int iterations = 200; + const int itemCount = 100; + + var faker = new Faker(); + faker.UseSeed(1337); + faker.RuleFor(p => p.Name, (f, _) => f.Name.FullName()); + faker.RuleFor(p => p.Age, (f, _) => f.Random.Int(1, 100)); + faker.RuleFor(p => p.BirthDate, (f, _) => f.Date.Past(1, DateTime.Now.AddYears(-100))); + faker.RuleFor(p => p.IsMarried, (f, _) => f.Random.Bool()); + + var buffer = new char[256]; + + var path = Sharpify.Utils.Env.PathInBaseDirectory("rdc-test.db"); + try { + for (var i = 0; i < iterations; i++) { + // load the db + var db = await ArrowDb.CreateFromFile(path); + // clear + db.Clear(); + // add items + for (var j = 0; j < itemCount; j++) { + var person = faker.Generate(); + var key = ArrowDb.GenerateTypedKey(person.Name, buffer); + db.Upsert(key, person, JContext.Default.Person); + } + // save + await db.SerializeAsync(); + } + } finally { + if (File.Exists(path)) { + File.Delete(path); + } + } + + // this test fails if an exception is thrown + } +} \ No newline at end of file diff --git a/tests/ArrowDbCore.Tests.Unit/KeyGeneration.cs b/tests/ArrowDbCore.Tests.Unit/KeyGeneration.cs new file mode 100644 index 0000000..a4d22ca --- /dev/null +++ b/tests/ArrowDbCore.Tests.Unit/KeyGeneration.cs @@ -0,0 +1,31 @@ +using System.Runtime.CompilerServices; + +namespace ArrowDbCore.Tests.Unit; + +public class KeyGeneration { + [InlineArray(128)] + private struct Buffer { + private char _first; + } + + [Fact] + public void GenerateTypedKey_Primitive() { + var buffer = new Buffer(); + var key = ArrowDb.GenerateTypedKey("1", buffer); + Assert.Equal("Int32:1", key); + } + + [Fact] + public void GenerateTypedKey_String() { + var buffer = new Buffer(); + var key = ArrowDb.GenerateTypedKey("1", buffer); + Assert.Equal("String:1", key); + } + + [Fact] + public void GenerateTypedKey_Person() { + var buffer = new Buffer(); + var key = ArrowDb.GenerateTypedKey("1", buffer); + Assert.Equal("Buffer:1", key); + } +} \ No newline at end of file From 7fb69bd84fffe76a6b0795e8e0b02f355a3e8f6d Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 20:09:34 +0200 Subject: [PATCH 06/10] Added workflow to run durability test --- .github/workflows/run-durability-tests.yaml | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/run-durability-tests.yaml diff --git a/.github/workflows/run-durability-tests.yaml b/.github/workflows/run-durability-tests.yaml new file mode 100644 index 0000000..39a04b6 --- /dev/null +++ b/.github/workflows/run-durability-tests.yaml @@ -0,0 +1,49 @@ +name: Run Durability Tests + +on: + pull_request: + workflow_dispatch: + +jobs: + test-pulse: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + configuration: [Debug, Release] + + env: + # Define the path to project and test project + PROJECT: src/ArrowDbCore/ArrowDbCore.csproj + TEST_PROJECT: tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj + + steps: + # 1. Checkout the repository code + - name: Checkout Repository + uses: actions/checkout@v4 + + # 2. Cache NuGet packages + - name: Cache NuGet Packages + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: | + ${{ runner.os }}-nuget- + + # 3. Setup .NET + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + # 4. Clean + - name: Clean + run: | + dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }} + dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }} + + # 5. Run Durability Tests + - name: Run Durability Tests + run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }} \ No newline at end of file From a3f057d08282ebba2ba9c330ef64cd8b665cce2a Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 20:09:48 +0200 Subject: [PATCH 07/10] Added changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9e655ac --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog (Sorted by Date in Descending Order) + +## 1.1.0.0 + +* Fixed issue with `FileSerializer` where serialization would write over existing file data which could create invalid tokens, causing deserialization to fail. +* Added static `ArrowDb.GenerateTypedKey` method that accepts the type of the value, specific key (identifier) and a buffer, it returns a `ReadOnlySpan` key that prefixes the type to the specific key. + +## 1.0.0.0 + +* Initial Release From f523c98d912f05ed7cbbc9949fee41b6b71d8abc Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 20:10:03 +0200 Subject: [PATCH 08/10] Updated readme --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 86ce886..f90a566 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,38 @@ do { As the example shows retries is the usual way to resolve these conflicts, but custom logic can also be used, you can simply reject the operation, and also use other loops or even `goto` statements if you are brave enough. +## `ReadOnlySpan` Key Generation + +`ArrowDb` APIs use `ReadOnlySpan` for keys to minimize unnecessary string allocations. Usually using the API with `Upsert` doesn't require specific logic as string can also be interpreted as `ReadOnlySpan`, however when checking if a key exists or removing keys, usually you don't have pre-existing reference to the key, which means you have to use rather low level APIs to efficiently generate a `ReadOnlySpan` key. + +To make this process much easier, and help with type safety, `ArrowDb` exposes a static `GenerateTypedKey` method that accepts the type of the value, specific key (identifier) and a buffer, it returns a `ReadOnlySpan` key that prefixes the type to the specific key. + +For example, if you have a `Person` class (from examples above): + +```csharp +// we need a buffer (we can rent one from a pool, or allocate it ourselves) +// in this example we will rent memory +using var memoryOwner = MemoryPool.Shared.Rent(128); +// in this example 128 chars will be sufficient, use the smallest size that fits your needs +ReadOnlySpan key = ArrowDb.GenerateTypedKey("john", buffer.Memory.Span); +// key is now ReadOnlySpan that contains "Person:john" +// we can use it for Upsert, ContainsKey, TryGetValue, Remove, etc... +_ = db.ContainsKey(key); +_ = db.TryGetValue(key, MyJsonContext.Default.Person, out var person); +// etc... +``` + +This can also be used to filter out keys for mass lookups: + +```csharp +// get all keys +var keys = db.Keys; +// get the type name +var prefix = typeof(Person).Name; +// get all keys where the value type is Person +var people = keys.Where(k => k.StartsWith(prefix)); +``` + ## Use `ArrowDb` for Runtime Caching `ArrowDb` is a great fit for runtime caching, as it is extremely lightweight, fast, type-safe and thread-safe. To support this use case, `ArrowDb` provides a ‘NoOp’ serializer that does not persist the data and keeps it in volatile memory. This is used via the factory method: From a2a0d4b551ad6ab77b6016691ed2f87c92eb32ce Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 20:53:44 +0200 Subject: [PATCH 09/10] Renamed tests --- ...un-durability-tests.yaml => integrity-tests.yaml} | 8 ++++---- .../{run-unit-tests.yaml => unit-tests.yaml} | 2 +- ArrowDbCore.sln | 12 ++++++------ src/ArrowDbCore/ArrowDbCore.csproj | 2 +- .../ArrowDbCore.Tests.Integrity.csproj} | 0 .../JContext.cs | 2 +- .../LargeFile.cs | 2 +- .../Person.cs | 2 +- .../ReadWriteCycles.cs | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) rename .github/workflows/{run-durability-tests.yaml => integrity-tests.yaml} (86%) rename .github/workflows/{run-unit-tests.yaml => unit-tests.yaml} (98%) rename tests/{ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj => ArrowDbCore.Tests.Integrity/ArrowDbCore.Tests.Integrity.csproj} (100%) rename tests/{ArrowDbCore.Tests.Durability => ArrowDbCore.Tests.Integrity}/JContext.cs (87%) rename tests/{ArrowDbCore.Tests.Durability => ArrowDbCore.Tests.Integrity}/LargeFile.cs (97%) rename tests/{ArrowDbCore.Tests.Durability => ArrowDbCore.Tests.Integrity}/Person.cs (81%) rename tests/{ArrowDbCore.Tests.Durability => ArrowDbCore.Tests.Integrity}/ReadWriteCycles.cs (97%) diff --git a/.github/workflows/run-durability-tests.yaml b/.github/workflows/integrity-tests.yaml similarity index 86% rename from .github/workflows/run-durability-tests.yaml rename to .github/workflows/integrity-tests.yaml index 39a04b6..9204ef3 100644 --- a/.github/workflows/run-durability-tests.yaml +++ b/.github/workflows/integrity-tests.yaml @@ -1,4 +1,4 @@ -name: Run Durability Tests +name: Integrity Tests on: pull_request: @@ -16,7 +16,7 @@ jobs: env: # Define the path to project and test project PROJECT: src/ArrowDbCore/ArrowDbCore.csproj - TEST_PROJECT: tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj + TEST_PROJECT: tests/ArrowDbCore.Tests.Integrity/ArrowDbCore.Tests.Integrity.csproj steps: # 1. Checkout the repository code @@ -44,6 +44,6 @@ jobs: dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }} dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }} - # 5. Run Durability Tests - - name: Run Durability Tests + # 5. Run Integrity Tests + - name: Run Integrity Tests run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }} \ No newline at end of file diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/unit-tests.yaml similarity index 98% rename from .github/workflows/run-unit-tests.yaml rename to .github/workflows/unit-tests.yaml index 9d80a72..4e85da6 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -1,4 +1,4 @@ -name: Run Unit Tests +name: Unit Tests on: pull_request: diff --git a/ArrowDbCore.sln b/ArrowDbCore.sln index 2235349..679eb26 100644 --- a/ArrowDbCore.sln +++ b/ArrowDbCore.sln @@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArrowDbCore.Benchmarks", "benchmarks\ArrowDbCore.Benchmarks\ArrowDbCore.Benchmarks.csproj", "{419CA340-26F0-4FC1-83AC-D06A93AAB190}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArrowDbCore.Tests.Durability", "tests\ArrowDbCore.Tests.Durability\ArrowDbCore.Tests.Durability.csproj", "{BD64C8CB-1B06-4F78-890A-F830ED2EF982}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArrowDbCore.Tests.Integrity", "tests\ArrowDbCore.Tests.Integrity\ArrowDbCore.Tests.Integrity.csproj", "{39B1435C-B9E0-40A8-ABA9-7BB2F2CCF787}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -38,15 +38,15 @@ Global {419CA340-26F0-4FC1-83AC-D06A93AAB190}.Debug|Any CPU.Build.0 = Debug|Any CPU {419CA340-26F0-4FC1-83AC-D06A93AAB190}.Release|Any CPU.ActiveCfg = Release|Any CPU {419CA340-26F0-4FC1-83AC-D06A93AAB190}.Release|Any CPU.Build.0 = Release|Any CPU - {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BD64C8CB-1B06-4F78-890A-F830ED2EF982}.Release|Any CPU.Build.0 = Release|Any CPU + {39B1435C-B9E0-40A8-ABA9-7BB2F2CCF787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39B1435C-B9E0-40A8-ABA9-7BB2F2CCF787}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39B1435C-B9E0-40A8-ABA9-7BB2F2CCF787}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39B1435C-B9E0-40A8-ABA9-7BB2F2CCF787}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {23F42F88-1579-4087-ABF2-814EDBD53F59} = {822210FC-B851-4C2C-AEAE-250F17687CC3} {CDBBF9DF-5F8B-41C0-AAE7-2EC157C3BA1D} = {4ED1B77D-F425-487C-B32C-53F92A8E5A2E} {419CA340-26F0-4FC1-83AC-D06A93AAB190} = {9844EA79-5000-4276-A2C4-D7BA430F18B4} - {BD64C8CB-1B06-4F78-890A-F830ED2EF982} = {4ED1B77D-F425-487C-B32C-53F92A8E5A2E} + {39B1435C-B9E0-40A8-ABA9-7BB2F2CCF787} = {4ED1B77D-F425-487C-B32C-53F92A8E5A2E} EndGlobalSection EndGlobal diff --git a/src/ArrowDbCore/ArrowDbCore.csproj b/src/ArrowDbCore/ArrowDbCore.csproj index 8b14edd..07c1da9 100644 --- a/src/ArrowDbCore/ArrowDbCore.csproj +++ b/src/ArrowDbCore/ArrowDbCore.csproj @@ -40,7 +40,7 @@ <_Parameter1>ArrowDbCore.Tests.Unit - <_Parameter1>ArrowDbCore.Tests.Durability + <_Parameter1>ArrowDbCore.Tests.Integrity diff --git a/tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj b/tests/ArrowDbCore.Tests.Integrity/ArrowDbCore.Tests.Integrity.csproj similarity index 100% rename from tests/ArrowDbCore.Tests.Durability/ArrowDbCore.Tests.Durability.csproj rename to tests/ArrowDbCore.Tests.Integrity/ArrowDbCore.Tests.Integrity.csproj diff --git a/tests/ArrowDbCore.Tests.Durability/JContext.cs b/tests/ArrowDbCore.Tests.Integrity/JContext.cs similarity index 87% rename from tests/ArrowDbCore.Tests.Durability/JContext.cs rename to tests/ArrowDbCore.Tests.Integrity/JContext.cs index 6cc56df..20a8de5 100644 --- a/tests/ArrowDbCore.Tests.Durability/JContext.cs +++ b/tests/ArrowDbCore.Tests.Integrity/JContext.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace ArrowDbCore.Tests.Durability; +namespace ArrowDbCore.Tests.Integrity; [JsonSourceGenerationOptions(WriteIndented = false, NumberHandling = JsonNumberHandling.AllowReadingFromString, UseStringEnumConverter = true)] [JsonSerializable(typeof(Person))] diff --git a/tests/ArrowDbCore.Tests.Durability/LargeFile.cs b/tests/ArrowDbCore.Tests.Integrity/LargeFile.cs similarity index 97% rename from tests/ArrowDbCore.Tests.Durability/LargeFile.cs rename to tests/ArrowDbCore.Tests.Integrity/LargeFile.cs index 9b5e0a0..32e58c9 100644 --- a/tests/ArrowDbCore.Tests.Durability/LargeFile.cs +++ b/tests/ArrowDbCore.Tests.Integrity/LargeFile.cs @@ -1,6 +1,6 @@ using Bogus; -namespace ArrowDbCore.Tests.Durability; +namespace ArrowDbCore.Tests.Integrity; public class LargeFile { [Fact] diff --git a/tests/ArrowDbCore.Tests.Durability/Person.cs b/tests/ArrowDbCore.Tests.Integrity/Person.cs similarity index 81% rename from tests/ArrowDbCore.Tests.Durability/Person.cs rename to tests/ArrowDbCore.Tests.Integrity/Person.cs index 12c0b2d..ace3c71 100644 --- a/tests/ArrowDbCore.Tests.Durability/Person.cs +++ b/tests/ArrowDbCore.Tests.Integrity/Person.cs @@ -1,4 +1,4 @@ -namespace ArrowDbCore.Tests.Durability; +namespace ArrowDbCore.Tests.Integrity; public class Person { public string Name { get; set; } = string.Empty; diff --git a/tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs b/tests/ArrowDbCore.Tests.Integrity/ReadWriteCycles.cs similarity index 97% rename from tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs rename to tests/ArrowDbCore.Tests.Integrity/ReadWriteCycles.cs index 723f02b..f7f5e88 100644 --- a/tests/ArrowDbCore.Tests.Durability/ReadWriteCycles.cs +++ b/tests/ArrowDbCore.Tests.Integrity/ReadWriteCycles.cs @@ -1,6 +1,6 @@ using Bogus; -namespace ArrowDbCore.Tests.Durability; +namespace ArrowDbCore.Tests.Integrity; public class ReadWriteCycles { From 8787b0457ce8a34c67f9b0e54e2738268c866835 Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 26 Jan 2025 20:54:35 +0200 Subject: [PATCH 10/10] Added test badges --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f90a566..ed0bb73 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@
- [![NuGet](https://img.shields.io/nuget/v/ArrowDb.svg)](https://www.nuget.org/packages/ArrowDb) + [![NuGet Downloads](https://img.shields.io/nuget/dt/ArrowDb?style=flat&label=Nuget%20-%20ArrowDb)](https://www.nuget.org/packages/ArrowDb) + [![Unit Tests](https://github.com/dusrdev/ArrowDb/actions/workflows/unit-tests.yaml/badge.svg)](https://github.com/dusrdev/ArrowDb/actions/workflows/unit-tests.yaml) + [![Integrity Tests](https://github.com/dusrdev/ArrowDb/actions/workflows/integrity-tests.yaml/badge.svg)](https://github.com/dusrdev/ArrowDb/actions/workflows/integrity-tests.yaml)