Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions foreign/csharp/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

for (var i = 0; i < producerCount; i++)
{
var bus = IggyClientFactory.CreateClient(new IggyClientConfigurator()
var bus = IggyClientFactory.CreateClient(new IggyClientConfigurator
{
BaseAddress = "127.0.0.1:8090",
Protocol = Protocol.Tcp,
Expand Down Expand Up @@ -67,9 +67,9 @@
await clients[0].CreateStreamAsync($"Test bench stream_{i}");

await clients[0].CreateTopicAsync(Identifier.Numeric(startingStreamId + i),
name: $"Test bench topic_{i}",
$"Test bench topic_{i}",
compressionAlgorithm: CompressionAlgorithm.None,
messageExpiry: 0,
messageExpiry: TimeSpan.Zero,
maxTopicSize: 2_000_000_000,
replicationFactor: 3,
partitionsCount: 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// // under the License.

using System.Text;
using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Enums;
using Apache.Iggy.Headers;
using Apache.Iggy.IggyClient;
using Apache.Iggy.Messages;
using Apache.Iggy.Tests.Integrations.Helpers;
using Apache.Iggy.Tests.Integrations.Models;
using TUnit.Core.Interfaces;
using Partitioning = Apache.Iggy.Kinds.Partitioning;

Expand All @@ -31,8 +31,8 @@ public class FetchMessagesFixture : IAsyncInitializer
{
internal readonly int MessageCount = 20;
internal readonly string StreamId = "FetchMessagesStream";
internal readonly CreateTopicRequest TopicHeadersRequest = TopicFactory.CreateTopic("HeadersTopic");
internal readonly CreateTopicRequest TopicRequest = TopicFactory.CreateTopic("Topic");
internal readonly CreateTestTopic TopicHeadersRequest = TopicFactory.CreateTopic("HeadersTopic");
internal readonly CreateTestTopic TopicRequest = TopicFactory.CreateTopic("Topic");

[ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
public required IggyServerFixture IggyServerFixture { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
// // specific language governing permissions and limitations
// // under the License.

using Apache.Iggy.Contracts;
using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Enums;
using Apache.Iggy.IggyClient;
using Apache.Iggy.Messages;
using Apache.Iggy.Tests.Integrations.Helpers;
using Apache.Iggy.Tests.Integrations.Models;
using TUnit.Core.Interfaces;
using Partitioning = Apache.Iggy.Kinds.Partitioning;

Expand All @@ -29,7 +28,7 @@ namespace Apache.Iggy.Tests.Integrations.Fixtures;
public class FlushMessageFixture : IAsyncInitializer
{
internal readonly string StreamId = "FlushMessageStream";
internal readonly CreateTopicRequest TopicRequest = TopicFactory.CreateTopic("Topic");
internal readonly CreateTestTopic TopicRequest = TopicFactory.CreateTopic("Topic");

[ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
public required IggyServerFixture IggyServerFixture { get; init; }
Expand All @@ -53,7 +52,6 @@ await client.Value.CreateTopicAsync(Identifier.String(StreamId.GetWithProtocol(c
};
await client.Value.SendMessagesAsync(Identifier.String(StreamId.GetWithProtocol(client.Key)),
Identifier.String(TopicRequest.Name), Partitioning.None(), messages);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class IggyServerFixture : IAsyncInitializer, IAsyncDisposable
{ "IGGY_ROOT_USERNAME", "iggy" },
{ "IGGY_ROOT_PASSWORD", "iggy" },
{ "IGGY_TCP_ADDRESS", "0.0.0.0:8090" },
{ "IGGY_HTTP_ADDRESS", "0.0.0.0:3000" }
{ "IGGY_HTTP_ADDRESS", "0.0.0.0:3000" },
{ "IGGY_SYSTEM_TOPIC_MESSAGE_EXPIRY", "10m" }
};

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
// // specific language governing permissions and limitations
// // under the License.

using Apache.Iggy.Contracts;
using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Enums;
using Apache.Iggy.IggyClient;
using Apache.Iggy.Messages;
using Apache.Iggy.Tests.Integrations.Helpers;
using Apache.Iggy.Tests.Integrations.Models;
using TUnit.Core.Interfaces;
using Partitioning = Apache.Iggy.Kinds.Partitioning;

Expand All @@ -29,7 +28,7 @@ namespace Apache.Iggy.Tests.Integrations.Fixtures;
public class OffsetFixtures : IAsyncInitializer
{
internal readonly string StreamId = "OffsetStream";
internal readonly CreateTopicRequest TopicRequest = TopicFactory.CreateTopic("Topic");
internal readonly CreateTestTopic TopicRequest = TopicFactory.CreateTopic("Topic");

[ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
public required IggyServerFixture IggyServerFixture { get; init; }
Expand All @@ -49,8 +48,7 @@ await client.Value.CreateTopicAsync(Identifier.String(StreamId.GetWithProtocol(c
{
new(Guid.NewGuid(), "Test message 1"u8.ToArray()),
new(Guid.NewGuid(), "Test message 2"u8.ToArray()),
new(Guid.NewGuid(), "Test message 3"u8.ToArray()),
new(Guid.NewGuid(), "Test message 4"u8.ToArray())
new(Guid.NewGuid(), "Test message 3"u8.ToArray()), new(Guid.NewGuid(), "Test message 4"u8.ToArray())
};
await client.Value.SendMessagesAsync(Identifier.String(StreamId.GetWithProtocol(client.Key)),
Identifier.String(TopicRequest.Name), Partitioning.None(), messages);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
// // specific language governing permissions and limitations
// // under the License.

using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Enums;
using Apache.Iggy.IggyClient;
using Apache.Iggy.Tests.Integrations.Helpers;
using Apache.Iggy.Tests.Integrations.Models;
using TUnit.Core.Interfaces;

namespace Apache.Iggy.Tests.Integrations.Fixtures;

public class PartitionsFixture : IAsyncInitializer
{
internal readonly string StreamId = "PartitionsStream";
internal readonly CreateTopicRequest TopicRequest = TopicFactory.CreateTopic("Topic");
internal readonly CreateTestTopic TopicRequest = TopicFactory.CreateTopic("Topic");

[ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
public required IggyServerFixture IggyServerFixture { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
// // specific language governing permissions and limitations
// // under the License.

using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Enums;
using Apache.Iggy.IggyClient;
using Apache.Iggy.Tests.Integrations.Helpers;
using Apache.Iggy.Tests.Integrations.Models;
using TUnit.Core.Interfaces;

namespace Apache.Iggy.Tests.Integrations.Fixtures;

public class SendMessageFixture : IAsyncInitializer
{
internal readonly string StreamId = "SendMessageStream";
internal readonly CreateTopicRequest TopicRequest = TopicFactory.CreateTopic("Topic");
internal readonly CreateTestTopic TopicRequest = TopicFactory.CreateTopic("Topic");

[ClassDataSource<IggyServerFixture>(Shared = SharedType.PerAssembly)]
public required IggyServerFixture IggyServerFixture { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
// // specific language governing permissions and limitations
// // under the License.

using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Tests.Integrations.Models;

namespace Apache.Iggy.Tests.Integrations.Helpers;

public static class TopicFactory
{
internal static CreateTopicRequest CreateTopic(string topicId, uint partitionsCount = 1, ulong messageExpiry = 0)
internal static CreateTestTopic CreateTopic(string topicId, uint partitionsCount = 1,
TimeSpan messageExpiry = default)
{
return new CreateTopicRequest
return new CreateTestTopic
{
Name = topicId,
PartitionsCount = partitionsCount,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

using System.Diagnostics.CodeAnalysis;
using Apache.Iggy.Enums;

namespace Apache.Iggy.Tests.Integrations.Models;

internal class CreateTestTopic
{
public required string Name { get; set; }
public CompressionAlgorithm CompressionAlgorithm { get; set; } = CompressionAlgorithm.None;
public TimeSpan MessageExpiry { get; set; } = TimeSpan.Zero;
public uint PartitionsCount { get; set; } = 1;
public byte? ReplicationFactor { get; set; } = 1;
public ulong MaxTopicSize { get; set; }

public CreateTestTopic()
{
}

[SetsRequiredMembers]
public CreateTestTopic(string name,
CompressionAlgorithm compressionAlgorithm,
TimeSpan messageExpiry,
uint partitionsCount,
byte? replicationFactor,
ulong maxTopicSize)
{
Name = name;
CompressionAlgorithm = compressionAlgorithm;
MessageExpiry = messageExpiry;
PartitionsCount = partitionsCount;
ReplicationFactor = replicationFactor;
MaxTopicSize = maxTopicSize;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

using Apache.Iggy.Enums;

namespace Apache.Iggy.Tests.Integrations.Models;

internal record UpdateTestTopic(
string Name,
CompressionAlgorithm CompressionAlgorithm,
ulong MaxTopicSize,
TimeSpan MessageExpiry,
byte? ReplicationFactor);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using Apache.Iggy.Contracts.Auth;
using Apache.Iggy.Enums;
using Apache.Iggy.Exceptions;
using Apache.Iggy.Tests.Integrations.Attributes;
using Apache.Iggy.Tests.Integrations.Fixtures;
using Shouldly;

Expand All @@ -27,7 +26,7 @@ namespace Apache.Iggy.Tests.Integrations;
public class PersonalAccessTokenTests
{
private const string Name = "test-pat";
private const ulong Expiry = 100_000_000;
private static readonly TimeSpan Expiry = TimeSpan.FromHours(1);

[ClassDataSource<PersonalAccessTokenFixture>(Shared = SharedType.PerClass)]
public required PersonalAccessTokenFixture Fixture { get; init; }
Expand Down Expand Up @@ -64,7 +63,7 @@ IReadOnlyList<PersonalAccessTokenResponse> response
response.ShouldNotBeNull();
response.Count.ShouldBe(1);
response[0].Name.ShouldBe(Name);
var tokenExpiryDateTimeOffset = DateTimeOffset.UtcNow.AddMicroseconds(Expiry);
var tokenExpiryDateTimeOffset = DateTimeOffset.UtcNow.Add(Expiry);
response[0].ExpiryAt!.Value.ToUniversalTime().ShouldBe(tokenExpiryDateTimeOffset, TimeSpan.FromMinutes(1));
}

Expand All @@ -73,7 +72,7 @@ IReadOnlyList<PersonalAccessTokenResponse> response
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
public async Task LoginWithPersonalAccessToken_Should_Be_Successfully(Protocol protocol)
{
var response = await Fixture.Clients[protocol].CreatePersonalAccessTokenAsync("test-pat-login", 100_000_000);
var response = await Fixture.Clients[protocol].CreatePersonalAccessTokenAsync("test-pat-login", Expiry);

var client = await Fixture.IggyServerFixture.CreateClient(protocol);

Expand Down
9 changes: 4 additions & 5 deletions foreign/csharp/Iggy_SDK.Tests.Integration/StreamsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
using Apache.Iggy.Enums;
using Apache.Iggy.Exceptions;
using Apache.Iggy.Messages;
using Apache.Iggy.Tests.Integrations.Attributes;
using Apache.Iggy.Tests.Integrations.Fixtures;
using Apache.Iggy.Tests.Integrations.Helpers;
using Shouldly;
using TUnit.Core.Logging;
using Partitioning = Apache.Iggy.Kinds.Partitioning;

namespace Apache.Iggy.Tests.Integrations;
Expand Down Expand Up @@ -121,8 +119,8 @@ public async Task GetStreams_ByStreamName_Should_ReturnValidResponse(Protocol pr
[MethodDataSource<IggyServerFixture>(nameof(IggyServerFixture.ProtocolData))]
public async Task GetStreamById_WithTopics_Should_ReturnValidResponse(Protocol protocol)
{
var topicRequest1 = TopicFactory.CreateTopic("Topic1", messageExpiry: 100_000);
var topicRequest2 = TopicFactory.CreateTopic("Topic2", messageExpiry: 100_000);
var topicRequest1 = TopicFactory.CreateTopic("Topic1", messageExpiry: TimeSpan.FromHours(1));
var topicRequest2 = TopicFactory.CreateTopic("Topic2", messageExpiry: TimeSpan.FromHours(1));

await Fixture.Clients[protocol].CreateTopicAsync(Identifier.String(Name.GetWithProtocol(protocol)),
topicRequest1.Name, topicRequest1.PartitionsCount, messageExpiry: topicRequest1.MessageExpiry);
Expand Down Expand Up @@ -230,7 +228,8 @@ await Should.NotThrowAsync(() =>
public async Task DeleteStream_NotExists_Should_Throw_InvalidResponse(Protocol protocol)
{
await Should.ThrowAsync<IggyInvalidStatusCodeException>(() =>
Fixture.Clients[protocol].DeleteStreamAsync(Identifier.String("stream-to-delete".GetWithProtocol(protocol))));
Fixture.Clients[protocol]
.DeleteStreamAsync(Identifier.String("stream-to-delete".GetWithProtocol(protocol))));
}

[Test]
Expand Down
24 changes: 13 additions & 11 deletions foreign/csharp/Iggy_SDK.Tests.Integration/TopicsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@

using System.Text;
using Apache.Iggy.Contracts;
using Apache.Iggy.Contracts.Http;
using Apache.Iggy.Enums;
using Apache.Iggy.Exceptions;
using Apache.Iggy.Messages;
using Apache.Iggy.Tests.Integrations.Attributes;
using Apache.Iggy.Tests.Integrations.Fixtures;
using Apache.Iggy.Tests.Integrations.Helpers;
using Apache.Iggy.Tests.Integrations.Models;
using Shouldly;
using Partitioning = Apache.Iggy.Kinds.Partitioning;

namespace Apache.Iggy.Tests.Integrations;

public class TopicsTests
{
private static readonly CreateTopicRequest TopicRequest = new("Test Topic", CompressionAlgorithm.Gzip, 1000, 1,
2, 2_000_000_000);
private static readonly CreateTestTopic TopicRequest = new("Test Topic", CompressionAlgorithm.Gzip,
TimeSpan.FromMinutes(10), 1, 2, 2_000_000_000);

private static readonly CreateTopicRequest TopicRequestSecond
= new("Test Topic 2", CompressionAlgorithm.Gzip, 1000, 1, 2, 2_000_000_000);
private static readonly CreateTestTopic TopicRequestSecond
= new("Test Topic 2", CompressionAlgorithm.Gzip, TimeSpan.FromMinutes(10), 1, 2, 2_000_000_000);

private static readonly UpdateTopicRequest UpdateTopicRequest
= new("Updated Topic", CompressionAlgorithm.Gzip, 3_000_000_000, 2000, 3);
private static readonly UpdateTestTopic UpdateTopicRequest
= new("Updated Topic", CompressionAlgorithm.Gzip, 3_000_000_000, TimeSpan.FromMinutes(10), 3);

[ClassDataSource<TopicsFixture>(Shared = SharedType.PerClass)]
public required TopicsFixture Fixture { get; init; }
Expand Down Expand Up @@ -173,18 +172,21 @@ await Fixture.Clients[protocol].CreateTopicAsync(Identifier.String(Fixture.Strea
public async Task Get_Topic_WithPartitions_Should_ReturnValidResponse(Protocol protocol)
{
await Fixture.Clients[protocol]
.CreatePartitionsAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)), Identifier.String(TopicRequest.Name),
.CreatePartitionsAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
Identifier.String(TopicRequest.Name),
2);

for (var i = 0; i < 3; i++)
{
await Fixture.Clients[protocol]
.SendMessagesAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)), Identifier.String(TopicRequest.Name),
.SendMessagesAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
Identifier.String(TopicRequest.Name),
Partitioning.None(), GetMessages(i + 2));
}

var response = await Fixture.Clients[protocol]
.GetTopicByIdAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)), Identifier.String(TopicRequest.Name));
.GetTopicByIdAsync(Identifier.String(Fixture.StreamId.GetWithProtocol(protocol)),
Identifier.String(TopicRequest.Name));

response.ShouldNotBeNull();
response.Id.ShouldBeGreaterThanOrEqualTo(0u);
Expand Down
Loading