-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1493 from dilanSachi/multiconfig-u1
[2201.0.0] Fix client configuration getting overwritten when mutliple clients are available
- Loading branch information
Showing
13 changed files
with
313 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
ballerina-tests/tests/65_multiple_client_configurations.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
// | ||
// WSO2 LLC. 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. | ||
|
||
syntax = "proto3"; | ||
|
||
import "google/protobuf/empty.proto"; | ||
|
||
service MultipleClientConfigsService1 { | ||
rpc call1(google.protobuf.Empty) returns (google.protobuf.Empty); | ||
} | ||
|
||
service MultipleClientConfigsService2 { | ||
rpc call1(google.protobuf.Empty) returns (google.protobuf.Empty); | ||
} |
38 changes: 38 additions & 0 deletions
38
ballerina-tests/tests/65_multiple_client_configurations_client.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
|
||
// WSO2 LLC. 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. | ||
|
||
import ballerina/grpc; | ||
import ballerina/test; | ||
|
||
grpc:ClientConfiguration config1 = { | ||
secureSocket: { | ||
cert: "tests/resources/public.crt" | ||
} | ||
}; | ||
|
||
grpc:ClientConfiguration config2 = { | ||
secureSocket: { | ||
cert: "tests/resources/public2.crt" | ||
} | ||
}; | ||
|
||
@test:Config {enable: true} | ||
function testMultipleConfigurationsInMultiClientScenario() returns error? { | ||
MultipleClientConfigsService1Client ep1 = check new ("https://localhost:9165", config1); | ||
MultipleClientConfigsService2Client ep2 = check new ("https://localhost:9265", config2); | ||
check ep1->call1(); | ||
check ep2->call1(); | ||
} |
123 changes: 123 additions & 0 deletions
123
ballerina-tests/tests/65_multiple_client_configurations_pb.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
// | ||
// WSO2 LLC. 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. | ||
|
||
import ballerina/grpc; | ||
import ballerina/protobuf.types.empty; | ||
|
||
public isolated client class MultipleClientConfigsService1Client { | ||
*grpc:AbstractClientEndpoint; | ||
|
||
private final grpc:Client grpcClient; | ||
|
||
public isolated function init(string url, *grpc:ClientConfiguration config) returns grpc:Error? { | ||
self.grpcClient = check new (url, config); | ||
check self.grpcClient.initStub(self, ROOT_DESCRIPTOR_65_MULTIPLE_CLIENT_CONFIGURATIONS, getDescriptorMap65MultipleClientConfigurations()); | ||
} | ||
|
||
isolated remote function call1() returns grpc:Error? { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
_ = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService1/call1", message, headers); | ||
} | ||
|
||
isolated remote function call1Context() returns empty:ContextNil|grpc:Error { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
var payload = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService1/call1", message, headers); | ||
[anydata, map<string|string[]>] [_, respHeaders] = payload; | ||
return {headers: respHeaders}; | ||
} | ||
} | ||
|
||
public isolated client class MultipleClientConfigsService2Client { | ||
*grpc:AbstractClientEndpoint; | ||
|
||
private final grpc:Client grpcClient; | ||
|
||
public isolated function init(string url, *grpc:ClientConfiguration config) returns grpc:Error? { | ||
self.grpcClient = check new (url, config); | ||
check self.grpcClient.initStub(self, ROOT_DESCRIPTOR_65_MULTIPLE_CLIENT_CONFIGURATIONS, getDescriptorMap65MultipleClientConfigurations()); | ||
} | ||
|
||
isolated remote function call1() returns grpc:Error? { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
_ = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService2/call1", message, headers); | ||
} | ||
|
||
isolated remote function call1Context() returns empty:ContextNil|grpc:Error { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
var payload = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService2/call1", message, headers); | ||
[anydata, map<string|string[]>] [_, respHeaders] = payload; | ||
return {headers: respHeaders}; | ||
} | ||
} | ||
|
||
public client class MultipleClientConfigsService1NilCaller { | ||
private grpc:Caller caller; | ||
|
||
public isolated function init(grpc:Caller caller) { | ||
self.caller = caller; | ||
} | ||
|
||
public isolated function getId() returns int { | ||
return self.caller.getId(); | ||
} | ||
|
||
isolated remote function sendError(grpc:Error response) returns grpc:Error? { | ||
return self.caller->sendError(response); | ||
} | ||
|
||
isolated remote function complete() returns grpc:Error? { | ||
return self.caller->complete(); | ||
} | ||
|
||
public isolated function isCancelled() returns boolean { | ||
return self.caller.isCancelled(); | ||
} | ||
} | ||
|
||
public client class MultipleClientConfigsService2NilCaller { | ||
private grpc:Caller caller; | ||
|
||
public isolated function init(grpc:Caller caller) { | ||
self.caller = caller; | ||
} | ||
|
||
public isolated function getId() returns int { | ||
return self.caller.getId(); | ||
} | ||
|
||
isolated remote function sendError(grpc:Error response) returns grpc:Error? { | ||
return self.caller->sendError(response); | ||
} | ||
|
||
isolated remote function complete() returns grpc:Error? { | ||
return self.caller->complete(); | ||
} | ||
|
||
public isolated function isCancelled() returns boolean { | ||
return self.caller.isCancelled(); | ||
} | ||
} | ||
|
||
const string ROOT_DESCRIPTOR_65_MULTIPLE_CLIENT_CONFIGURATIONS = "0A2736355F6D756C7469706C655F636C69656E745F636F6E66696775726174696F6E732E70726F746F1A1B676F6F676C652F70726F746F6275662F656D7074792E70726F746F32580A1D4D756C7469706C65436C69656E74436F6E66696773536572766963653112370A0563616C6C3112162E676F6F676C652E70726F746F6275662E456D7074791A162E676F6F676C652E70726F746F6275662E456D70747932580A1D4D756C7469706C65436C69656E74436F6E66696773536572766963653212370A0563616C6C3112162E676F6F676C652E70726F746F6275662E456D7074791A162E676F6F676C652E70726F746F6275662E456D707479620670726F746F33"; | ||
|
||
public isolated function getDescriptorMap65MultipleClientConfigurations() returns map<string> { | ||
return {"65_multiple_client_configurations.proto": "0A2736355F6D756C7469706C655F636C69656E745F636F6E66696775726174696F6E732E70726F746F1A1B676F6F676C652F70726F746F6275662F656D7074792E70726F746F32580A1D4D756C7469706C65436C69656E74436F6E66696773536572766963653112370A0563616C6C3112162E676F6F676C652E70726F746F6275662E456D7074791A162E676F6F676C652E70726F746F6275662E456D70747932580A1D4D756C7469706C65436C69656E74436F6E66696773536572766963653212370A0563616C6C3112162E676F6F676C652E70726F746F6275662E456D7074791A162E676F6F676C652E70726F746F6275662E456D707479620670726F746F33", "google/protobuf/empty.proto": "0A1B676F6F676C652F70726F746F6275662F656D7074792E70726F746F120F676F6F676C652E70726F746F62756622070A05456D70747942540A13636F6D2E676F6F676C652E70726F746F627566420A456D70747950726F746F50015A057479706573F80101A20203475042AA021E476F6F676C652E50726F746F6275662E57656C6C4B6E6F776E5479706573620670726F746F33"}; | ||
} | ||
|
45 changes: 45 additions & 0 deletions
45
ballerina-tests/tests/65_multiple_client_configurations_service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
|
||
// WSO2 LLC. 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. | ||
|
||
import ballerina/grpc; | ||
|
||
listener grpc:Listener multiConfigListener1 = new (9165, secureSocket = { | ||
key: { | ||
certFile: "tests/resources/public.crt", | ||
keyFile: "tests/resources/private.key" | ||
} | ||
}); | ||
|
||
@grpc:ServiceDescriptor {descriptor: ROOT_DESCRIPTOR_65_MULTIPLE_CLIENT_CONFIGURATIONS, descMap: getDescriptorMap65MultipleClientConfigurations()} | ||
service "MultipleClientConfigsService1" on multiConfigListener1 { | ||
|
||
remote function call1() returns error? { | ||
} | ||
} | ||
|
||
listener grpc:Listener multiConfigListener2 = new (9265, secureSocket = { | ||
key: { | ||
certFile: "tests/resources/public2.crt", | ||
keyFile: "tests/resources/private2.key" | ||
} | ||
}); | ||
|
||
@grpc:ServiceDescriptor {descriptor: ROOT_DESCRIPTOR_65_MULTIPLE_CLIENT_CONFIGURATIONS, descMap: getDescriptorMap65MultipleClientConfigurations()} | ||
service "MultipleClientConfigsService2" on multiConfigListener2 { | ||
|
||
remote function call1() returns error? { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCSdfIOco/H6EFV | ||
wH2JA0XNw658K3dbUHNpiG9taxxh+WZyqGwTJypbwzsSwtmHJkmLSTnwwXKpAKvz | ||
cV0l1Pm1Tki38Q9rcuwQ1DKOh6Ovjf7UjF3JYrqkgpn2XgGxllsVPQsgjJd2GQ2c | ||
0WKbq/au+WBme6GK+gzUBDZK5hyiXcbauYnjA9q/r6pGzO95FhIHbwdtCD8OntfM | ||
sltaWV/jYcUjMb/+j4mj38ib7Mhrzm/fNT2snalzMqnSnTe1gErltv3r0bDXQFU+ | ||
wOy0xkb+0aAt/RRbqWoqVM+hOyfyuODXJiCoDnbmp3zPOkw9utykkhuOzBALqqkA | ||
co7XNFJnAgMBAAECggEABT1L7gFiLGQeJjuvIf4oep5z+QQzDmS35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gYEAso51I7hipW/Bu+x9m+Oy | ||
dCpM/S0i9sVdvTQoy3mkiCGii1YRySVeHl2d4gnrT+872FBOI0PnhO8Cen5KVq4F | ||
HlHOpenNz9CPfjoyKO1ZzWDEf1dpxdJh8TbHnMi46DaG6xlxt46Raqbqmrp/aQkt | ||
IkDD4NBPFxZ0q4QsTi6vFhQ= | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDsTCCApmgAwIBAgIUQNhCNPDDTuFXfM6peyjmUXFU1vkwDQYJKoZIhvcNAQEL | ||
BQAwaDELMAkGA1UEBhMCTEsxEDAOBgNVBAgMB1dlc3Rlcm4xEDAOBgNVBAcMB0Nv | ||
bG9tYm8xDTALBgNVBAoMBFdTTzIxEjAQBgNVBAsMCUJhbGxlcmluYTESMBAGA1UE | ||
AwwJbG9jYWxob3N0MB4XDTIzMTIxODEwMDc0MloXDTI0MTIxNzEwMDc0MlowaDEL | ||
MAkGA1UEBhMCTEsxEDAOBgNVBAgMB1dlc3Rlcm4xEDAOBgNVBAcMB0NvbG9tYm8x | ||
DTALBgNVBAoMBFdTTzIxEjAQBgNVBAsMCUJhbGxlcmluYTESMBAGA1UEAwwJbG9j | ||
YWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAknXyDnKPx+hB | ||
VcB9iQNFzcOufCt3W1BzaYhvbWscYflmcqhsEycqW8M7EsLZhyZJi0k58MFyqQCr | ||
83FdJdT5tU5It/EPa3LsENQyjoejr43+1IxdyWK6pIKZ9l4BsZZbFT0LIIyXdhkN | ||
nNFim6v2rvlgZnuhivoM1AQ2SuYcol3G2rmJ4wPav6+qRszveRYSB28HbQg/Dp7X | ||
zLJbWllf42HFIzG//o+Jo9/Im+zIa85v3zU9rJ2pczKp0p03tYBK5bb969Gw10BV | ||
PsDstMZG/tGgLf0UW6lqKlTPoTsn8rjg1yYgqA525qd8zzpMPbrcpJIbjswQC6qp | ||
AHKO1zRSZwIDAQABo1MwUTAdBgNVHQ4EFgQUI1DNyHFRIMZuPPhfZrK+O+F//xUw | ||
HwYDVR0jBBgwFoAUI1DNyHFRIMZuPPhfZrK+O+F//xUwDwYDVR0TAQH/BAUwAwEB | ||
/zANBgkqhkiG9w0BAQsFAAOCAQEAbqFWpIPHV32QtomaKZaF5PGfFEGS6+sgtiz3 | ||
fbli6R0floI7kfEHwinCyfv/u4qI2i8unXP2kBUXrsGeoDrMsoJUc94LX5L1pdpo | ||
c+qaCpP8CyTktiSlPmqfklGJzTh8h7+OJVPcWunnNwL6op2ZyyqMEgsRrzB0iCSA | ||
5URZRtTwLq/JJnnUE1YQFrndmOs4Go4+Xdx5Q/rquYBSGt8fpceTDxzrIdR2QS5a | ||
1FriP1l2k/Yi+st9XtYx6SiN5jcIpPWgQco8kxYtAtCER0dqJM3/UyuaAzYSJAnI | ||
cxANjATsH+ALr5F7bDCOqvMiSndJYh1V4d0ufC2YqbvIq/9XOg== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters