Skip to content
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

Add gateway version to topology #118

Merged
merged 3 commits into from
Apr 20, 2020
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
5 changes: 4 additions & 1 deletion Client.IntegrationTests/BrokerTopologyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Client.IntegrationTests
[TestFixture]
public class BrokerTopologyTest
{
private readonly ZeebeIntegrationTestHelper testHelper = new ZeebeIntegrationTestHelper();
private readonly ZeebeIntegrationTestHelper testHelper = ZeebeIntegrationTestHelper.latest();
private IZeebeClient zeebeClient;

[OneTimeSetUp]
Expand All @@ -37,6 +37,9 @@ public async Task RequestTopology()
// then
Console.WriteLine(topology);

var gatewayVersion = topology.GatewayVersion;
Assert.AreEqual("0.23.0", gatewayVersion);

var topologyBrokers = topology.Brokers;
Assert.AreEqual(1, topologyBrokers.Count);

Expand Down
2 changes: 1 addition & 1 deletion Client.IntegrationTests/JobWorkerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JobWorkerTest
private static readonly string DemoProcessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "oneTaskProcess.bpmn");
private static readonly string WorkflowInstanceVariables = "{\"a\":123, \"b\":true}";

private readonly ZeebeIntegrationTestHelper testHelper = new ZeebeIntegrationTestHelper();
private readonly ZeebeIntegrationTestHelper testHelper = ZeebeIntegrationTestHelper.latest();
private IZeebeClient zeebeClient;
private long workflowKey;

Expand Down
62 changes: 62 additions & 0 deletions Client.IntegrationTests/OldVersionBrokerTopologyTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Threading.Tasks;
using NUnit.Framework;
using TestContainers.Core.Builders;
using TestContainers.Core.Containers;
using Zeebe.Client;
using Zeebe.Client.Api.Responses;

namespace Client.IntegrationTests
{
[TestFixture]
public class OldVersionBrokerTopologyTest
{
private const string Version = "0.22.2";
private readonly ZeebeIntegrationTestHelper testHelper = ZeebeIntegrationTestHelper.ofVersion(Version);
private IZeebeClient zeebeClient;

[OneTimeSetUp]
public async Task Setup()
{
zeebeClient = await testHelper.SetupIntegrationTest();
}

[OneTimeTearDown]
public async Task Stop()
{
await testHelper.TearDownIntegrationTest();
}

[Test]
public async Task RequestTopology()
{
// given

// when
var topology = await zeebeClient.TopologyRequest().Send();

// then
Console.WriteLine(topology);

var gatewayVersion = topology.GatewayVersion;
Assert.AreEqual("lower then 0.23", gatewayVersion);

var topologyBrokers = topology.Brokers;
Assert.AreEqual(1, topologyBrokers.Count);

var topologyBroker = topologyBrokers[0];
Assert.AreEqual(0, topologyBroker.NodeId);

// assert host and port ?!
// Assert.AreEqual(container.GetMappedPort(26500), topologyBroker.Port);

var partitions = topologyBroker.Partitions;
Assert.AreEqual(1, partitions.Count);

var partitionInfo = partitions[0];
Assert.AreEqual(PartitionBrokerRole.LEADER, partitionInfo.Role);
Assert.AreEqual(true, partitionInfo.IsLeader);
Assert.AreEqual(1, partitionInfo.PartitionId);
}
}
}
2 changes: 1 addition & 1 deletion Client.IntegrationTests/WorkflowInstanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WorkflowInstanceTest
private static readonly string SimpleProcessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "simpleProcess.bpmn");
private static readonly string WorkflowInstanceVariables = "{\"a\":123, \"b\":true}";

private readonly ZeebeIntegrationTestHelper testHelper = new ZeebeIntegrationTestHelper();
private readonly ZeebeIntegrationTestHelper testHelper = ZeebeIntegrationTestHelper.latest();
private IZeebeClient zeebeClient;

[OneTimeSetUp]
Expand Down
2 changes: 1 addition & 1 deletion Client.IntegrationTests/WorkflowTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WorkflowTest
{
private static readonly string DemoProcessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "simpleProcess.bpmn");

private readonly ZeebeIntegrationTestHelper testHelper = new ZeebeIntegrationTestHelper();
private readonly ZeebeIntegrationTestHelper testHelper = ZeebeIntegrationTestHelper.latest();
private IZeebeClient zeebeClient;

[OneTimeSetUp]
Expand Down
21 changes: 20 additions & 1 deletion Client.IntegrationTests/ZeebeIntegrationTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,28 @@ namespace Client.IntegrationTests
{
public class ZeebeIntegrationTestHelper
{
private const string LatestVersion = "0.23.0";

private Container container;
private IZeebeClient client;

private readonly string version;

private ZeebeIntegrationTestHelper(string version)
{
this.version = version;
}

public static ZeebeIntegrationTestHelper latest()
{
return new ZeebeIntegrationTestHelper(LatestVersion);
}

public static ZeebeIntegrationTestHelper ofVersion(string version)
{
return new ZeebeIntegrationTestHelper(version);
}

public async Task<IZeebeClient> SetupIntegrationTest()
{
container = CreateZeebeContainer();
Expand All @@ -36,7 +55,7 @@ private Container CreateZeebeContainer()
{
return new GenericContainerBuilder<Container>()
.Begin()
.WithImage("camunda/zeebe:0.23.0")
.WithImage("camunda/zeebe:" + version)
.WithExposedPorts(26500)
.Build();
}
Expand Down
9 changes: 8 additions & 1 deletion Client/Api/Responses/ITopology.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ namespace Zeebe.Client.Api.Responses
{
public interface ITopology
{
/// <returns>all (known) brokers of the cluster </returns>
/// <returns>
/// All (known) brokers of the cluster
/// </returns>
IList<IBrokerInfo> Brokers { get; }

/// <returns>
/// The gateway version or 'lower then 0.23' if none was found.
/// </returns>
string GatewayVersion { get; }
}
}
9 changes: 8 additions & 1 deletion Client/Impl/Responses/Topology.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Linq;
using GatewayProtocol;
Expand All @@ -22,16 +23,22 @@ namespace Zeebe.Client.Impl.Responses
{
public class Topology : ITopology
{
private const string FallbackVersion = "lower then 0.23";

public IList<IBrokerInfo> Brokers { get; }
public string GatewayVersion { get; }

public Topology(TopologyResponse response)
{
Brokers = response.Brokers.Select(broker => new BrokerInfo(broker)).Cast<IBrokerInfo>().ToList();
GatewayVersion = string.IsNullOrEmpty(response.GatewayVersion) ? FallbackVersion : response.GatewayVersion;
}

public override string ToString()
{
return "Brokers:\n" + string.Join(",\n", Brokers);
return
"GatewayVersion: " + GatewayVersion + "\n"
+ "Brokers:\n" + string.Join(",\n", Brokers);
}
}
}
Loading