atharvalade commented on code in PR #2710:
URL: https://github.com/apache/iggy/pull/2710#discussion_r2790688006


##########
foreign/csharp/Iggy_SDK.Tests.Integration/ConsumerGroupTests.cs:
##########
@@ -21,157 +21,183 @@
 using Apache.Iggy.IggyClient;
 using Apache.Iggy.Tests.Integrations.Attributes;
 using Apache.Iggy.Tests.Integrations.Fixtures;
-using Apache.Iggy.Tests.Integrations.Helpers;
 using Shouldly;
 
 namespace Apache.Iggy.Tests.Integrations;
 
 public class ConsumerGroupTests
 {
-    private static readonly uint GroupId = 0;
-    private static readonly string GroupName = "test_consumer_group";
-    private Identifier TopicId => Identifier.String(Fixture.TopicId);
+    private const uint PartitionsCount = 10;
+    private const string TopicName = "cg-topic";
+    private const string GroupName = "test_consumer_group";
 
-    [ClassDataSource<ConsumerGroupFixture>(Shared = SharedType.PerClass)]
-    public required ConsumerGroupFixture Fixture { get; init; }
+    [ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
+    public required IggyServerFixture Fixture { get; init; }
+
+    private async Task<(IIggyClient client, string streamName)> 
CreateStreamAndTopic(Protocol protocol)
+    {
+        var client = protocol == Protocol.Tcp
+            ? await Fixture.CreateTcpClient()
+            : await Fixture.CreateHttpClient();
+
+        var streamName = $"cg-stream-{Guid.NewGuid():N}";
+        await client.CreateStreamAsync(streamName);
+        await client.CreateTopicAsync(Identifier.String(streamName), 
TopicName, PartitionsCount);
+        return (client, streamName);
+    }
 
     [Test]
     
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
     public async Task 
CreateConsumerGroup_HappyPath_Should_CreateConsumerGroup_Successfully(Protocol 
protocol)
     {
-        var consumerGroup
-            = await Fixture.Clients[protocol]
-                
.CreateConsumerGroupAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
 TopicId,
-                    GroupName);
+        var (client, streamName) = await CreateStreamAndTopic(protocol);
+
+        var consumerGroup = await client.CreateConsumerGroupAsync(
+            Identifier.String(streamName), Identifier.String(TopicName), 
GroupName);
 
         consumerGroup.ShouldNotBeNull();
-        consumerGroup.Id.ShouldBe(GroupId);
-        consumerGroup.PartitionsCount.ShouldBe(Fixture.PartitionsCount);
+        consumerGroup.Id.ShouldBeGreaterThanOrEqualTo(0u);
+        consumerGroup.PartitionsCount.ShouldBe(PartitionsCount);
         consumerGroup.MembersCount.ShouldBe(0u);
         consumerGroup.Name.ShouldBe(GroupName);
     }
 
     [Test]
-    
[DependsOn(nameof(CreateConsumerGroup_HappyPath_Should_CreateConsumerGroup_Successfully))]
     
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
     public async Task 
CreateConsumerGroup_Should_Throw_InvalidResponse(Protocol protocol)
     {
+        var (client, streamName) = await CreateStreamAndTopic(protocol);
+        await client.CreateConsumerGroupAsync(Identifier.String(streamName),
+            Identifier.String(TopicName), GroupName);
+
         await Should.ThrowAsync<IggyInvalidStatusCodeException>(() =>
-            Fixture.Clients[protocol]
-                
.CreateConsumerGroupAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
 TopicId,
-                    GroupName));
+            client.CreateConsumerGroupAsync(Identifier.String(streamName),
+                Identifier.String(TopicName), GroupName));
     }
 
     [Test]
-    [DependsOn(nameof(CreateConsumerGroup_Should_Throw_InvalidResponse))]
     
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
     public async Task 
