-
Notifications
You must be signed in to change notification settings - Fork 102
Object store item size fix #977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8a54203
Make the parameter-less StreamConfig constructor public
darkwatchuk 7a2ddf6
Merge branch 'nats-io:main' into main
darkwatchuk deb2c2e
Merge branch 'nats-io:main' into main
darkwatchuk 07df362
Merge branch 'nats-io:main' into main
darkwatchuk 2050c17
Make NatsMsg<T>.Build Public
darkwatchuk 134042d
Add docs
mtmk f0fdb45
Add docs
mtmk d45d936
Merge branch 'nats-io:main' into main
darkwatchuk 0b49cce
Merge branch 'nats-io:main' into main
darkwatchuk d5c2b4b
Change ObjectStore ObjectMetadata.Size to ulong from int
darkwatchuk 689c7f5
Copilot feedback
mtmk d871e11
Use `uint` for `Chunks` field and update related comments/test cases.
mtmk d125a80
Add test for validating metadata field types against NATS spec
mtmk 644958b
Keep format happy
mtmk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 contains hidden or 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 contains hidden or 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 |
|---|---|---|
|
|
@@ -82,7 +82,7 @@ public async Task Put_chunks() | |
|
|
||
| Assert.Equal($"SHA-256={sha}", data.Digest); | ||
| Assert.Equal(chunks, data.Chunks); | ||
| Assert.Equal(size, data.Size); | ||
| Assert.Equal((ulong)size, data.Size); | ||
| } | ||
|
|
||
| // buffer with smaller last chunk | ||
|
|
@@ -102,7 +102,7 @@ public async Task Put_chunks() | |
|
|
||
| Assert.Equal($"SHA-256={sha}", data.Digest); | ||
| Assert.Equal(chunks, data.Chunks); | ||
| Assert.Equal(size, data.Size); | ||
| Assert.Equal((ulong)size, data.Size); | ||
| } | ||
|
|
||
| // Object name checks | ||
|
|
@@ -195,7 +195,7 @@ public async Task Delete_object() | |
| await store.PutAsync("k1", new byte[] { 65, 66, 67 }, cancellationToken); | ||
|
|
||
| var info = await store.GetInfoAsync("k1", cancellationToken: cancellationToken); | ||
| Assert.Equal(3, info.Size); | ||
| Assert.Equal(3UL, info.Size); | ||
|
|
||
| var bytes = await store.GetBytesAsync("k1", cancellationToken); | ||
| Assert.Equal(bytes, new byte[] { 65, 66, 67 }); | ||
|
|
@@ -207,8 +207,8 @@ public async Task Delete_object() | |
|
|
||
| var info2 = await store.GetInfoAsync("k1", showDeleted: true, cancellationToken: cancellationToken); | ||
| Assert.True(info2.Deleted); | ||
| Assert.Equal(0, info2.Size); | ||
| Assert.Equal(0, info2.Chunks); | ||
| Assert.Equal(0UL, info2.Size); | ||
| Assert.Equal(0U, info2.Chunks); | ||
| Assert.Equal(string.Empty, info2.Digest); | ||
|
|
||
| // Put again | ||
|
|
@@ -622,4 +622,45 @@ await Assert.ThrowsAsync<NatsObjNotFoundException>(async () => | |
| await b1.GetBytesAsync("name1", cancellationToken: cancellationToken); | ||
| }); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task Metadata_field_types_match_spec() | ||
| { | ||
| var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); | ||
| var cancellationToken = cts.Token; | ||
|
|
||
| await using var server = await NatsServerProcess.StartAsync(); | ||
| await using var nats = new NatsConnection(new NatsOpts { Url = server.Url }); | ||
| var js = new NatsJSContext(nats); | ||
| var obj = new NatsObjContext(js); | ||
|
|
||
| var store = await obj.CreateObjectStoreAsync(new NatsObjConfig("b1"), cancellationToken); | ||
|
|
||
| // Test that Size property is ulong (uint64 in NATS spec) | ||
| var metadata = new ObjectMetadata { Name = "test" }; | ||
| metadata.Size = ulong.MaxValue; // Should compile without error | ||
| Assert.Equal(18446744073709551615UL, metadata.Size); | ||
|
|
||
| // Test that Chunks property is uint (uint32 in NATS spec) | ||
| metadata.Chunks = uint.MaxValue; // Should compile without error | ||
| Assert.Equal(4294967295U, metadata.Chunks); | ||
|
|
||
| // Test with actual object metadata from store | ||
| await store.PutAsync("k1", new byte[] { 1, 2, 3 }, cancellationToken: cancellationToken); | ||
| var info = await store.GetInfoAsync("k1", cancellationToken: cancellationToken); | ||
|
|
||
| // Verify Size is ulong | ||
| #pragma warning disable IDE0007 | ||
| // ReSharper disable once SuggestVarOrType_BuiltInTypes | ||
| ulong size = info.Size; // Should compile without error | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since using large files won't be possible I just check the type here. |
||
| #pragma warning restore IDE0007 | ||
| Assert.Equal(3UL, size); | ||
|
|
||
| // Verify Chunks is uint | ||
| #pragma warning disable IDE0007 | ||
| // ReSharper disable once SuggestVarOrType_BuiltInTypes | ||
| uint chunks = info.Chunks; // Should compile without error | ||
| #pragma warning restore IDE0007 | ||
| Assert.Equal(1U, chunks); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turns out this one is not align with the spec either (ADR-20)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have long (int 64) in both java and .net v1. ADR has uint32 so I think this is fine.