Skip to content

Commit 70ffd6e

Browse files
authored
fix(nats): Validate StorageType and pin NATS test endpoint (follow-up to #10028) (#10176)
* feat: validate StorageType in NatsStreamOptionsValidator Reject StorageType values that are not defined StreamConfigStorage enum members before they reach JetStream, throwing OrleansConfigurationException with the valid values (File/Memory). Addresses review feedback on #10028. * test: pin NATS endpoint in StorageType test Addresses PR #10028 review: use NatsTestConstants.NatsClientOptions for both the connection manager options and the verification connection so the stream is created against and queried from the same pinned server endpoint.
1 parent e29301a commit 70ffd6e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/Orleans.Streaming.NATS/NatsOptions.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,12 @@ public void ValidateConfiguration()
9191
throw new OrleansConfigurationException(
9292
$"The {nameof(NatsOptions.NumReplicas)} must be at least 1 for the NATS stream provider '{name}'.");
9393
}
94+
95+
if (!Enum.IsDefined(typeof(StreamConfigStorage), options.StorageType))
96+
{
97+
throw new OrleansConfigurationException(
98+
$"The {nameof(NatsOptions.StorageType)} value '{options.StorageType}' is not valid for the NATS stream provider '{name}'. " +
99+
$"Valid values are {nameof(StreamConfigStorage.File)} and {nameof(StreamConfigStorage.Memory)}.");
100+
}
94101
}
95102
}

‎test/Extensions/Orleans.Streaming.NATS.Tests/NatsOptionsTests.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,14 @@ public async Task StorageType_IsAppliedToJetStreamConfig(StreamConfigStorage sto
160160
NumReplicas = 1,
161161
PartitionCount = 2,
162162
ProducerCount = 1,
163-
StorageType = storageType
163+
StorageType = storageType,
164+
NatsClientOptions = NatsTestConstants.NatsClientOptions
164165
};
165166

166167
var connectionManager = new NatsConnectionManager(providerName, NullLoggerFactory.Instance, options);
167168
await connectionManager.Initialize();
168169

169-
await using var natsConnection = new NatsConnection();
170+
await using var natsConnection = new NatsConnection(NatsTestConstants.NatsClientOptions);
170171
var natsContext = new NatsJSContext(natsConnection);
171172
await natsConnection.ConnectAsync();
172173

0 commit comments

Comments
 (0)