GetConsumerGroupById_Should_Return_ValidResponse(Protocol protocol)
     {
-        var response = await Fixture.Clients[protocol]
-            
.GetConsumerGroupByIdAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
 TopicId,
-                Identifier.Numeric(GroupId));
+        var (client, streamName) = await CreateStreamAndTopic(protocol);
+        var cg = await 
client.CreateConsumerGroupAsync(Identifier.String(streamName),
+            Identifier.String(TopicName), GroupName);
+
+        var response = await client.GetConsumerGroupByIdAsync(
+            Identifier.String(streamName), Identifier.String(TopicName),
+            Identifier.Numeric(cg!.Id));
 
         response.ShouldNotBeNull();
-        response.Id.ShouldBe(GroupId);
+        response.Id.ShouldBe(cg.Id);
         response.Name.ShouldBe(GroupName);
-        response.PartitionsCount.ShouldBe(Fixture.PartitionsCount);
+        response.PartitionsCount.ShouldBe(PartitionsCount);
         response.MembersCount.ShouldBe(0u);
     }
 
     [Test]
-    [DependsOn(nameof(GetConsumerGroupById_Should_Return_ValidResponse))]
     
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
     public async Task GetConsumerGroups_Should_Return_ValidResponse(Protocol 
protocol)
     {
-        IReadOnlyList<ConsumerGroupResponse> response
-            = await Fixture.Clients[protocol]
-                
.GetConsumerGroupsAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
 TopicId);
+        var (client, streamName) = await CreateStreamAndTopic(protocol);
+        await client.CreateConsumerGroupAsync(Identifier.String(streamName),
+            Identifier.String(TopicName), GroupName);
+
+        IReadOnlyList<ConsumerGroupResponse> response = await 
client.GetConsumerGroupsAsync(
+            Identifier.String(streamName), Identifier.String(TopicName));
 
         response.ShouldNotBeNull();
         response.Count.ShouldBe(1);
 
         var group = response.FirstOrDefault();
         group.ShouldNotBeNull();
-        group.Id.ShouldBe(GroupId);
         group.Name.ShouldBe(GroupName);
-        group.PartitionsCount.ShouldBe(Fixture.PartitionsCount);
+        group.PartitionsCount.ShouldBe(PartitionsCount);
         group.MembersCount.ShouldBe(0u);
     }
 
     [Test]
     [SkipHttp]
-    [DependsOn(nameof(GetConsumerGroups_Should_Return_ValidResponse))]
     
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
     public async Task 
JoinConsumerGroup_Tcp_Should_JoinConsumerGroup_Successfully(Protocol protocol)
     {
+        var (client, streamName) = await CreateStreamAndTopic(protocol);
+        var cg = await 
client.CreateConsumerGroupAsync(Identifier.String(streamName),
+            Identifier.String(TopicName), GroupName);
+
         await Should.NotThrowAsync(() =>
-            Fixture.Clients[protocol]
-                
.JoinConsumerGroupAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
 TopicId,
-                    Identifier.Numeric(GroupId)));
+            client.JoinConsumerGroupAsync(Identifier.String(streamName),
+                Identifier.String(TopicName), Identifier.Numeric(cg!.Id)));
     }
 
     [Test]
     [SkipTcp]
-    [DependsOn(nameof(GetConsumerGroups_Should_Return_ValidResponse))]
     
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
     public async Task 
JoinConsumerGroup_Http_Should_Throw_FeatureUnavailable(Protocol protocol)
     {
+        var (client, streamName) = await CreateStreamAndTopic(protocol);
+        var cg = await 
client.CreateConsumerGroupAsync(Identifier.String(streamName),
+            Identifier.String(TopicName), GroupName);
+
         await Should.ThrowAsync<FeatureUnavailableException>(() =>

Review Comment:
   Done. `JoinConsumerGroup_Tcp` now calls `GetMeAsync`() after joining and 
verifies `ConsumerGroupsCount` == 1 and the group ID is in the list



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to