From 153a1b31ab693b6cc8c06614cb46815327b9e855 Mon Sep 17 00:00:00 2001 From: scottf Date: Mon, 24 Jun 2024 14:08:23 -0400 Subject: [PATCH 1/4] [Bug] Maximum Message Size accepted a long, but should accept an int --- src/NATS.Client/Internals/Validator.cs | 15 ++++++++-- .../JetStream/StreamConfiguration.cs | 29 ++++++++++++++----- .../KeyValue/KeyValueConfiguration.cs | 21 ++++++++++++-- src/NATS.Client/KeyValue/KeyValueStatus.cs | 11 +++++-- .../JetStreamManageStreams.cs | 2 +- src/Tests/IntegrationTests/TestJetStream.cs | 2 +- .../TestJetStreamManagement.cs | 10 +++---- src/Tests/IntegrationTests/TestKeyValue.cs | 7 +++-- .../JetStream/TestStreamConfiguration.cs | 6 +++- .../UnitTests/JetStream/TestStreamInfo.cs | 1 + 10 files changed, 80 insertions(+), 24 deletions(-) diff --git a/src/NATS.Client/Internals/Validator.cs b/src/NATS.Client/Internals/Validator.cs index 1817277b8..a5209a8bb 100644 --- a/src/NATS.Client/Internals/Validator.cs +++ b/src/NATS.Client/Internals/Validator.cs @@ -359,14 +359,25 @@ internal static long ValidateMaxBucketBytes(long max) return ValidateGtZeroOrMinus1(max, "Max BucketBytes"); // max bucket bytes is a kv alias to max bytes } + internal static long ValidateMaxMessageSize(long max, string label) + { + long l = ValidateGtZeroOrMinus1(max, label); + if (l > int.MaxValue) + { + throw new ArgumentException($"{label} cannot be larger than {int.MaxValue}"); + } + + return l; + } + internal static long ValidateMaxMessageSize(long max) { - return ValidateGtZeroOrMinus1(max, "Max Message Size"); + return ValidateMaxMessageSize(max, "Max Message Size"); } internal static long ValidateMaxValueSize(long max) { - return ValidateGtZeroOrMinus1(max, "Max Value Size"); // max value size is a kv alias to max message size + return ValidateMaxMessageSize(max, "Max Value Size"); // max value size is a kv alias to max message size } internal static int ValidateNumberOfReplicas(int replicas) diff --git a/src/NATS.Client/JetStream/StreamConfiguration.cs b/src/NATS.Client/JetStream/StreamConfiguration.cs index 09e2f922d..5690d961b 100644 --- a/src/NATS.Client/JetStream/StreamConfiguration.cs +++ b/src/NATS.Client/JetStream/StreamConfiguration.cs @@ -31,7 +31,7 @@ public sealed class StreamConfiguration : JsonSerializable public long MaxMsgsPerSubject { get; } public long MaxBytes { get; } public Duration MaxAge { get; } - public long MaxMsgSize { get; } + public int MaximumMessageSize { get; } public StorageType StorageType { get; } public int Replicas { get; } public bool NoAck { get; } @@ -54,8 +54,10 @@ public sealed class StreamConfiguration : JsonSerializable public IDictionary Metadata { get; } public ulong FirstSequence { get; private set; } - [Obsolete("MaxMsgSize was mistakenly renamed in a previous change.", false)] - public long MaxValueSize => MaxMsgSize; + [Obsolete("The server value is a 32-bit signed value. Use MaximumMessageSize.", false)] + public long MaxMsgSize => MaximumMessageSize; + [Obsolete("MaxMsgSize was mistakenly renamed in a previous change. Use MaximumMessageSize.", false)] + public long MaxValueSize => MaximumMessageSize; internal StreamConfiguration(string json) : this(JSON.Parse(json)) { } @@ -73,7 +75,7 @@ internal StreamConfiguration(JSONNode scNode) MaxMsgsPerSubject = AsLongOrMinus1(scNode, ApiConstants.MaxMsgsPerSubject); MaxBytes = AsLongOrMinus1(scNode, ApiConstants.MaxBytes); MaxAge = AsDuration(scNode, ApiConstants.MaxAge, Duration.Zero); - MaxMsgSize = AsLongOrMinus1(scNode, ApiConstants.MaxMsgSize); + MaximumMessageSize = AsIntOrMinus1(scNode, ApiConstants.MaxMsgSize); Replicas = scNode[ApiConstants.NumReplicas].AsInt; NoAck = scNode[ApiConstants.NoAck].AsBool; TemplateOwner = scNode[ApiConstants.TemplateOwner].Value; @@ -107,7 +109,7 @@ private StreamConfiguration(StreamConfigurationBuilder builder) MaxMsgsPerSubject = builder._maxMsgsPerSubject; MaxBytes = builder._maxBytes; MaxAge = builder._maxAge; - MaxMsgSize = builder._maxMsgSize; + MaximumMessageSize = builder._maxMsgSize; StorageType = builder._storageType; Replicas = builder._replicas; NoAck = builder._noAck; @@ -197,7 +199,7 @@ public sealed class StreamConfigurationBuilder internal long _maxMsgsPerSubject = -1; internal long _maxBytes = -1; internal Duration _maxAge = Duration.Zero; - internal long _maxMsgSize = -1; + internal int _maxMsgSize = -1; internal StorageType _storageType = StorageType.File; internal int _replicas = 1; internal bool _noAck; @@ -236,7 +238,7 @@ public StreamConfigurationBuilder(StreamConfiguration sc) _maxMsgsPerSubject = sc.MaxMsgsPerSubject; _maxBytes = sc.MaxBytes; _maxAge = sc.MaxAge; - _maxMsgSize = sc.MaxMsgSize; + _maxMsgSize = sc.MaximumMessageSize; _storageType = sc.StorageType; _replicas = sc.Replicas; _noAck = sc.NoAck; @@ -424,8 +426,19 @@ public StreamConfigurationBuilder WithMaxAge(long maxAgeMillis) { /// /// the maximum message size /// The StreamConfigurationBuilder + [Obsolete("The server value is a 32-bit signed value. Use WithMaximumMessageSize.", false)] public StreamConfigurationBuilder WithMaxMsgSize(long maxMsgSize) { - _maxMsgSize = Validator.ValidateMaxMessageSize(maxMsgSize); + _maxMsgSize = (int)Validator.ValidateMaxMessageSize(maxMsgSize); + return this; + } + + /// + /// Sets the maximum message size in the StreamConfiguration. + /// + /// the maximum message size + /// The StreamConfigurationBuilder + public StreamConfigurationBuilder WithMaximumMessageSize(int maxMsgSize) { + _maxMsgSize = (int)Validator.ValidateMaxMessageSize(maxMsgSize); return this; } diff --git a/src/NATS.Client/KeyValue/KeyValueConfiguration.cs b/src/NATS.Client/KeyValue/KeyValueConfiguration.cs index cca37234d..52aea2c46 100644 --- a/src/NATS.Client/KeyValue/KeyValueConfiguration.cs +++ b/src/NATS.Client/KeyValue/KeyValueConfiguration.cs @@ -58,7 +58,13 @@ internal KeyValueConfiguration(StreamConfiguration sc) /// /// The maximum size for an individual value in the bucket /// - public long MaxValueSize => BackingConfig.MaxMsgSize; + [Obsolete("The server value is a 32-bit signed value. Use MaximumValueSize.", false)] + public long MaxValueSize => BackingConfig.MaximumMessageSize; + + /// + /// The maximum size for an individual value in the bucket + /// + public int MaximumValueSize => BackingConfig.MaximumMessageSize; /// /// The maximum age for a value in this bucket @@ -215,8 +221,19 @@ public KeyValueConfigurationBuilder WithMaxBucketSize(long maxBucketSize) { /// /// the maximum size for a value /// + [Obsolete("The server value is a 32-bit signed value. Use WithMaximumValueSize.", false)] public KeyValueConfigurationBuilder WithMaxValueSize(long maxValueSize) { - scBuilder.WithMaxMsgSize(Validator.ValidateMaxValueSize(maxValueSize)); + scBuilder.WithMaximumMessageSize((int)Validator.ValidateMaxValueSize(maxValueSize)); + return this; + } + + /// + /// Sets the maximum size for an individual value in the KeyValueConfiguration. + /// + /// the maximum size for a value + /// + public KeyValueConfigurationBuilder WithMaximumValueSize(int maxValueSize) { + scBuilder.WithMaximumMessageSize((int)Validator.ValidateMaxValueSize(maxValueSize)); return this; } diff --git a/src/NATS.Client/KeyValue/KeyValueStatus.cs b/src/NATS.Client/KeyValue/KeyValueStatus.cs index c48374895..ec74c64dc 100644 --- a/src/NATS.Client/KeyValue/KeyValueStatus.cs +++ b/src/NATS.Client/KeyValue/KeyValueStatus.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using System.Collections.Generic; using NATS.Client.Internals; using NATS.Client.JetStream; @@ -67,7 +68,13 @@ public KeyValueStatus(StreamInfo si) { /// /// The maximum size for an individual value in the bucket /// - public long MaxValueSize => Config.MaxValueSize; + [Obsolete("The server value is a 32-bit signed value. Use MaximumValueSize.", false)] + public long MaxValueSize => Config.MaximumValueSize; + + /// + /// The maximum size for an individual value in the bucket + /// + public long MaximumValueSize => Config.MaximumValueSize; /// /// The maximum age for a value in this bucket @@ -111,7 +118,7 @@ public KeyValueStatus(StreamInfo si) { public override string ToString() { - return $"BucketName: {BucketName}, Description: {Description}, EntryCount: {EntryCount}, MaxHistoryPerKey: {MaxHistoryPerKey}, MaxBucketSize: {MaxBucketSize}, MaxValueSize: {MaxValueSize}, Ttl: {Ttl}, StorageType: {StorageType}, Replicas: {Replicas}, BackingStore: {BackingStore}"; + return $"BucketName: {BucketName}, Description: {Description}, EntryCount: {EntryCount}, MaxHistoryPerKey: {MaxHistoryPerKey}, MaxBucketSize: {MaxBucketSize}, MaximumValueSize: {MaximumValueSize}, Ttl: {Ttl}, StorageType: {StorageType}, Replicas: {Replicas}, BackingStore: {BackingStore}"; } } } diff --git a/src/Samples/JetStreamManageStreams/JetStreamManageStreams.cs b/src/Samples/JetStreamManageStreams/JetStreamManageStreams.cs index 775108e09..dfd2b7975 100644 --- a/src/Samples/JetStreamManageStreams/JetStreamManageStreams.cs +++ b/src/Samples/JetStreamManageStreams/JetStreamManageStreams.cs @@ -64,7 +64,7 @@ public static void Main(string[] args) // .WithMaxConsumers(...) // .WithMaxBytes(...) // .WithMaxAge(...) - // .WithMaxMsgSize(...) + // .WithMaximumMessageSize(...) .WithStorageType(StorageType.Memory) // .WithReplicas(...) // .WithNoAck(...) diff --git a/src/Tests/IntegrationTests/TestJetStream.cs b/src/Tests/IntegrationTests/TestJetStream.cs index 507f0bdd3..82ef88494 100644 --- a/src/Tests/IntegrationTests/TestJetStream.cs +++ b/src/Tests/IntegrationTests/TestJetStream.cs @@ -1064,7 +1064,7 @@ public async Task TestMaxPayloadJs() .WithName(streamName) .WithStorageType(StorageType.Memory) .WithSubjects(subject1, subject2) - .WithMaxMsgSize(1000) + .WithMaximumMessageSize(1000) .Build() ); diff --git a/src/Tests/IntegrationTests/TestJetStreamManagement.cs b/src/Tests/IntegrationTests/TestJetStreamManagement.cs index 9fe14de03..6eefda805 100644 --- a/src/Tests/IntegrationTests/TestJetStreamManagement.cs +++ b/src/Tests/IntegrationTests/TestJetStreamManagement.cs @@ -59,7 +59,7 @@ public void TestStreamCreate() Assert.Equal(-1, sc.MaxConsumers); Assert.Equal(-1, sc.MaxMsgs); Assert.Equal(-1, sc.MaxBytes); - Assert.Equal(-1, sc.MaxMsgSize); + Assert.Equal(-1, sc.MaximumMessageSize); Assert.Equal(1, sc.Replicas); Assert.Equal(1U, sc.FirstSequence); @@ -121,7 +121,7 @@ public void TestStreamCreateWithNoSubject() { Assert.Equal(-1, sc.MaxConsumers); Assert.Equal(-1, sc.MaxMsgs); Assert.Equal(-1, sc.MaxBytes); - Assert.Equal(-1, sc.MaxMsgSize); + Assert.Equal(-1, sc.MaximumMessageSize); Assert.Equal(1, sc.Replicas); Assert.Equal(Duration.Zero, sc.MaxAge); @@ -153,7 +153,7 @@ public void TestUpdateStream() Assert.Equal(Subject(0), sc.Subjects[0]); Assert.Equal(Subject(1), sc.Subjects[1]); Assert.Equal(-1, sc.MaxBytes); - Assert.Equal(-1, sc.MaxMsgSize); + Assert.Equal(-1, sc.MaximumMessageSize); Assert.Equal(Duration.Zero, sc.MaxAge); Assert.Equal(StorageType.Memory, sc.StorageType); Assert.Equal(DiscardPolicy.Old, sc.DiscardPolicy); @@ -167,7 +167,7 @@ public void TestUpdateStream() .WithStorageType(StorageType.Memory) .WithSubjects(Subject(0), Subject(1), Subject(2)) .WithMaxBytes(43) - .WithMaxMsgSize(44) + .WithMaximumMessageSize(44) .WithMaxAge(Duration.OfDays(100)) .WithDiscardPolicy(DiscardPolicy.New) .WithNoAck(true) @@ -185,7 +185,7 @@ public void TestUpdateStream() Assert.Equal(Subject(1), sc.Subjects[1]); Assert.Equal(Subject(2), sc.Subjects[2]); Assert.Equal(43u, sc.MaxBytes); - Assert.Equal(44, sc.MaxMsgSize); + Assert.Equal(44, sc.MaximumMessageSize); Assert.Equal(Duration.OfDays(100), sc.MaxAge); Assert.Equal(StorageType.Memory, sc.StorageType); Assert.Equal(DiscardPolicy.New, sc.DiscardPolicy); diff --git a/src/Tests/IntegrationTests/TestKeyValue.cs b/src/Tests/IntegrationTests/TestKeyValue.cs index a7cfa3fae..241bc9ef5 100644 --- a/src/Tests/IntegrationTests/TestKeyValue.cs +++ b/src/Tests/IntegrationTests/TestKeyValue.cs @@ -76,6 +76,8 @@ public void TestWorkFlow() Assert.Equal(-1, kvc.MaxBucketSize); Assert.Equal(-1, status.MaxValueSize); Assert.Equal(-1, kvc.MaxValueSize); + Assert.Equal(-1, status.MaximumValueSize); + Assert.Equal(-1, kvc.MaximumValueSize); Assert.Equal(Duration.Zero, status.Ttl); Assert.Equal(Duration.Zero, kvc.Ttl); Assert.Equal(StorageType.Memory, status.StorageType); @@ -557,7 +559,7 @@ public void TestCreateUpdate() { Assert.Empty(kvs.Description); Assert.Equal(1, kvs.MaxHistoryPerKey); Assert.Equal(-1, kvs.MaxBucketSize); - Assert.Equal(-1, kvs.MaxValueSize); + Assert.Equal(-1, kvs.MaximumValueSize); Assert.Equal(Duration.Zero, kvs.Ttl); Assert.Equal(StorageType.Memory, kvs.StorageType); Assert.Equal(1, kvs.Replicas); @@ -580,7 +582,7 @@ public void TestCreateUpdate() { .WithDescription(Plain) .WithMaxHistoryPerKey(3) .WithMaxBucketSize(10_000) - .WithMaxValueSize(100) + .WithMaximumValueSize(100) .WithTtl(Duration.OfHours(1)) .Build(); @@ -591,6 +593,7 @@ public void TestCreateUpdate() { Assert.Equal(3, kvs.MaxHistoryPerKey); Assert.Equal(10_000, kvs.MaxBucketSize); Assert.Equal(100, kvs.MaxValueSize); + Assert.Equal(100, kvs.MaximumValueSize); Assert.Equal(Duration.OfHours(1), kvs.Ttl); Assert.Equal(StorageType.Memory, kvs.StorageType); Assert.Equal(1, kvs.Replicas); diff --git a/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs b/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs index 6c64fc449..c4ab4c172 100644 --- a/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs +++ b/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs @@ -52,7 +52,7 @@ public void TestConstruction() .WithMaxMessagesPerSubject(testSc.MaxMsgsPerSubject) .WithMaxBytes(testSc.MaxBytes) .WithMaxAge(testSc.MaxAge) - .WithMaxMsgSize(testSc.MaxMsgSize) + .WithMaximumMessageSize(testSc.MaximumMessageSize) .WithStorageType(testSc.StorageType) .WithReplicas(testSc.Replicas) .WithNoAck(testSc.NoAck) @@ -110,6 +110,9 @@ public void TestConstructionInvalidsCoverage() Assert.Throws(() => StreamConfiguration.Builder().WithMaxAge(-1)); Assert.Throws(() => StreamConfiguration.Builder().WithMaxMsgSize(0)); Assert.Throws(() => StreamConfiguration.Builder().WithMaxMsgSize(-2)); + Assert.Throws(() => StreamConfiguration.Builder().WithMaxMsgSize((long)int.MaxValue + 1)); + Assert.Throws(() => StreamConfiguration.Builder().WithMaximumMessageSize(0)); + Assert.Throws(() => StreamConfiguration.Builder().WithMaximumMessageSize(-2)); Assert.Throws(() => StreamConfiguration.Builder().WithReplicas(0)); Assert.Throws(() => StreamConfiguration.Builder().WithReplicas(6)); Assert.Throws(() => StreamConfiguration.Builder().WithDuplicateWindow(Duration.OfNanos(-1))); @@ -283,6 +286,7 @@ private void Validate(StreamConfiguration sc, bool serverTest) Assert.Equal(Duration.OfNanos(43000000000L), sc.MaxAge); Assert.Equal(Duration.OfNanos(42000000000L), sc.DuplicateWindow); Assert.Equal(734, sc.MaxMsgSize); + Assert.Equal(734, sc.MaximumMessageSize); Assert.Equal(StorageType.Memory, sc.StorageType); Assert.Equal(DiscardPolicy.New, sc.DiscardPolicy); diff --git a/src/Tests/UnitTests/JetStream/TestStreamInfo.cs b/src/Tests/UnitTests/JetStream/TestStreamInfo.cs index 06db61354..56714a0ae 100644 --- a/src/Tests/UnitTests/JetStream/TestStreamInfo.cs +++ b/src/Tests/UnitTests/JetStream/TestStreamInfo.cs @@ -41,6 +41,7 @@ public void JsonIsReadProperly() Assert.Equal(DiscardPolicy.Old, si.Config.DiscardPolicy); Assert.Equal(100000000000, si.Config.MaxAge.Nanos); Assert.Equal(4, si.Config.MaxMsgSize); + Assert.Equal(4, si.Config.MaximumMessageSize); Assert.Equal(StorageType.Memory, si.Config.StorageType); Assert.Equal(5, si.Config.Replicas); Assert.Equal(120000000000, si.Config.DuplicateWindow.Nanos); From 6b84629cdbc25bfa448a2f248f64136526fc4b5f Mon Sep 17 00:00:00 2001 From: scottf Date: Mon, 24 Jun 2024 14:16:43 -0400 Subject: [PATCH 2/4] [Bug] Maximum Message Size accepted a long, but should accept an int --- src/NATS.Client/JetStream/StreamConfiguration.cs | 2 +- src/NATS.Client/KeyValue/KeyValueConfiguration.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NATS.Client/JetStream/StreamConfiguration.cs b/src/NATS.Client/JetStream/StreamConfiguration.cs index 5690d961b..e05ce505a 100644 --- a/src/NATS.Client/JetStream/StreamConfiguration.cs +++ b/src/NATS.Client/JetStream/StreamConfiguration.cs @@ -151,7 +151,7 @@ public override JSONNode ToJsonNode() AddField(o, ApiConstants.MaxMsgsPerSubject, MaxMsgsPerSubject); AddField(o, ApiConstants.MaxBytes, MaxBytes); AddField(o, ApiConstants.MaxAge, MaxAge.Nanos); - AddField(o, ApiConstants.MaxMsgSize, MaxMsgSize); + AddField(o, ApiConstants.MaxMsgSize, MaximumMessageSize); AddField(o, ApiConstants.NumReplicas, Replicas); AddField(o, ApiConstants.NoAck, NoAck); AddField(o, ApiConstants.TemplateOwner, TemplateOwner); diff --git a/src/NATS.Client/KeyValue/KeyValueConfiguration.cs b/src/NATS.Client/KeyValue/KeyValueConfiguration.cs index 52aea2c46..38beb8fd4 100644 --- a/src/NATS.Client/KeyValue/KeyValueConfiguration.cs +++ b/src/NATS.Client/KeyValue/KeyValueConfiguration.cs @@ -445,7 +445,7 @@ public KeyValueConfiguration Build() { public override string ToString() { - return $"BucketName: {BucketName}, Description: {Description}, MaxHistoryPerKey: {MaxHistoryPerKey}, MaxBucketSize: {MaxBucketSize}, MaxValueSize: {MaxValueSize}, Ttl: {Ttl}, StorageType: {StorageType}, Replicas: {Replicas} Placement: {Placement}, Republish: {Republish}, IsCompressed: {IsCompressed}"; + return $"BucketName: {BucketName}, Description: {Description}, MaxHistoryPerKey: {MaxHistoryPerKey}, MaxBucketSize: {MaxBucketSize}, MaximumValueSize: {MaximumValueSize}, Ttl: {Ttl}, StorageType: {StorageType}, Replicas: {Replicas} Placement: {Placement}, Republish: {Republish}, IsCompressed: {IsCompressed}"; } } } From 7be7159371d02e014b0293589ee9c2218746f184 Mon Sep 17 00:00:00 2001 From: scottf Date: Mon, 24 Jun 2024 14:38:38 -0400 Subject: [PATCH 3/4] [Bug] Maximum Message Size accepted a long, but should accept an int --- src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs | 4 ---- src/Tests/UnitTests/JetStream/TestStreamInfo.cs | 1 - 2 files changed, 5 deletions(-) diff --git a/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs b/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs index c4ab4c172..8de15c417 100644 --- a/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs +++ b/src/Tests/UnitTests/JetStream/TestStreamConfiguration.cs @@ -108,9 +108,6 @@ public void TestConstructionInvalidsCoverage() Assert.Throws(() => StreamConfiguration.Builder().WithMaxBytes(-2)); Assert.Throws(() => StreamConfiguration.Builder().WithMaxAge(Duration.OfNanos(-1))); Assert.Throws(() => StreamConfiguration.Builder().WithMaxAge(-1)); - Assert.Throws(() => StreamConfiguration.Builder().WithMaxMsgSize(0)); - Assert.Throws(() => StreamConfiguration.Builder().WithMaxMsgSize(-2)); - Assert.Throws(() => StreamConfiguration.Builder().WithMaxMsgSize((long)int.MaxValue + 1)); Assert.Throws(() => StreamConfiguration.Builder().WithMaximumMessageSize(0)); Assert.Throws(() => StreamConfiguration.Builder().WithMaximumMessageSize(-2)); Assert.Throws(() => StreamConfiguration.Builder().WithReplicas(0)); @@ -285,7 +282,6 @@ private void Validate(StreamConfiguration sc, bool serverTest) Assert.Equal(732, sc.MaxBytes); Assert.Equal(Duration.OfNanos(43000000000L), sc.MaxAge); Assert.Equal(Duration.OfNanos(42000000000L), sc.DuplicateWindow); - Assert.Equal(734, sc.MaxMsgSize); Assert.Equal(734, sc.MaximumMessageSize); Assert.Equal(StorageType.Memory, sc.StorageType); Assert.Equal(DiscardPolicy.New, sc.DiscardPolicy); diff --git a/src/Tests/UnitTests/JetStream/TestStreamInfo.cs b/src/Tests/UnitTests/JetStream/TestStreamInfo.cs index 56714a0ae..f6e0f17ae 100644 --- a/src/Tests/UnitTests/JetStream/TestStreamInfo.cs +++ b/src/Tests/UnitTests/JetStream/TestStreamInfo.cs @@ -40,7 +40,6 @@ public void JsonIsReadProperly() Assert.Equal(3u, si.Config.MaxBytes); Assert.Equal(DiscardPolicy.Old, si.Config.DiscardPolicy); Assert.Equal(100000000000, si.Config.MaxAge.Nanos); - Assert.Equal(4, si.Config.MaxMsgSize); Assert.Equal(4, si.Config.MaximumMessageSize); Assert.Equal(StorageType.Memory, si.Config.StorageType); Assert.Equal(5, si.Config.Replicas); From 0888ecab2d124582579b837c9826f148302f35a7 Mon Sep 17 00:00:00 2001 From: scottf Date: Mon, 24 Jun 2024 15:15:31 -0400 Subject: [PATCH 4/4] [Bug] Maximum Message Size accepted a long, but should accept an int --- src/Tests/IntegrationTests/TestKeyValue.cs | 3 --- .../UnitTests/JetStream/TestKeyValueConfiguration.cs | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Tests/IntegrationTests/TestKeyValue.cs b/src/Tests/IntegrationTests/TestKeyValue.cs index 241bc9ef5..3b8e81679 100644 --- a/src/Tests/IntegrationTests/TestKeyValue.cs +++ b/src/Tests/IntegrationTests/TestKeyValue.cs @@ -74,8 +74,6 @@ public void TestWorkFlow() Assert.Equal(3, kvc.MaxHistoryPerKey); Assert.Equal(-1, status.MaxBucketSize); Assert.Equal(-1, kvc.MaxBucketSize); - Assert.Equal(-1, status.MaxValueSize); - Assert.Equal(-1, kvc.MaxValueSize); Assert.Equal(-1, status.MaximumValueSize); Assert.Equal(-1, kvc.MaximumValueSize); Assert.Equal(Duration.Zero, status.Ttl); @@ -592,7 +590,6 @@ public void TestCreateUpdate() { Assert.Equal(Plain, kvs.Description); Assert.Equal(3, kvs.MaxHistoryPerKey); Assert.Equal(10_000, kvs.MaxBucketSize); - Assert.Equal(100, kvs.MaxValueSize); Assert.Equal(100, kvs.MaximumValueSize); Assert.Equal(Duration.OfHours(1), kvs.Ttl); Assert.Equal(StorageType.Memory, kvs.StorageType); diff --git a/src/Tests/UnitTests/JetStream/TestKeyValueConfiguration.cs b/src/Tests/UnitTests/JetStream/TestKeyValueConfiguration.cs index b8ffd6285..bb7e3a948 100644 --- a/src/Tests/UnitTests/JetStream/TestKeyValueConfiguration.cs +++ b/src/Tests/UnitTests/JetStream/TestKeyValueConfiguration.cs @@ -33,7 +33,7 @@ public void TestConstructionWorks() { .WithName("bucketName") .WithMaxHistoryPerKey(44) .WithMaxBucketSize(555) - .WithMaxValueSize(666) + .WithMaximumValueSize(666) .WithTtl(Duration.OfMillis(777)) .WithStorageType(StorageType.Memory) .WithReplicas(2) @@ -59,7 +59,7 @@ private void Validate(KeyValueConfiguration kvc) { Assert.Equal("bucketName", kvc.BucketName); Assert.Equal(44, kvc.MaxHistoryPerKey); Assert.Equal(555, kvc.MaxBucketSize); - Assert.Equal(666, kvc.MaxValueSize); + Assert.Equal(666, kvc.MaximumValueSize); Assert.Equal(Duration.OfMillis(777), kvc.Ttl); Assert.Equal(StorageType.Memory, kvc.StorageType); Assert.True(kvc.AllowDirect); @@ -171,8 +171,8 @@ public void TestConstructionInvalidsCoverage() { Assert.Throws(() => KeyValueConfiguration.Builder().WithMaxHistoryPerKey(65)); Assert.Throws(() => KeyValueConfiguration.Builder().WithMaxBucketSize(0)); Assert.Throws(() => KeyValueConfiguration.Builder().WithMaxBucketSize(-2)); - Assert.Throws(() => KeyValueConfiguration.Builder().WithMaxValueSize(0)); - Assert.Throws(() => KeyValueConfiguration.Builder().WithMaxValueSize(-2)); + Assert.Throws(() => KeyValueConfiguration.Builder().WithMaximumValueSize(0)); + Assert.Throws(() => KeyValueConfiguration.Builder().WithMaximumValueSize(-2)); Assert.Throws(() => KeyValueConfiguration.Builder().WithTtl(Duration.OfNanos(-1))); Assert.Throws(() => KeyValueConfiguration.Builder().WithReplicas(0)); Assert.Throws(() => KeyValueConfiguration.Builder().WithReplicas(6));