Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #67 from finos-plexus/db-contrib/develop
Browse files Browse the repository at this point in the history
Db contrib/develop
  • Loading branch information
nikoant authored Sep 18, 2018
2 parents 6e8e920 + 3dd1d16 commit ceec72d
Show file tree
Hide file tree
Showing 42 changed files with 382 additions and 244 deletions.
21 changes: 21 additions & 0 deletions desktop/coverage-broker.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
REM work around for https://github.com/dotnet/cli/issues/3995
set tmp=
set temp=
CD %~dp0
if defined APPVEYOR (
SET LOGGER=Appveyor
) else (
SET LOGGER=xunit
)

if not defined NUGET_PACKAGES (
SET NUGET_PACKAGES=%USERPROFILE%\.nuget\packages
)

if not exist ..\bin\test-reports mkdir ..\bin\test-reports

CALL dotnet restore src\Plexus.Interop.sln && dotnet build src\Plexus.Interop.sln -c debug /p:DebugType=Full && SET PLEXUS_TIMEOUT_MULTIPLIER=10 ^
&& %NUGET_PACKAGES%\OpenCover\4.6.519\tools\OpenCover.Console.exe -oldStyle -returntargetcode -register:user -output:..\bin\test-reports\dotnet-coverage.xml ^
-filter:"+[Plexus.*]* -[*.Tests]* -[*.IntegrationTests]* -[*.Testing]* -[Plexus.Interop.Samples.*]* -[Plexus.*]*.Generated.* -[Plexus.Interop.Client*]* -[*.Client]*" -excludebyfile:*.proto.cs;*.g.cs -skipautoprops ^
-targetdir:src -target:dotnet.exe -searchdirs:..\bin\win-x86\broker -targetargs:"test Plexus.Interop.Tests.sln /p:DebugType=Full --test-adapter-path:. --logger:%LOGGER% --verbosity quiet" ^
&& %NUGET_PACKAGES%\ReportGenerator\3.1.2\tools\ReportGenerator.exe -reports:..\bin\test-reports\dotnet-coverage.xml -targetdir:..\bin\test-reports\dotnet-coverage -sourcedirs:src reporttypes:Html
21 changes: 21 additions & 0 deletions desktop/coverage-client.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
REM work around for https://github.com/dotnet/cli/issues/3995
set tmp=
set temp=
CD %~dp0
if defined APPVEYOR (
SET LOGGER=Appveyor
) else (
SET LOGGER=xunit
)

if not defined NUGET_PACKAGES (
SET NUGET_PACKAGES=%USERPROFILE%\.nuget\packages
)

if not exist ..\bin\test-reports mkdir ..\bin\test-reports

CALL dotnet restore src\Plexus.Interop.sln && dotnet build src\Plexus.Interop.sln -c debug /p:DebugType=Full && SET PLEXUS_TIMEOUT_MULTIPLIER=10 ^
&& %NUGET_PACKAGES%\OpenCover\4.6.519\tools\OpenCover.Console.exe -oldStyle -returntargetcode -register:user -output:..\bin\test-reports\dotnet-coverage.xml ^
-filter:"+[Plexus.*]* -[*.Tests]* -[*.IntegrationTests]* -[*.Testing]* -[Plexus.Interop.Samples.*]* -[Plexus.*]*.Generated.* -[Plexus.Interop.Broker*]* -[Plexus.Interop.Apps.Manager*]* -[Plexus.Interop.Metamodel*]* -[*.Server]*" -excludebyfile:*.proto.cs;*.g.cs -skipautoprops ^
-targetdir:src -target:dotnet.exe -searchdirs:..\bin\win-x86\broker -targetargs:"test Plexus.Interop.Tests.sln /p:DebugType=Full --test-adapter-path:. --logger:%LOGGER% --verbosity quiet" ^
&& %NUGET_PACKAGES%\ReportGenerator\3.1.2\tools\ReportGenerator.exe -reports:..\bin\test-reports\dotnet-coverage.xml -targetdir:..\bin\test-reports\dotnet-coverage -sourcedirs:src reporttypes:Html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
{
public enum ResolveMode
{
SingleInstance,
MultiInstance,
SingleLaunchingInstance
SingleInstance,
MultiInstance
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@ private static ResolveMode Convert(Generated.AppLaunchMode launchMode)
{
case Generated.AppLaunchMode.SingleInstance:
return ResolveMode.SingleInstance;
case Generated.AppLaunchMode.SingleLaunchingInstance:
return ResolveMode.SingleLaunchingInstance;
case Generated.AppLaunchMode.MultiInstance:
return ResolveMode.MultiInstance;
default:
Expand All @@ -419,8 +417,6 @@ private static Generated.AppLaunchMode Convert(ResolveMode resolveMode)
{
case ResolveMode.SingleInstance:
return Generated.AppLaunchMode.SingleInstance;
case ResolveMode.SingleLaunchingInstance:
return Generated.AppLaunchMode.SingleLaunchingInstance;
case ResolveMode.MultiInstance:
return Generated.AppLaunchMode.MultiInstance;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ static AppLaunchModeReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Ch1pbnRlcm9wL2FwcF9sYXVuY2hfbW9kZS5wcm90bxIHaW50ZXJvcBoVaW50",
"ZXJvcC9vcHRpb25zLnByb3RvKlcKDUFwcExhdW5jaE1vZGUSEwoPU0lOR0xF",
"X0lOU1RBTkNFEAASEgoOTVVMVElfSU5TVEFOQ0UQARIdChlTSU5HTEVfTEFV",
"TkNISU5HX0lOU1RBTkNFEAJCKaoCJlBsZXh1cy5JbnRlcm9wLkFwcHMuSW50",
"ZXJuYWwuR2VuZXJhdGVkYgZwcm90bzM="));
"ZXJvcC9vcHRpb25zLnByb3RvKjgKDUFwcExhdW5jaE1vZGUSEwoPU0lOR0xF",
"X0lOU1RBTkNFEAASEgoOTVVMVElfSU5TVEFOQ0UQAUIpqgImUGxleHVzLklu",
"dGVyb3AuQXBwcy5JbnRlcm5hbC5HZW5lcmF0ZWRiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Plexus.Interop.Apps.Internal.Generated.OptionsReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Plexus.Interop.Apps.Internal.Generated.AppLaunchMode), }, null));
Expand All @@ -56,7 +55,6 @@ static AppLaunchModeReflection() {
internal enum AppLaunchMode {
[pbr::OriginalName("SINGLE_INSTANCE")] SingleInstance = 0,
[pbr::OriginalName("MULTI_INSTANCE")] MultiInstance = 1,
[pbr::OriginalName("SINGLE_LAUNCHING_INSTANCE")] SingleLaunchingInstance = 2,
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public async Task HandleAsync(
new Maybe<UniqueId>(x.ConnectionId)),
x => x.Match.Provided);
}

var discoveredServices =
from s in groupedMethods
let consumedService = s.Key.ConsumedService
Expand All @@ -96,17 +97,19 @@ select _protocol.MessageFactory.CreateDiscoveredService(
consumedService.Alias),
_protocol.MessageFactory.CreateProvidedServiceReference(
providedService.Service.Id,
providedService.Alias,
providedService.Application.Id,
providedService.Alias,
providedService.Application.Id,
connectionId),
s.Key.ProvidedService.Title,
s.Select(m =>
_protocol.MessageFactory.CreateDiscoveredServiceMethod(
m.Method.Name,
m.Title,
m.Method.InputMessage.Id,
m.Method.OutputMessage.Id,
Convert(m.Method.Type))).ToList());
_protocol.MessageFactory.CreateDiscoveredServiceMethod(
m.Method.Name,
m.Title,
m.Method.InputMessage.Id,
m.Method.OutputMessage.Id,
Convert(m.Method.Type),
m.Options.Select(o => _protocol.MessageFactory.CreateOption(o.Id, o.Value)).ToList()))
.ToList());
using (var response = _protocol.MessageFactory.CreateServiceDiscoveryResponse(discoveredServices.ToList()))
{
Log.Info("Completed service discovery request {{{0}}} from {{{1}}}: {2}", request, sourceConnection, response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace Plexus.Interop.Broker.Internal
using Plexus.Interop.Protocol.Invocation;
using Plexus.Interop.Transport;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -211,7 +210,7 @@ private async ValueTask<IAppConnection> ResolveTargetConnectionAsync(
if (candidate == null)
{
candidate = singleInstanceMethods.FirstOrDefault();
resolveMode = ResolveMode.SingleLaunchingInstance;
resolveMode = ResolveMode.SingleInstance;
}
if (candidate == null)
{
Expand Down
3 changes: 1 addition & 2 deletions desktop/src/Plexus.Interop.Broker.Core/Internal/interop.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@
"AppLaunchMode": {
"values": {
"SINGLE_INSTANCE": 0,
"MULTI_INSTANCE": 1,
"SINGLE_LAUNCHING_INSTANCE": 2
"MULTI_INSTANCE": 1
}
},
"AppConnectionDescriptor": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ IDiscoveredServiceMethod CreateDiscoveredServiceMethod(
Maybe<string> methodTitle,
string inputMessageId,
string outputMessageId,
MethodType methodType);
MethodType methodType,
IReadOnlyCollection<IOption> options);

IMethodDiscoveryRequest CreateMethodDiscoveryRequest(
Maybe<string> inputMessageId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ private DiscoveredServiceMethod ConvertToProto(IDiscoveredServiceMethod method)
proto.OutputMessageId = method.OutputMessageId.ConvertToProtoStrict();
proto.MethodId = method.MethodId.ConvertToProtoStrict();
proto.MethodTitle = method.MethodTitle.ConvertToProto();
proto.Options.AddRange(method.Options.Select(ConvertToProto));
return proto;
}

Expand Down Expand Up @@ -520,7 +521,8 @@ private IDiscoveredServiceMethod ConvertFromProtoStrict(DiscoveredServiceMethod
proto.MethodTitle.ConvertFromProto(),
proto.InputMessageId.ConvertFromProtoStrict(),
proto.OutputMessageId.ConvertFromProtoStrict(),
ConvertFromProto(proto.MethodType));
ConvertFromProto(proto.MethodType),
proto.Options.Select(ConvertFromProtoStrict).ToList());
}

private DiscoveryMethodType ConvertFromProto(MethodType proto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

internal sealed class ServiceDiscoveryResponse : PooledObject<ServiceDiscoveryResponse>, IServiceDiscoveryResponse
{
public IReadOnlyCollection<IDiscoveredService> Services { get; set; }
public IReadOnlyCollection<IDiscoveredService> Services { get; set; } =
ArrayConstants<IDiscoveredService>.Empty;

protected override void Cleanup()
{
Expand Down
4 changes: 3 additions & 1 deletion desktop/src/Plexus.Interop.Protocol/ProtocolMessagePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,16 @@ public IDiscoveredServiceMethod CreateDiscoveredServiceMethod(
Maybe<string> methodTitle,
string inputMessageId,
string outputMessageId,
MethodType methodType)
MethodType methodType,
IReadOnlyCollection<IOption> options)
{
var obj = DiscoveredServiceMethod.Rent();
obj.MethodId = methodId;
obj.MethodTitle = methodTitle;
obj.InputMessageId = inputMessageId;
obj.OutputMessageId = outputMessageId;
obj.MethodType = methodType;
obj.Options = options;
return obj;
}

Expand Down
45 changes: 21 additions & 24 deletions desktop/src/Plexus.Interop.Tests/ClientBrokerIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,6 @@ public void DiscoveryByMethod()
discoveryResult.InputMessageId.ShouldBe("plexus.interop.testing.EchoRequest");
discoveryResult.OutputMessageId.ShouldBe("plexus.interop.testing.EchoRequest");
discoveryResult.Type.ShouldBe(MethodType.Unary);
foreach (var option in discoveryResult.Options)
{
WriteLog($"{option.Id}: {option.Value}");
}
discoveryResult.Options.Count.ShouldBe(3);
discoveryResult.Options.ShouldContain(o => o.Id.Equals("interop.ProvidedMethodOptions.title") && o.Value.Equals("Sample Unary Method"));
discoveryResult.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.string_option") && o.Value.Equals("some string"));
Expand Down Expand Up @@ -513,6 +509,13 @@ await client.DiscoveryInvoker.DiscoverAsync(
serverStreamingMethod.ShouldNotBeNull();
serverStreamingMethod.Title.ShouldBe("Sample Duplex Streaming Method");
serverStreamingMethod.ProvidedMethod.ProvidedService.ConnectionId.HasValue.ShouldBeFalse();
serverStreamingMethod.Options.Count.ShouldBe(1);
var unaryMethod =
discoveryResult.Methods.FirstOrDefault(x => string.Equals(x.ProvidedMethod.Name, "Unary"));
unaryMethod.ShouldNotBeNull();
unaryMethod.Options.ShouldContain(o => o.Id.Equals("interop.ProvidedMethodOptions.title") && o.Value.Equals("Sample Unary Method"));
unaryMethod.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.string_option") && o.Value.Equals("some string"));
unaryMethod.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.enum_option") && o.Value.Equals("VALUE_TWO"));
}
});
}
Expand Down Expand Up @@ -541,6 +544,10 @@ public void OnlineDiscoveryByMethod()
discoveryResult.OutputMessageId.ShouldBe("plexus.interop.testing.EchoRequest");
discoveryResult.Type.ShouldBe(MethodType.Unary);
discoveryResult.ProviderConnectionId.ShouldBeOneOf(server1.ConnectionId, server2.ConnectionId);
discoveryResult.Options.Count.ShouldBe(3);
discoveryResult.Options.ShouldContain(o => o.Id.Equals("interop.ProvidedMethodOptions.title") && o.Value.Equals("Sample Unary Method"));
discoveryResult.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.string_option") && o.Value.Equals("some string"));
discoveryResult.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.enum_option") && o.Value.Equals("VALUE_TWO"));
}
});
}
Expand Down Expand Up @@ -569,6 +576,12 @@ await client.DiscoveryInvoker.DiscoverOnlineAsync(
serverStreamingMethod.ProviderConnectionId.ShouldBeOneOf(server1.ConnectionId,
server2.ConnectionId);
serverStreamingMethod.Title.ShouldBe("Sample Server Streaming Method");
var unaryMethod =
discoveryResult.Methods.FirstOrDefault(x => string.Equals(x.ProvidedMethod.Name, "Unary"));
unaryMethod.ShouldNotBeNull();
unaryMethod.Options.ShouldContain(o => o.Id.Equals("interop.ProvidedMethodOptions.title") && o.Value.Equals("Sample Unary Method"));
unaryMethod.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.string_option") && o.Value.Equals("some string"));
unaryMethod.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.enum_option") && o.Value.Equals("VALUE_TWO"));
}
});
}
Expand Down Expand Up @@ -678,27 +691,11 @@ Task<EchoRequest> HandleAsync(EchoRequest request, MethodCallContext context)

RunWith10SecTimeout(async () =>
{
var echoServerFactory = new TestClientFactory(
(broker, id) =>
{
var optionsBuilder = new ClientOptionsBuilder()
.WithBrokerWorkingDir(_testBrokerFixture.SharedInstance.WorkingDir)
.WithDefaultConfiguration()
.WithProvidedService(
EchoService.Id,
x => x.WithUnaryMethod<EchoRequest, EchoRequest>("Unary", HandleAsync))
.WithApplicationId(EchoServerClient.Id);

return ClientFactory.Instance.Create(optionsBuilder.Build());
});
var appLauncher = RegisterDisposable(
new TestAppLauncher(
_testBrokerFixture.SharedInstance,
new Dictionary<string, TestClientFactory> { { EchoServerClient.Id, echoServerFactory } }
)
);
await appLauncher.StartAsync();
var server = ConnectEchoServer();
ConnectEchoServer(
b => b.WithProvidedService(
EchoService.Id,
x => x.WithUnaryMethod<EchoRequest, EchoRequest>("Unary", HandleAsync)));
var request = CreateTestRequest();
var response = await server.CallInvoker.Call(EchoUnaryMethod, request);
response.ShouldBe(request);
Expand Down
4 changes: 2 additions & 2 deletions dsl/interop-lang/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dependencies {
mwe2 "org.eclipse.xtext:xtext-antlr-generator:[2.1.1, 3)"

// added for Xcore support
mwe2 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:+'
mwe2 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:+'
mwe2 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
mwe2 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.2.0'
}

task generateXtextLanguage(type: JavaExec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ package interop;

enum AppLaunchMode {
SINGLE_INSTANCE = 0;
MULTI_INSTANCE = 1;
SINGLE_LAUNCHING_INSTANCE = 2;
MULTI_INSTANCE = 1;
}
10 changes: 5 additions & 5 deletions dsl/model/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ dependencies {
compile "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
compile 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:+'

xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:+'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:+'
xtextLanguages "org.eclipse.emf:org.eclipse.emf.codegen:+"
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore:+'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:+'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.3.0'
xtextLanguages "org.eclipse.emf:org.eclipse.emf.codegen:2.11.0"
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore:2.12.0'
xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.2.0'
xtextLanguages "org.eclipse.xtext:org.eclipse.xtext.ecore:${xtextVersion}"
xtextLanguages "org.eclipse.emf:org.eclipse.emf.mwe2.lib:2.9.1.201705291010"
}
Expand Down
4 changes: 2 additions & 2 deletions dsl/proto-lang/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ dependencies {
mwe2 "org.eclipse.xtext:xtext-antlr-generator:[2.1.1, 3)"

// added for Xcore support
mwe2 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:+'
mwe2 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:+'
mwe2 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
mwe2 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.2.0'
}

task generateXtextLanguage(type: JavaExec) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2017 Plexus Interop Deutsche Bank AG
// Copyright 2017-2018 Plexus Interop Deutsche Bank AG
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2017 Plexus Interop Deutsche Bank AG
// Copyright 2017-2018 Plexus Interop Deutsche Bank AG
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2017 Plexus Interop Deutsche Bank AG
// Copyright 2017-2018 Plexus Interop Deutsche Bank AG
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion web/packages/broker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"babel-register": "^6.23.0",
"browserify": "^14.4.0",
"jasmine-reporters": "^2.2.0",
"jest": "23.1.0",
"jest": "23.5.0",
"trash-cli": "^1.4.0",
"tslint": "5.8.0",
"typescript": "2.6.1",
Expand Down
Loading

0 comments on commit ceec72d

Please sign in to comment.