diff --git a/.github/workflows/build_release_artifacts.yml b/.github/workflows/build_release_artifacts.yml index 79001131..d530102f 100644 --- a/.github/workflows/build_release_artifacts.yml +++ b/.github/workflows/build_release_artifacts.yml @@ -68,12 +68,23 @@ jobs: run: | $directory = "${{runner.workspace}}/grpc-labview/tests/New_ATS/logs" - Get-ChildItem -Path $directory | ForEach-Object { - if ($_.PSIsContainer -eq $false) { - Write-Host "Contents of $($_.Name):" - Get-Content $_.FullName + # Recursively iterate through all files in subfolders + Get-ChildItem -Path $directory -File -Recurse | Group-Object Directory | ForEach-Object { + $subfolderName = $_.Name + + Write-Host "Folder: $subfolderName" + + $_.Group | ForEach-Object { + $file = $_ + Write-Host "Filename: $($file.Name)" + Write-Host "Contents:" + + # Print the content of the file + Get-Content $file.FullName + Write-Host "" } + Write-Host "" } - if: startsWith(github.ref, 'refs/tags/v') diff --git a/labview source/Client Server Support New/gRPC Scripting Tools/Top Level API/Delete Message Template Files.vi b/labview source/Client Server Support New/gRPC Scripting Tools/Top Level API/Delete Message Template Files.vi index ab58cf1d..aff9b8e4 100644 Binary files a/labview source/Client Server Support New/gRPC Scripting Tools/Top Level API/Delete Message Template Files.vi and b/labview source/Client Server Support New/gRPC Scripting Tools/Top Level API/Delete Message Template Files.vi differ diff --git a/tests/New_ATS/.gitignore b/tests/New_ATS/.gitignore index a474825b..29301961 100644 --- a/tests/New_ATS/.gitignore +++ b/tests/New_ATS/.gitignore @@ -8,6 +8,6 @@ venv *.aliases *.lvproj *.lvlps -Generated_server Generated_client -logs +Generated_server +logs \ No newline at end of file diff --git a/tests/New_ATS/README.md b/tests/New_ATS/README.md index 47d2819c..cbe2820d 100644 --- a/tests/New_ATS/README.md +++ b/tests/New_ATS/README.md @@ -6,12 +6,13 @@ 2. The configuration of the testing suite is saved in the [testlist.json](pylib/testlist.json) file. We can modify it to run specific tests with specific labview version and bitness according to our needs. -3. For each test, inside the test folder, we have a protofile, a `Python_client` folder that contains the python clients and an `Impl` folder that stores pre-implemented `Start Sync.vi` and `Run Service.vi` for that particular protofile. +3. For each test, inside the test folder, we have a protofile, a `Python_client` folder that contains the python clients, optionally a `Python_server` folder that contains the python server, an `Impl` folder that stores pre-implemented `Start Sync.vi` and `Run Service.vi` for that particular protofile and a `testcases` folder that contain the testcases for each rpc in json format. 4. When executing the testing suite, the following steps are performed for each test: - Delete the pre-existing `Generated Server` folder that contains the gRPC Server. - Regenerate the gRPC server using the protofile. - Copy the `Start Sync.vi` and `Run Service.vi` from the `Impl` folder into the new `Generated Server` folder. + - Regenerate the server (without deleting the previously generated server) if we are not doing clean generation. - Run the pre-written python clients in the `Python_client` folder which uses pytest to run all the testcases for each rpc. The testcases are defined in the form of json files in the `testcases` folder. - Prints the verbose output of each testcase onto the terminal. @@ -49,7 +50,7 @@ Now follow the below steps to run the testing suite on windows. Currently only w (By default it runs Labview 2019) ```json - "labview-version": "2019", + "labview_version": "2019", ``` - Modify the value associated with `"labview-bitness"` to run the specified labview version with the sepcified bitness. @@ -57,7 +58,15 @@ Now follow the below steps to run the testing suite on windows. Currently only w (By default it runs Labview 2019 32 bit) ```json - "labview-bitness": "32" + "labview_bitness": "32", + ``` + + - Modify the value associated with `"clean_gen"` to specify whether or not you want to do a clean generation. + + (By default it is set to 'true' which means we are doing a clean generation) + + ```json + "clean_gen": true ``` 2. Run the [pylib/run_tests.py](pylib/run_tests.py) @@ -90,6 +99,8 @@ Follow the below steps to add more tests in the testing suite. 10. Create a `Python_client` folder and add python clients for each rpc into it that will interact with the LabVIEW gRPC Server. The name of the client can be anything but should strictly end with `_client.py` like `_client.py`. +11. Optionally, you may also create a `Python_server` folder and write the python server with all the rpc's defined into it. The name of the python server can be anything but we prefer it to be like `_server.py`. + ### TODO: 1. Add the following tests: @@ -98,9 +109,9 @@ Follow the below steps to add more tests in the testing suite. - [ ] Reflection tests - [ ] Client tests (currently we are only testing gRPC Server) - [ ] Modification scenarios (do some modification after first generation and then generate and test again) - - Add/Remove/modify RPC - - Add/Remove/modify services - - Add/Remove/modify messages + - Add/Remove/modify RPC + - Add/Remove/modify services + - Add/Remove/modify messages - [ ] Backward compatibility tests (server generated without the current feature but needs to work with the changes to the current features) - [ ] Imported proto-file tests - [x] Multiple RPC methods tests diff --git a/tests/New_ATS/Tests/all-datatypes-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/all-datatypes-oneof/Python_client/GetFeature_client.py index 0b33428a..7c3ce000 100644 --- a/tests/New_ATS/Tests/all-datatypes-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/all-datatypes-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,12 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. +# 2) Increments all the integer and decimal fields of req_oneof by 1 and saves in corresponding res_oneof fields of 'res' message. +# 3) Appends '_response' to the string fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. +# 4) Does a NOT operation on the boolean fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. +# 5) Doesn't do any operation on the bytes fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. def get_GetFeature_output(test_input): req_latitude = test_input.get('req_latitude') diff --git a/tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof_server.py b/tests/New_ATS/Tests/all-datatypes-oneof/Python_server/all-datatypes-oneof_server.py similarity index 76% rename from tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof_server.py rename to tests/New_ATS/Tests/all-datatypes-oneof/Python_server/all-datatypes-oneof_server.py index d70e3ba2..ebd29841 100644 --- a/tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof_server.py +++ b/tests/New_ATS/Tests/all-datatypes-oneof/Python_server/all-datatypes-oneof_server.py @@ -5,6 +5,13 @@ import all_datatypes_oneof_pb2_grpc class GreeterService(all_datatypes_oneof_pb2_grpc.GreeterServiceServicer): + + # 'GetFeature' rpc performs the following operations on the 'req' message fields: + # 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. + # 2) Increments all the integer and decimal fields of req_oneof by 1 and saves in corresponding res_oneof fields of 'res' message. + # 3) Appends '_response' to the string fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. + # 4) Does a NOT operation on the boolean fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. + # 5) Doesn't do any operation on the bytes fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. def GetFeature(self, request, context): response = all_datatypes_oneof_pb2.res(res_latitude=request.req_latitude+1) if request.HasField('req_int32'): diff --git a/tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof.proto b/tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof.proto index db541f3c..a08080e4 100644 --- a/tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof.proto +++ b/tests/New_ATS/Tests/all-datatypes-oneof/all-datatypes-oneof.proto @@ -3,6 +3,12 @@ syntax = "proto3"; package Greeter; service GreeterService { + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. + // 2) Increments all the integer and decimal fields of req_oneof by 1 and saves in corresponding res_oneof fields of 'res' message. + // 3) Appends '_response' to the string fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. + // 4) Does a NOT operation on the boolean fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. + // 5) Doesn't do any operation on the bytes fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/Tests/enum-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/enum-oneof/Python_client/GetFeature_client.py index fd3d9444..d553afff 100644 --- a/tests/New_ATS/Tests/enum-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/enum-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,10 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Increments req_latitude by 1 and saves in res_latitude. +# 2) Appends '_response' to the req_name field of req_oneof and saves in res_name field of res_oneof. +# 3) Returns the same value of req_color field of req_oneof and saves in res_color field of res_oneof. def get_GetFeature_output(test_input): req_latitude = int(test_input.get('req_latitude')) req_name = test_input['req_oneof'].get('req_name') @@ -16,9 +20,11 @@ def get_GetFeature_output(test_input): response_dict = {} response_dict['res_latitude'] = response.res_latitude response_dict['res_oneof'] = {} - response_dict['res_oneof']['res_color'] = enum_oneof_pb2.Color.Name(response.res_color) if response.HasField('res_color') else None - response_dict['res_oneof']['res_name'] = response.res_name if response.HasField('res_name') else None - + if response.HasField('res_color'): + response_dict['res_oneof']['res_color'] = enum_oneof_pb2.Color.Name(response.res_color) + if response.HasField('res_name'): + response_dict['res_oneof']['res_name'] = response.res_name + return(response_dict) def read_json(filepath): diff --git a/tests/New_ATS/Tests/enum-oneof/enum-oneof.proto b/tests/New_ATS/Tests/enum-oneof/enum-oneof.proto index f7241f8f..e1841b61 100644 --- a/tests/New_ATS/Tests/enum-oneof/enum-oneof.proto +++ b/tests/New_ATS/Tests/enum-oneof/enum-oneof.proto @@ -3,6 +3,11 @@ syntax = "proto3"; package Greeter; service GreeterService { + + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Increments req_latitude by 1 and saves in res_latitude. + // 2) Appends '_response' to the req_name field of req_oneof and saves in res_name field of res_oneof. + // 3) Returns the same value of req_color field of req_oneof and saves in res_color field of res_oneof. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/Tests/enum-oneof/testcases/GetFeature.json b/tests/New_ATS/Tests/enum-oneof/testcases/GetFeature.json index c2c13cd6..345a1905 100644 --- a/tests/New_ATS/Tests/enum-oneof/testcases/GetFeature.json +++ b/tests/New_ATS/Tests/enum-oneof/testcases/GetFeature.json @@ -3,15 +3,13 @@ "input": { "req_latitude": 100, "req_oneof": { - "req_name": "Enum", - "req_color": null + "req_name": "Enum" } }, "output": { "res_latitude": 101, "res_oneof": { - "res_name": "Enum_response", - "res_color": null + "res_name": "Enum_response" } } }, @@ -19,14 +17,12 @@ "input": { "req_latitude": 100, "req_oneof": { - "req_name": null, "req_color": "GREEN" } }, "output": { "res_latitude": 101, "res_oneof": { - "res_name": null, "res_color": "GREEN" } } diff --git a/tests/New_ATS/Tests/enum-streaming/Impl/Run Service.vi b/tests/New_ATS/Tests/enum-streaming/Impl/Run Service.vi new file mode 100644 index 00000000..106db68c Binary files /dev/null and b/tests/New_ATS/Tests/enum-streaming/Impl/Run Service.vi differ diff --git a/tests/New_ATS/Tests/enum-streaming/Impl/Start Sync.vi b/tests/New_ATS/Tests/enum-streaming/Impl/Start Sync.vi new file mode 100644 index 00000000..60fe4371 Binary files /dev/null and b/tests/New_ATS/Tests/enum-streaming/Impl/Start Sync.vi differ diff --git a/tests/New_ATS/Tests/enum-streaming/Python_client/BidirectionalStreamingMethod_client.py b/tests/New_ATS/Tests/enum-streaming/Python_client/BidirectionalStreamingMethod_client.py new file mode 100644 index 00000000..ec5ea085 --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/Python_client/BidirectionalStreamingMethod_client.py @@ -0,0 +1,80 @@ +import grpc +import enum_streaming_pb2 +import enum_streaming_pb2_grpc +import json +import pytest +import os +from enum import Enum + +# 'BidirectionalStreamingMethod' rpc performs the following operations on a stream of 'request' message fields and outputs a stream of corresonding 'response' messages: +# 1) Increments request_number by 1 and saves in response_number of 'response' message. +# 2) Appends '_response' to the request_message field and saves in response_message field of 'response' message. +# 3) Save the same request_color enum value in response_color +class Color(Enum): + RED = 0 + GREEN = 1 + BLUE = 2 + +def get_BidirectionalStreamingMethod_output(test_input): + + responses = [] + + with grpc.insecure_channel('localhost:50051') as channel: + stub = enum_streaming_pb2_grpc.RouteGuideStub(channel) + def get_requests(): + for request in test_input: + request_number = request["request_number"] + request_message = request["request_message"] + request_color = request["request_color"] + if Color.RED.value == request_color: + request_color = Color.RED + if Color.GREEN.value == request_color: + request_color = Color.GREEN + if Color.BLUE.value == request_color: + request_color = Color.BLUE + yield enum_streaming_pb2.request(request_number=request_number, request_message=request_message, request_color=request_color) + response_stream = stub.BidirectionalStreamingMethod(get_requests()) + for response in response_stream: + response_dict = { + "response_number": response.response_number, + "response_message": response.response_message, + "response_color": response.response_color, + } + if response_dict["response_color"] == 0: + response_dict["response_color"] = "RED" + if response_dict["response_color"] == 1: + response_dict["response_color"] = "GREEN" + if response_dict["response_color"] == 2: + response_dict["response_color"] = "BLUE" + + responses.append(response_dict) + + return responses + +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +BidirectionalStreamingMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/BidirectionalStreamingMethod.json' + +@pytest.mark.parametrize('testcase', read_json(BidirectionalStreamingMethod_json_file_path)) +def test_BidirectionalStreamingMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_BidirectionalStreamingMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_BidirectionalStreamingMethod_output([ + { + "request_number": 25, + "request_message": "Hello, World!", + "request_color": "RED" + }, + { + "request_number": 52, + "request_message": "Goodbye, World!", + "request_color": "BLUE" + } + ]) + print(res) \ No newline at end of file diff --git a/tests/New_ATS/Tests/enum-streaming/Python_client/ClientStreamingMethod_client.py b/tests/New_ATS/Tests/enum-streaming/Python_client/ClientStreamingMethod_client.py new file mode 100644 index 00000000..846fac7f --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/Python_client/ClientStreamingMethod_client.py @@ -0,0 +1,77 @@ +import grpc +import enum_streaming_pb2 +import enum_streaming_pb2_grpc +import json +import pytest +import os +from enum import Enum + +# 'ClientStreamingMethod' rpc performs the following operations on a stream of 'request' message fields and outputs a single 'response' message: +# 1) Adds the values of request_number of each 'request' message and saves the sum in the response_number of the 'response' message. +# 2) Appends the values of all request_message fields and saves the result in response_message of 'response' message. +# 3) Save the same request_color enum value of the last 'request' message in response_color of each 'response' message +class Color(Enum): + RED = 0 + GREEN = 1 + BLUE = 2 + +def get_ClientStreamingMethod_output(test_input): + + response_dict = {} + with grpc.insecure_channel('localhost:50051') as channel: + stub = enum_streaming_pb2_grpc.RouteGuideStub(channel) + def get_requests(): + for request in test_input: + request_number = request["request_number"] + request_message = request["request_message"] + request_color = request["request_color"] + if Color.RED.value == request_color: + request_color = Color.RED + if Color.GREEN.value == request_color: + request_color = Color.GREEN + if Color.BLUE.value == request_color: + request_color = Color.BLUE + yield enum_streaming_pb2.request(request_number=request_number, request_message=request_message, request_color=request_color) + response = stub.ClientStreamingMethod(get_requests()) + + response_dict = { + "response_number": response.response_number, + "response_message": response.response_message, + "response_color": response.response_color, + } + if response_dict["response_color"] == 0: + response_dict["response_color"] = "RED" + if response_dict["response_color"] == 1: + response_dict["response_color"] = "GREEN" + if response_dict["response_color"] == 2: + response_dict["response_color"] = "BLUE" + + return response_dict + +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +ClientStreamingMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/ClientStreamingMethod.json' + +@pytest.mark.parametrize('testcase', read_json(ClientStreamingMethod_json_file_path)) +def test_ClientStreamingMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_ClientStreamingMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_ClientStreamingMethod_output([ + { + "request_number": 25, + "request_message": "Hello, World!", + "request_color": "RED" + }, + { + "request_number": 52, + "request_message": "Goodbye, World!", + "request_color": "BLUE" + } + ]) + print(res) \ No newline at end of file diff --git a/tests/New_ATS/Tests/enum-streaming/Python_client/ServerStreamingMethod_client.py b/tests/New_ATS/Tests/enum-streaming/Python_client/ServerStreamingMethod_client.py new file mode 100644 index 00000000..632af96e --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/Python_client/ServerStreamingMethod_client.py @@ -0,0 +1,72 @@ +import grpc +import enum_streaming_pb2 +import enum_streaming_pb2_grpc +import json +import pytest +import os +from enum import Enum + +# 'ServerStreamingMethod' rpc performs the following operations on the 'request' message fields and streams 'request_number' number of 'response' messages: +# 1) Increments response_number from the previous response_number by 1 starting with the request_number value in the first 'response' message's response_number. +# 2) Appends '_response' to the request_message field and saves in response_message field of each 'response' message. +# 3) Save the same request_color enum value in response_color of each 'response' message +class Color(Enum): + RED = 0 + GREEN = 1 + BLUE = 2 + +def get_ServerStreamingMethod_output(test_input): + request_number = test_input["request_number"] + request_message = test_input["request_message"] + request_color = test_input["request_color"] + if Color.RED.value == request_color: + request_color = Color.RED + if Color.GREEN.value == request_color: + request_color = Color.GREEN + if Color.BLUE.value == request_color: + request_color = Color.BLUE + + responses = [] + + with grpc.insecure_channel('localhost:50051') as channel: + stub = enum_streaming_pb2_grpc.RouteGuideStub(channel) + request = enum_streaming_pb2.request(request_number=request_number, request_message=request_message, request_color=request_color) + response_stream = stub.ServerStreamingMethod(request) + + for response in response_stream: + response_dict = { + "response_number": response.response_number, + "response_message": response.response_message, + "response_color": response.response_color, + } + if response_dict["response_color"] == 0: + response_dict["response_color"] = "RED" + if response_dict["response_color"] == 1: + response_dict["response_color"] = "GREEN" + if response_dict["response_color"] == 2: + response_dict["response_color"] = "BLUE" + + responses.append(response_dict) + + return responses + +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +ServerStreamingMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/ServerStreamingMethod.json' + +@pytest.mark.parametrize('testcase', read_json(ServerStreamingMethod_json_file_path)) +def test_ServerStreamingMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_ServerStreamingMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_ServerStreamingMethod_output({ + "request_number": 10, + "request_message": "Hello, World!", + "request_color": "BLUE" + }) + print(res) \ No newline at end of file diff --git a/tests/New_ATS/Tests/enum-streaming/Python_client/UnaryMethod_client.py b/tests/New_ATS/Tests/enum-streaming/Python_client/UnaryMethod_client.py new file mode 100644 index 00000000..22d62b3d --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/Python_client/UnaryMethod_client.py @@ -0,0 +1,69 @@ +import grpc +import enum_streaming_pb2 +import enum_streaming_pb2_grpc +import json +import pytest +import os +from enum import Enum + +# 'UnaryMethod' rpc performs the following operations on the 'request' message fields: +# 1) Increments request_number by 1 and saves in response_number of 'response' message. +# 2) Appends '_response' to the request_message field and saves in response_message field of 'response' message. +# 3) Save the same request_color enum value in response_color +class Color(Enum): + RED = 0 + GREEN = 1 + BLUE = 2 + +def get_UnaryMethod_output(test_input): + request_number = test_input["request_number"] + request_message = test_input["request_message"] + request_color = test_input["request_color"] + if Color.RED.value == request_color: + request_color = Color.RED + if Color.GREEN.value == request_color: + request_color = Color.GREEN + if Color.BLUE.value == request_color: + request_color = Color.BLUE + + + with grpc.insecure_channel('localhost:50051') as channel: + stub = enum_streaming_pb2_grpc.RouteGuideStub(channel) + request = enum_streaming_pb2.request(request_number=request_number, request_message=request_message, request_color=request_color) + response = stub.UnaryMethod(request) + + response_dict = { + "response_number": response.response_number, + "response_message": response.response_message, + "response_color": response.response_color, + } + + if response_dict["response_color"] == 0: + response_dict["response_color"] = "RED" + if response_dict["response_color"] == 1: + response_dict["response_color"] = "GREEN" + if response_dict["response_color"] == 2: + response_dict["response_color"] = "BLUE" + + return response_dict + +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +UnaryMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/UnaryMethod.json' + +@pytest.mark.parametrize('testcase', read_json(UnaryMethod_json_file_path)) +def test_UnaryMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_UnaryMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_UnaryMethod_output({ + "request_number": 25, + "request_message": "Hello, World!", + "request_color": "GREEN" + }) + print(res) \ No newline at end of file diff --git a/tests/New_ATS/Tests/enum-streaming/enum-streaming.proto b/tests/New_ATS/Tests/enum-streaming/enum-streaming.proto new file mode 100644 index 00000000..c7092f62 --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/enum-streaming.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package routeguide; + +enum Color { + RED = 0; + GREEN = 1; + BLUE = 2; +} + +service RouteGuide{ + + // 'UnaryMethod' rpc performs the following operations on the 'request' message fields: + // 1) Increments request_number by 1 and saves in response_number of 'response' message. + // 2) Appends '_response' to the request_message field and saves in response_message field of 'response' message. + // 3) Save the same request_color enum value in response_color + rpc UnaryMethod(request) returns (response) {} + + // 'ServerStreamingMethod' rpc performs the following operations on the 'request' message fields and streams 'request_number' number of 'response' messages: + // 1) Increments response_number from the previous response_number by 1 starting with the request_number value in the first 'response' message's response_number. + // 2) Appends '_response' to the request_message field and saves in response_message field of each 'response' message. + // 3) Save the same request_color enum value in response_color of each 'response' message + rpc ServerStreamingMethod(request) returns (stream response) {} + + // 'ClientStreamingMethod' rpc performs the following operations on a stream of 'request' message fields and outputs a single 'response' message: + // 1) Adds the values of request_number of each 'request' message and saves the sum in the response_number of the 'response' message. + // 2) Appends the values of all request_message fields and saves the result in response_message of 'response' message. + // 3) Save the same request_color enum value of the last 'request' message in response_color of each 'response' message + rpc ClientStreamingMethod(stream request) returns (response) {} + + // 'BidirectionalStreamingMethod' rpc performs the following operations on a stream of 'request' message fields and outputs a stream of corresonding 'response' messages: + // 1) Increments request_number by 1 and saves in response_number of 'response' message. + // 2) Appends '_response' to the request_message field and saves in response_message field of 'response' message. + // 3) Save the same request_color enum value in response_color + rpc BidirectionalStreamingMethod(stream request) returns (stream response) {} +} + +message request { + int32 request_number = 1; + string request_message = 2; + Color request_color = 3; +} + +message response { + int32 response_number = 1; + string response_message = 2; + Color response_color = 3; +} \ No newline at end of file diff --git a/tests/New_ATS/Tests/enum-streaming/testcases/BidirectionalStreamingMethod.json b/tests/New_ATS/Tests/enum-streaming/testcases/BidirectionalStreamingMethod.json new file mode 100644 index 00000000..8fd7d0f6 --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/testcases/BidirectionalStreamingMethod.json @@ -0,0 +1,218 @@ +[ + { + "input": [ + { + "request_number": 10, + "request_message": "Hello, world!", + "request_color": "RED" + }, + { + "request_number": 95, + "request_message": "Goodbye, world!", + "request_color": "GREEN" + }, + { + "request_number": 20, + "request_message": "Test Input 1", + "request_color": "GREEN" + } + ], + "output": [ + { + "response_number": 11, + "response_message": "Hello, world!_response", + "response_color": "RED" + }, + { + "response_number": 96, + "response_message": "Goodbye, world!_response", + "response_color": "GREEN" + }, + { + "response_number": 21, + "response_message": "Test Input 1_response", + "response_color": "GREEN" + } + ] + }, + { + "input": [ + { + "request_number": 20, + "request_message": "Test Input 1", + "request_color": "GREEN" + }, + { + "request_number": 75, + "request_message": "Test Input 2", + "request_color": "RED" + } + ], + "output": [ + { + "response_number": 21, + "response_message": "Test Input 1_response", + "response_color": "GREEN" + }, + { + "response_number": 76, + "response_message": "Test Input 2_response", + "response_color": "RED" + } + ] + }, + { + "input": [ + { + "request_number": 30, + "request_message": "Sample Input A", + "request_color": "RED" + }, + { + "request_number": 85, + "request_message": "Sample Input B", + "request_color": "GREEN" + }, + { + "request_number": 67, + "request_message": "Sample Input C", + "request_color": "BLUE" + }, + { + "request_number": 5, + "request_message": "Test Input D", + "request_color": "RED" + }, + { + "request_number": 8, + "request_message": "Test Input E", + "request_color": "BLUE" + } + ], + "output": [ + { + "response_number": 31, + "response_message": "Sample Input A_response", + "response_color": "RED" + }, + { + "response_number": 86, + "response_message": "Sample Input B_response", + "response_color": "GREEN" + }, + { + "response_number": 68, + "response_message": "Sample Input C_response", + "response_color": "BLUE" + }, + { + "response_number": 6, + "response_message": "Test Input D_response", + "response_color": "RED" + }, + { + "response_number": 9, + "response_message": "Test Input E_response", + "response_color": "BLUE" + } + ] + }, + { + "input": [ + { + "request_number": 5, + "request_message": "Test Input X", + "request_color": "GREEN" + }, + { + "request_number": 60, + "request_message": "Test Input Y", + "request_color": "RED" + }, + { + "request_number": 6, + "request_message": "Test Input Z", + "request_color": "BLUE" + } + ], + "output": [ + { + "response_number": 6, + "response_message": "Test Input X_response", + "response_color": "GREEN" + }, + { + "response_number": 61, + "response_message": "Test Input Y_response", + "response_color": "RED" + }, + { + "response_number": 7, + "response_message": "Test Input Z_response", + "response_color": "BLUE" + } + ] + }, + { + "input": [ + { + "request_number": 15, + "request_message": "Random Input 1", + "request_color": "BLUE" + }, + { + "request_number": 70, + "request_message": "Random Input 2", + "request_color": "RED" + } + ], + "output": [ + { + "response_number": 16, + "response_message": "Random Input 1_response", + "response_color": "BLUE" + }, + { + "response_number": 71, + "response_message": "Random Input 2_response", + "response_color": "RED" + } + ] + }, + { + "input": [ + { + "request_number": 25, + "request_message": "Test Message 1", + "request_color": "GREEN" + }, + { + "request_number": 80, + "request_message": "Test Message 2", + "request_color": "BLUE" + }, + { + "request_number": 7, + "request_message": "Test Message 3", + "request_color": "RED" + } + ], + "output": [ + { + "response_number": 26, + "response_message": "Test Message 1_response", + "response_color": "GREEN" + }, + { + "response_number": 81, + "response_message": "Test Message 2_response", + "response_color": "BLUE" + }, + { + "response_number": 8, + "response_message": "Test Message 3_response", + "response_color": "RED" + } + ] + } +] diff --git a/tests/New_ATS/Tests/enum-streaming/testcases/ClientStreamingMethod.json b/tests/New_ATS/Tests/enum-streaming/testcases/ClientStreamingMethod.json new file mode 100644 index 00000000..89fd64da --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/testcases/ClientStreamingMethod.json @@ -0,0 +1,178 @@ +[ + { + "input": [ + { + "request_number": 10, + "request_message": "Hello, world!", + "request_color": "RED" + }, + { + "request_number": 95, + "request_message": "Goodbye, world!", + "request_color": "GREEN" + }, + { + "request_number": 20, + "request_message": "Test Input 1", + "request_color": "GREEN" + } + ], + "output": { + "response_number": 125, + "response_message": "Hello, world!Goodbye, world!Test Input 1", + "response_color": "GREEN" + } + }, + { + "input": [ + { + "request_number": 5, + "request_message": "Input A", + "request_color": "BLUE" + }, + { + "request_number": 15, + "request_message": "Input B", + "request_color": "RED" + }, + { + "request_number": 30, + "request_message": "Input C", + "request_color": "GREEN" + } + ], + "output": { + "response_number": 50, + "response_message": "Input AInput BInput C", + "response_color": "GREEN" + } + }, + { + "input": [ + { + "request_number": 8, + "request_message": "Input X", + "request_color": "RED" + }, + { + "request_number": 42, + "request_message": "Input Y", + "request_color": "BLUE" + } + ], + "output": { + "response_number": 50, + "response_message": "Input XInput Y", + "response_color": "BLUE" + } + }, + { + "input": [ + { + "request_number": 12, + "request_message": "Sample 1", + "request_color": "GREEN" + }, + { + "request_number": 18, + "request_message": "Sample 2", + "request_color": "RED" + } + ], + "output": { + "response_number": 30, + "response_message": "Sample 1Sample 2", + "response_color": "RED" + } + }, + { + "input": [ + { + "request_number": 9, + "request_message": "Input P", + "request_color": "BLUE" + } + ], + "output": { + "response_number": 9, + "response_message": "Input P", + "response_color": "BLUE" + } + }, + { + "input": [ + { + "request_number": 7, + "request_message": "Input Q", + "request_color": "GREEN" + }, + { + "request_number": 21, + "request_message": "Input R", + "request_color": "RED" + }, + { + "request_number": 16, + "request_message": "Input S", + "request_color": "GREEN" + } + ], + "output": { + "response_number": 44, + "response_message": "Input QInput RInput S", + "response_color": "GREEN" + } + }, + { + "input": [ + { + "request_number": 10, + "request_message": "Test Input 3", + "request_color": "BLUE" + } + ], + "output": { + "response_number": 10, + "response_message": "Test Input 3", + "response_color": "BLUE" + } + }, + { + "input": [ + { + "request_number": 5, + "request_message": "Input T", + "request_color": "RED" + }, + { + "request_number": 25, + "request_message": "Input U", + "request_color": "GREEN" + } + ], + "output": { + "response_number": 30, + "response_message": "Input TInput U", + "response_color": "GREEN" + } + }, + { + "input": [ + { + "request_number": 3, + "request_message": "Test Input 4", + "request_color": "BLUE" + }, + { + "request_number": 12, + "request_message": "Test Input 5", + "request_color": "RED" + } + ], + "output": { + "response_number": 15, + "response_message": "Test Input 4Test Input 5", + "response_color": "RED" + } + } +] diff --git a/tests/New_ATS/Tests/enum-streaming/testcases/ServerStreamingMethod.json b/tests/New_ATS/Tests/enum-streaming/testcases/ServerStreamingMethod.json new file mode 100644 index 00000000..76675090 --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/testcases/ServerStreamingMethod.json @@ -0,0 +1,402 @@ +[ + { + "input": { + "request_number": 10, + "request_message": "Hello, World!", + "request_color": "BLUE" + }, + "output": [ + { + "response_number": 10, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 11, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 12, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 13, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 14, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 15, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 16, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 17, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 18, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + }, + { + "response_number": 19, + "response_message": "Hello, World!_response", + "response_color": "BLUE" + } + ] + }, + { + "input": { + "request_number": 5, + "request_message": "Good Morning!", + "request_color": "RED" + }, + "output": [ + { + "response_number": 5, + "response_message": "Good Morning!_response", + "response_color": "RED" + }, + { + "response_number": 6, + "response_message": "Good Morning!_response", + "response_color": "RED" + }, + { + "response_number": 7, + "response_message": "Good Morning!_response", + "response_color": "RED" + }, + { + "response_number": 8, + "response_message": "Good Morning!_response", + "response_color": "RED" + }, + { + "response_number": 9, + "response_message": "Good Morning!_response", + "response_color": "RED" + } + ] + }, + { + "input": { + "request_number": 7, + "request_message": "Hi There!", + "request_color": "BLUE" + }, + "output": [ + { + "response_number": 7, + "response_message": "Hi There!_response", + "response_color": "BLUE" + }, + { + "response_number": 8, + "response_message": "Hi There!_response", + "response_color": "BLUE" + }, + { + "response_number": 9, + "response_message": "Hi There!_response", + "response_color": "BLUE" + }, + { + "response_number": 10, + "response_message": "Hi There!_response", + "response_color": "BLUE" + }, + { + "response_number": 11, + "response_message": "Hi There!_response", + "response_color": "BLUE" + }, + { + "response_number": 12, + "response_message": "Hi There!_response", + "response_color": "BLUE" + }, + { + "response_number": 13, + "response_message": "Hi There!_response", + "response_color": "BLUE" + } + ] + }, + { + "input": { + "request_number": 3, + "request_message": "Good Evening!", + "request_color": "GREEN" + }, + "output": [ + { + "response_number": 3, + "response_message": "Good Evening!_response", + "response_color": "GREEN" + }, + { + "response_number": 4, + "response_message": "Good Evening!_response", + "response_color": "GREEN" + }, + { + "response_number": 5, + "response_message": "Good Evening!_response", + "response_color": "GREEN" + } + ] + }, + { + "input": { + "request_number": 4, + "request_message": "Have a great day!", + "request_color": "BLUE" + }, + "output": [ + { + "response_number": 4, + "response_message": "Have a great day!_response", + "response_color": "BLUE" + }, + { + "response_number": 5, + "response_message": "Have a great day!_response", + "response_color": "BLUE" + }, + { + "response_number": 6, + "response_message": "Have a great day!_response", + "response_color": "BLUE" + }, + { + "response_number": 7, + "response_message": "Have a great day!_response", + "response_color": "BLUE" + } + ] + }, + { + "input": { + "request_number": 6, + "request_message": "Good Night!", + "request_color": "GREEN" + }, + "output": [ + { + "response_number": 6, + "response_message": "Good Night!_response", + "response_color": "GREEN" + }, + { + "response_number": 7, + "response_message": "Good Night!_response", + "response_color": "GREEN" + }, + { + "response_number": 8, + "response_message": "Good Night!_response", + "response_color": "GREEN" + }, + { + "response_number": 9, + "response_message": "Good Night!_response", + "response_color": "GREEN" + }, + { + "response_number": 10, + "response_message": "Good Night!_response", + "response_color": "GREEN" + }, + { + "response_number": 11, + "response_message": "Good Night!_response", + "response_color": "GREEN" + } + ] + }, + { + "input": { + "request_number": 8, + "request_message": "Welcome!", + "request_color": "RED" + }, + "output": [ + { + "response_number": 8, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 9, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 10, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 11, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 12, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 13, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 14, + "response_message": "Welcome!_response", + "response_color": "RED" + }, + { + "response_number": 15, + "response_message": "Welcome!_response", + "response_color": "RED" + } + ] + }, + { + "input": { + "request_number": 4, + "request_message": "Have a nice day!", + "request_color": "GREEN" + }, + "output": [ + { + "response_number": 4, + "response_message": "Have a nice day!_response", + "response_color": "GREEN" + }, + { + "response_number": 5, + "response_message": "Have a nice day!_response", + "response_color": "GREEN" + }, + { + "response_number": 6, + "response_message": "Have a nice day!_response", + "response_color": "GREEN" + }, + { + "response_number": 7, + "response_message": "Have a nice day!_response", + "response_color": "GREEN" + } + ] + }, + { + "input": { + "request_number": 9, + "request_message": "Goodbye!", + "request_color": "RED" + }, + "output": [ + { + "response_number": 9, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 10, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 11, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 12, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 13, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 14, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 15, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 16, + "response_message": "Goodbye!_response", + "response_color": "RED" + }, + { + "response_number": 17, + "response_message": "Goodbye!_response", + "response_color": "RED" + } + ] + }, + { + "input": { + "request_number": 6, + "request_message": "Sweet Dreams!", + "request_color": "GREEN" + }, + "output": [ + { + "response_number": 6, + "response_message": "Sweet Dreams!_response", + "response_color": "GREEN" + }, + { + "response_number": 7, + "response_message": "Sweet Dreams!_response", + "response_color": "GREEN" + }, + { + "response_number": 8, + "response_message": "Sweet Dreams!_response", + "response_color": "GREEN" + }, + { + "response_number": 9, + "response_message": "Sweet Dreams!_response", + "response_color": "GREEN" + }, + { + "response_number": 10, + "response_message": "Sweet Dreams!_response", + "response_color": "GREEN" + }, + { + "response_number": 11, + "response_message": "Sweet Dreams!_response", + "response_color": "GREEN" + } + ] + } +] diff --git a/tests/New_ATS/Tests/enum-streaming/testcases/UnaryMethod.json b/tests/New_ATS/Tests/enum-streaming/testcases/UnaryMethod.json new file mode 100644 index 00000000..9a61cc50 --- /dev/null +++ b/tests/New_ATS/Tests/enum-streaming/testcases/UnaryMethod.json @@ -0,0 +1,122 @@ +[ + { + "input": { + "request_number": 25, + "request_message": "Hello, World!", + "request_color": "RED" + }, + "output": { + "response_number": 26, + "response_message": "Hello, World!_response", + "response_color": "RED" + } + }, + { + "input": { + "request_number": 10, + "request_message": "Test Input 1", + "request_color": "GREEN" + }, + "output": { + "response_number": 11, + "response_message": "Test Input 1_response", + "response_color": "GREEN" + } + }, + { + "input": { + "request_number": 100, + "request_message": "Sample Message", + "request_color": "BLUE" + }, + "output": { + "response_number": 101, + "response_message": "Sample Message_response", + "response_color": "BLUE" + } + }, + { + "input": { + "request_number": 50, + "request_message": "Another Request", + "request_color": "RED" + }, + "output": { + "response_number": 51, + "response_message": "Another Request_response", + "response_color": "RED" + } + }, + { + "input": { + "request_number": 5, + "request_message": "Short Message", + "request_color": "GREEN" + }, + "output": { + "response_number": 6, + "response_message": "Short Message_response", + "response_color": "GREEN" + } + }, + { + "input": { + "request_number": 75, + "request_message": "Large Request", + "request_color": "BLUE" + }, + "output": { + "response_number": 76, + "response_message": "Large Request_response", + "response_color": "BLUE" + } + }, + { + "input": { + "request_number": 200, + "request_message": "High Number", + "request_color": "RED" + }, + "output": { + "response_number": 201, + "response_message": "High Number_response", + "response_color": "RED" + } + }, + { + "input": { + "request_number": 30, + "request_message": "Request 30", + "request_color": "GREEN" + }, + "output": { + "response_number": 31, + "response_message": "Request 30_response", + "response_color": "GREEN" + } + }, + { + "input": { + "request_number": 15, + "request_message": "Request 15", + "request_color": "BLUE" + }, + "output": { + "response_number": 16, + "response_message": "Request 15_response", + "response_color": "BLUE" + } + }, + { + "input": { + "request_number": 80, + "request_message": "Request 80", + "request_color": "RED" + }, + "output": { + "response_number": 81, + "response_message": "Request 80_response", + "response_color": "RED" + } + } +] diff --git a/tests/New_ATS/Tests/helloworld/Python_client/SayHello_client.py b/tests/New_ATS/Tests/helloworld/Python_client/SayHello_client.py index d18ecac2..fdb758c3 100644 --- a/tests/New_ATS/Tests/helloworld/Python_client/SayHello_client.py +++ b/tests/New_ATS/Tests/helloworld/Python_client/SayHello_client.py @@ -5,6 +5,7 @@ import pytest import os +# Sends a greeting by appending 'Hello ' prefix and "!!!" suffix to the name field of HelloRequest message def read_json(filepath): with open(filepath, 'r') as file: test_data = json.load(file) diff --git a/tests/New_ATS/Tests/helloworld/helloworld_server.py b/tests/New_ATS/Tests/helloworld/Python_server/helloworld_server.py similarity index 85% rename from tests/New_ATS/Tests/helloworld/helloworld_server.py rename to tests/New_ATS/Tests/helloworld/Python_server/helloworld_server.py index 2218e714..898c7341 100644 --- a/tests/New_ATS/Tests/helloworld/helloworld_server.py +++ b/tests/New_ATS/Tests/helloworld/Python_server/helloworld_server.py @@ -5,6 +5,7 @@ import helloworld_pb2_grpc class Greeter(helloworld_pb2_grpc.GreeterServiceServicer): + # Sends a greeting by appending 'Hello ' prefix and "!!!" suffix to the name field of HelloRequest message def SayHello(self, request, context): print("Got request " + str(request)) return helloworld_pb2.HelloReply(message=f'Hello {request.name}!!!') diff --git a/tests/New_ATS/Tests/helloworld/helloworld.proto b/tests/New_ATS/Tests/helloworld/helloworld.proto index 1ebfa48c..204fa89a 100644 --- a/tests/New_ATS/Tests/helloworld/helloworld.proto +++ b/tests/New_ATS/Tests/helloworld/helloworld.proto @@ -4,7 +4,7 @@ package helloworld; // The greeting service definition. service GreeterService { - // Sends a greeting + // Sends a greeting by appending 'Hello ' prefix and "!!!" suffix to the name field of HelloRequest message rpc SayHello (HelloRequest) returns (HelloReply) {} } diff --git a/tests/New_ATS/Tests/message-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/message-oneof/Python_client/GetFeature_client.py index 59d5d4c2..3c5b0cbc 100644 --- a/tests/New_ATS/Tests/message-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/message-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,10 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Saves req_oneof's active index in res_id (either 2 or 3) +# 2) Appends '_response' to the req_name field of req_oneof and saves in res_name field of res_oneof. +# 3) Appends '_nested' to the message_a's (of req_oneof) data_a1 field and saves in corresponding message_a in res_oneof. def get_GetFeature_output(test_input): req_id = test_input.get('req_id') req_name = test_input['req_oneof'].get('req_name') diff --git a/tests/New_ATS/Tests/message-oneof/message-oneof.proto b/tests/New_ATS/Tests/message-oneof/message-oneof.proto index a1c0ad31..0bd84a05 100644 --- a/tests/New_ATS/Tests/message-oneof/message-oneof.proto +++ b/tests/New_ATS/Tests/message-oneof/message-oneof.proto @@ -3,6 +3,11 @@ syntax = "proto3"; package Greeter; service GreeterService { + + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Saves req_oneof's active index in res_id (either 2 or 3) + // 2) Appends '_response' to the req_name field of req_oneof and saves in res_name field of res_oneof. + // 3) Appends '_nested' to the message_a's (of req_oneof) data_a1 field and saves in corresponding message_a in res_oneof. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/Tests/multiple-field-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/multiple-field-oneof/Python_client/GetFeature_client.py index 03331790..dfc08cc2 100644 --- a/tests/New_ATS/Tests/multiple-field-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/multiple-field-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,11 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. +# 2) Increments all the integer and decimal fields of req_oneof by 1 and saves in corresponding res_oneof fields of 'res' message. +# 3) Appends '_response' to the string fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. +# 4) Does a NOT operation on the boolean fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. def get_GetFeature_output(test_input): req_latitude = test_input.get('req_latitude') req_name = test_input['req_oneof'].get('req_name') diff --git a/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto b/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto index 050c79e4..4d6f3355 100644 --- a/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto +++ b/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto @@ -3,6 +3,12 @@ syntax = "proto3"; package Greeter; service GreeterService { + + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. + // 2) Increments all the integer and decimal fields of req_oneof by 1 and saves in corresponding res_oneof fields of 'res' message. + // 3) Appends '_response' to the string fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. + // 4) Does a NOT operation on the boolean fields of req_oneof and saves in corresponding res_oneof fields of 'res' message. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/Tests/nested-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/nested-oneof/Python_client/GetFeature_client.py index b7b74d14..20da4625 100644 --- a/tests/New_ATS/Tests/nested-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/nested-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,11 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Increments req_id by 1 and saves in res_id of 'res' message. +# 2) Increments req_price of req_oneof by 1 and saves in res_oneof's res_price field of 'res' message. +# 3) Appends '_response' to the anotherField field of message_a in req_oneof and saves in corresponding res_oneof's message_a field of 'res' message. +# 4) Appends '_response' to the data_a1 and data_a2 fields of oneof_a field of message_a field in req_oneof and saves in corresponding res_oneof's message_a field of 'res' message. def get_GetFeature_output(test_input): req_id = test_input.get('req_id') req_price = data_a1 = data_a2 = anotherField = None diff --git a/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto b/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto index f171e551..44802a69 100644 --- a/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto +++ b/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto @@ -3,6 +3,12 @@ syntax = "proto3"; package Greeter; service GreeterService { + + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Increments req_id by 1 and saves in res_id of 'res' message. + // 2) Increments req_price of req_oneof by 1 and saves in res_oneof's res_price field of 'res' message. + // 3) Appends '_response' to the anotherField field of message_a in req_oneof and saves in corresponding res_oneof's message_a field of 'res' message. + // 4) Appends '_response' to the data_a1 and data_a2 fields of oneof_a field of message_a field in req_oneof and saves in corresponding res_oneof's message_a field of 'res' message. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/Tests/oneof-streaming/Impl/Run Service.vi b/tests/New_ATS/Tests/oneof-streaming/Impl/Run Service.vi new file mode 100644 index 00000000..0d20f460 Binary files /dev/null and b/tests/New_ATS/Tests/oneof-streaming/Impl/Run Service.vi differ diff --git a/tests/New_ATS/Tests/oneof-streaming/Impl/Start Sync.vi b/tests/New_ATS/Tests/oneof-streaming/Impl/Start Sync.vi new file mode 100644 index 00000000..81aea962 Binary files /dev/null and b/tests/New_ATS/Tests/oneof-streaming/Impl/Start Sync.vi differ diff --git a/tests/New_ATS/Tests/oneof-streaming/Python_client/BidirectionalStreamingMethod_client.py b/tests/New_ATS/Tests/oneof-streaming/Python_client/BidirectionalStreamingMethod_client.py new file mode 100644 index 00000000..0d3e9fae --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/Python_client/BidirectionalStreamingMethod_client.py @@ -0,0 +1,56 @@ +import grpc +import oneof_streaming_pb2 +import oneof_streaming_pb2_grpc +import json +import pytest +import os + +# 'BidirectionalStreamingMethod' rpc performs the following operations on the 'Request' message fields and returns one 'Response' message for each 'Request' message: +# 1) Increments age by 1 and saves in new_age of 'Response' message. +# 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. +# 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +BidirectionalStreamingMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/BidirectionalStreamingMethod.json' + +def get_BidirectionalStreamingMethod_output(test_input): + output = [] + + with grpc.insecure_channel('localhost:50051') as channel: + stub = oneof_streaming_pb2_grpc.GreeterServiceStub(channel) + + def generate_requests(): + for request_data in test_input: + yield oneof_streaming_pb2.Request( + age=request_data['age'], + message=request_data['request_oneof'].get('message'), + request_id=request_data['request_oneof'].get('request_id') + ) + + responses = stub.BidirectionalStreamingMethod(generate_requests()) + + for response in responses: + output.append({ + "new_age": response.new_age, + "response_oneof": { + "result": response.result + } + }) + + return output + +@pytest.mark.parametrize('testcase', read_json(BidirectionalStreamingMethod_json_file_path)) +def test_BidirectionalStreamingMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_BidirectionalStreamingMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_BidirectionalStreamingMethod_output([ + { "age": 2, "request_oneof": { "message": "Hello, World!" } }, + { "age": 2, "request_oneof": { "message": "Hello, World!" } } + ]) + print(res) diff --git a/tests/New_ATS/Tests/oneof-streaming/Python_client/ClientStreamingMethod_client.py b/tests/New_ATS/Tests/oneof-streaming/Python_client/ClientStreamingMethod_client.py new file mode 100644 index 00000000..09c71c3d --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/Python_client/ClientStreamingMethod_client.py @@ -0,0 +1,68 @@ +import grpc +import oneof_streaming_pb2 +import oneof_streaming_pb2_grpc +import json +import pytest +import os + +# 'ClientStreamingMethod' rpc performs the following operations on the 'Request' message fields returns one single 'Response' message: +# 1) Sums up the values of age field in all 'Request' messages and saves the sum in new_age of 'Response' message. +# 2) Increments request_id of request_oneof of the last 'Request' message by 1 and saves in response_oneof's response_id field of 'Response' message. +# 3) Appends '_response' to the message field of request_oneof of the last 'Request' message and saves in result field of response_oneof of 'Response' message. +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +ClientStreamingMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/ClientStreamingMethod.json' + +def get_ClientStreamingMethod_output(test_input): + response_dict = None + request_list = [] + for request in test_input: + request_list.append(oneof_streaming_pb2.Request( + age=request['age'], + message=request['request_oneof'].get('message'), + request_id=request['request_oneof'].get('request_id') + ) + ) + + with grpc.insecure_channel('localhost:50051') as channel: + + stub = oneof_streaming_pb2_grpc.GreeterServiceStub(channel) + + response = stub.ClientStreamingMethod(iter(request_list)) + + response_dict = { + "new_age":response.new_age, + "response_oneof":{} + } + if response.HasField('result'): + response_dict['response_oneof']['result'] = response.result + if response.HasField('response_id'): + response_dict['response_oneof']['response_id'] = response.response_id + + return response_dict + +@pytest.mark.parametrize('testcase', read_json(ClientStreamingMethod_json_file_path)) +def test_ClientStreamingMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_ClientStreamingMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_ClientStreamingMethod_output([ + { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + }, + { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + } + ]) + print(res) diff --git a/tests/New_ATS/Tests/oneof-streaming/Python_client/ServerStreamingMethod_client.py b/tests/New_ATS/Tests/oneof-streaming/Python_client/ServerStreamingMethod_client.py new file mode 100644 index 00000000..25278714 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/Python_client/ServerStreamingMethod_client.py @@ -0,0 +1,56 @@ +import grpc +import oneof_streaming_pb2 +import oneof_streaming_pb2_grpc +import json +import pytest +import os + +# 'ServerStreamingMethod' rpc performs the following operations on the 'Request' message fields and streams 'age' number of identical 'Response' messages: +# 1) Increments age by 1 and saves in new_age of 'Response' message. +# 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. +# 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. +def get_ServerStreamingMethod_output(test_input): + age = test_input['age'] + message = test_input['request_oneof'].get('message') + request_id=test_input['request_oneof'].get('request_id') + + response_list = [] + with grpc.insecure_channel('localhost:50051') as channel: + stub = oneof_streaming_pb2_grpc.GreeterServiceStub(channel) + request = oneof_streaming_pb2.Request(age=age, message=message, request_id=request_id) + response_stream = stub.ServerStreamingMethod(request) + + for response in response_stream: + response_dict = { + 'new_age': response.new_age, + 'response_oneof': {} + } + if response.HasField('result'): + response_dict['response_oneof']['result'] = response.result + if response.HasField('response_id'): + response_dict['response_oneof']['response_id'] = response.response_id + response_list.append(response_dict) + + return response_list + +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +ServerStreamingMethod_json_file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'testcases', 'ServerStreamingMethod.json') + +@pytest.mark.parametrize('testcase', read_json(ServerStreamingMethod_json_file_path)) +def test_ServerStreamingMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_ServerStreamingMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_ServerStreamingMethod_output({ + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + }) + print(res) diff --git a/tests/New_ATS/Tests/oneof-streaming/Python_client/UnaryMethod_client.py b/tests/New_ATS/Tests/oneof-streaming/Python_client/UnaryMethod_client.py new file mode 100644 index 00000000..d445f9e5 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/Python_client/UnaryMethod_client.py @@ -0,0 +1,54 @@ +import grpc +import oneof_streaming_pb2 +import oneof_streaming_pb2_grpc +import json +import pytest +import os + +# 'UnaryMethod' rpc performs the following operations on the 'Request' message fields: +# 1) Increments age by 1 and saves in new_age of 'Response' message. +# 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. +# 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. +def get_UnaryMethod_output(test_input): + age = test_input['age'] + message = test_input['request_oneof'].get('message') + request_id = test_input['request_oneof'].get('request_id') + + with grpc.insecure_channel('localhost:50051') as channel: + stub = oneof_streaming_pb2_grpc.GreeterServiceStub(channel) + request = oneof_streaming_pb2.Request(age=age, message=message, request_id=request_id) + response = stub.UnaryMethod(request) + + response_dict = { + 'new_age': response.new_age, + 'response_oneof': {} + } + + if response.HasField('result'): + response_dict['response_oneof']['result'] = response.result + if response.HasField('response_id'): + response_dict['response_oneof']['response_id'] = response.response_id + + return response_dict + +def read_json(filepath): + with open(filepath, 'r') as file: + test_data = json.load(file) + return test_data + +UnaryMethod_json_file_path = f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/testcases/UnaryMethod.json' + +@pytest.mark.parametrize('testcase', read_json(UnaryMethod_json_file_path)) +def test_UnaryMethod(testcase): + test_input = testcase['input'] + expected = testcase['output'] + assert get_UnaryMethod_output(test_input) == expected + +if __name__ == "__main__": + res = get_UnaryMethod_output({ + "age": 25, + "request_oneof": { + "message": "Hello, World!" + } + }) + print(res) diff --git a/tests/New_ATS/Tests/oneof-streaming/Python_server/oneof-streaming_server.py b/tests/New_ATS/Tests/oneof-streaming/Python_server/oneof-streaming_server.py new file mode 100644 index 00000000..aeaac234 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/Python_server/oneof-streaming_server.py @@ -0,0 +1,100 @@ +import grpc +from concurrent import futures +import time +import oneof_streaming_pb2 +import oneof_streaming_pb2_grpc + +class GreeterService(oneof_streaming_pb2_grpc.GreeterServiceServicer): + + # 'UnaryMethod' rpc performs the following operations on the 'Request' message fields: + # 1) Increments age by 1 and saves in new_age of 'Response' message. + # 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. + # 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. + def UnaryMethod(self, request, context): + age = request.age + message = request_id = None + if request.HasField("message"): + message = request.message + if request.HasField("request_id"): + request_id = request.request_id + new_age = age + 1 + result = f"{message}_response" if message else None + response = oneof_streaming_pb2.Response(new_age=new_age, result=result, response_id=request_id) + return response + + + # 'ServerStreamingMethod' rpc performs the following operations on the 'Request' message fields and streams 'age' number of identical 'Response' messages: + # 1) Increments age by 1 and saves in new_age of 'Response' message. + # 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. + # 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. + def ServerStreamingMethod(self, request, context): + age = request.age + message = request_id = None + if request.HasField("message"): + message = request.message + if request.HasField("request_id"): + request_id = request.request_id + + for _ in range(age): + new_age = age + 1 + result = f"{message}_response" if message else None + response_id = request_id+1 if request_id else None + response = oneof_streaming_pb2.Response(new_age=new_age, result=result, response_id=response_id) + yield response + + + # 'ClientStreamingMethod' rpc performs the following operations on the 'Request' message fields returns one single 'Response' message: + # 1) Sums up the values of age field in all 'Request' messages and saves the sum in new_age of 'Response' message. + # 2) Increments request_id of request_oneof of the last 'Request' message by 1 and saves in response_oneof's response_id field of 'Response' message. + # 3) Appends '_response' to the message field of request_oneof of the last 'Request' message and saves in result field of response_oneof of 'Response' message. + def ClientStreamingMethod(self, request_iterator, context): + age_sum = 0 + last_message = None + + for request in request_iterator: + age_sum += request.age + last_message = request + + new_age=age_sum + message = request_id = None + if last_message.HasField("message"): + message = last_message.message + if last_message.HasField("request_id"): + request_id = last_message.request_id + + result = f"{message}_response" if message else None + response_id = request_id+1 if request_id else None + + response = oneof_streaming_pb2.Response(new_age=new_age, result=result, response_id=response_id) + return response + + + # 'BidirectionalStreamingMethod' rpc performs the following operations on the 'Request' message fields and returns one 'Response' message for each 'Request' message: + # 1) Increments age by 1 and saves in new_age of 'Response' message. + # 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. + # 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. + def BidirectionalStreamingMethod(self, request_iterator, context): + for request in request_iterator: + new_age = request.age + 1 + message = request_id = None + if request.HasField("message"): + message = request.message + if request.HasField("request_id"): + request_id = request.request_id + + result = f"{message}_response" if message else None + response_id = request_id+1 if request_id else None + + response = oneof_streaming_pb2.Response(new_age=new_age, result=result, response_id=response_id) + yield response + +def serve(): + server = grpc.server(futures.ThreadPoolExecutor(max_workers=2)) + oneof_streaming_pb2_grpc.add_GreeterServiceServicer_to_server(GreeterService(), server) + server.add_insecure_port('[::]:50051') + print("Server started on port 50051") + server.start() + server.wait_for_termination() + +if __name__ == '__main__': + serve() diff --git a/tests/New_ATS/Tests/oneof-streaming/oneof-streaming.proto b/tests/New_ATS/Tests/oneof-streaming/oneof-streaming.proto new file mode 100644 index 00000000..8f704248 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/oneof-streaming.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +service GreeterService { + + // 'UnaryMethod' rpc performs the following operations on the 'Request' message fields: + // 1) Increments age by 1 and saves in new_age of 'Response' message. + // 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. + // 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. + rpc UnaryMethod(Request) returns (Response); + + // 'ServerStreamingMethod' rpc performs the following operations on the 'Request' message fields and streams 'age' number of identical 'Response' messages: + // 1) Increments age by 1 and saves in new_age of 'Response' message. + // 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. + // 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. + rpc ServerStreamingMethod(Request) returns (stream Response); + + // 'ClientStreamingMethod' rpc performs the following operations on the 'Request' message fields returns one single 'Response' message: + // 1) Sums up the values of age field in all 'Request' messages and saves the sum in new_age of 'Response' message. + // 2) Increments request_id of request_oneof of the last 'Request' message by 1 and saves in response_oneof's response_id field of 'Response' message. + // 3) Appends '_response' to the message field of request_oneof of the last 'Request' message and saves in result field of response_oneof of 'Response' message. + rpc ClientStreamingMethod(stream Request) returns (Response); + + // 'BidirectionalStreamingMethod' rpc performs the following operations on the 'Request' message fields and returns one 'Response' message for each 'Request' message: + // 1) Increments age by 1 and saves in new_age of 'Response' message. + // 2) Increments request_id of request_oneof by 1 and saves in response_oneof's response_id field of 'Response' message. + // 3) Appends '_response' to the message field of request_oneof and saves in result field of response_oneof of 'Response' message. + rpc BidirectionalStreamingMethod(stream Request) returns (stream Response); +} + +message Request { + int32 age = 1; + oneof request_oneof { + string message = 2; + int32 request_id = 3; + } +} + +message Response { + int32 new_age = 1; + oneof response_oneof { + string result = 2; + int32 response_id = 3; + } +} \ No newline at end of file diff --git a/tests/New_ATS/Tests/oneof-streaming/testcases/BidirectionalStreamingMethod.json b/tests/New_ATS/Tests/oneof-streaming/testcases/BidirectionalStreamingMethod.json new file mode 100644 index 00000000..170498e3 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/testcases/BidirectionalStreamingMethod.json @@ -0,0 +1,656 @@ +[ + { + "input": [ + { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + }, + { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + } + ], + "output": [ + { + "new_age": 3, + "response_oneof": { + "result": "Hello, World!_response" + } + }, + { + "new_age": 3, + "response_oneof": { + "result": "Hello, World!_response" + } + } + ] + }, + { + "input": [ + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + } + ], + "output": [ + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + } + ] + }, + { + "input": [ + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + } + ], + "output": [ + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + } + ] + }, + { + "input": [ + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + } + ], + "output": [ + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + } + ] + }, + { + "input": [ + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + } + ], + "output": [ + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + } + ] + } +] diff --git a/tests/New_ATS/Tests/oneof-streaming/testcases/ClientStreamingMethod.json b/tests/New_ATS/Tests/oneof-streaming/testcases/ClientStreamingMethod.json new file mode 100644 index 00000000..5bfa40e1 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/testcases/ClientStreamingMethod.json @@ -0,0 +1,364 @@ +[ + { + "input": [ + { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + }, + { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + } + ], + "output": { + "new_age": 4, + "response_oneof": { + "result": "Hello, World!_response" + } + } + }, + { + "input": [ + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + } + ], + "output": { + "new_age": 25, + "response_oneof": { + "result": "Good morning_response" + } + } + }, + { + "input": [ + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + } + ], + "output": { + "new_age": 100, + "response_oneof": { + "result": "Hi there_response" + } + } + }, + { + "input": [ + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + } + ], + "output": { + "new_age": 225, + "response_oneof": { + "result": "How are you?_response" + } + } + }, + { + "input": [ + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + } + ], + "output": { + "new_age": 400, + "response_oneof": { + "result": "Greetings!_response" + } + } + } +] diff --git a/tests/New_ATS/Tests/oneof-streaming/testcases/ServerStreamingMethod.json b/tests/New_ATS/Tests/oneof-streaming/testcases/ServerStreamingMethod.json new file mode 100644 index 00000000..7f0f2759 --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/testcases/ServerStreamingMethod.json @@ -0,0 +1,364 @@ +[ + { + "input": { + "age": 2, + "request_oneof": { + "message": "Hello, World!" + } + }, + "output": [ + { + "new_age": 3, + "response_oneof": { + "result": "Hello, World!_response" + } + }, + { + "new_age": 3, + "response_oneof": { + "result": "Hello, World!_response" + } + } + ] + }, + { + "input": { + "age": 5, + "request_oneof": { + "message": "Good morning" + } + }, + "output": [ + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + }, + { + "new_age": 6, + "response_oneof": { + "result": "Good morning_response" + } + } + ] + }, + { + "input": { + "age": 10, + "request_oneof": { + "message": "Hi there" + } + }, + "output": [ + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + }, + { + "new_age": 11, + "response_oneof": { + "result": "Hi there_response" + } + } + ] + }, + { + "input": { + "age": 15, + "request_oneof": { + "message": "How are you?" + } + }, + "output": [ + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + }, + { + "new_age": 16, + "response_oneof": { + "result": "How are you?_response" + } + } + ] + }, + { + "input": { + "age": 20, + "request_oneof": { + "message": "Greetings!" + } + }, + "output": [ + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + }, + { + "new_age": 21, + "response_oneof": { + "result": "Greetings!_response" + } + } + ] + } +] diff --git a/tests/New_ATS/Tests/oneof-streaming/testcases/UnaryMethod.json b/tests/New_ATS/Tests/oneof-streaming/testcases/UnaryMethod.json new file mode 100644 index 00000000..57921ccf --- /dev/null +++ b/tests/New_ATS/Tests/oneof-streaming/testcases/UnaryMethod.json @@ -0,0 +1,128 @@ +[ + { + "input": { + "age": 25, + "request_oneof": { + "message": "Hello, World!" + } + }, + "output": { + "new_age": 26, + "response_oneof": { + "result": "Hello, World!_response" + } + } + }, + { + "input": { + "age": 18, + "request_oneof": { + "message": "Good morning" + } + }, + "output": { + "new_age": 19, + "response_oneof": { + "result": "Good morning_response" + } + } + }, + { + "input": { + "age": 40, + "request_oneof": { + "request_id": 123 + } + }, + "output": { + "new_age": 41, + "response_oneof": { + "response_id": 124 + } + } + }, + { + "input": { + "age": 60, + "request_oneof": { + "request_id": 456 + } + }, + "output": { + "new_age": 61, + "response_oneof": { + "response_id": 457 + } + } + }, + { + "input": { + "age": 30, + "request_oneof": { + "message": "Testing" + } + }, + "output": { + "new_age": 31, + "response_oneof": { + "result": "Testing_response" + } + } + }, + { + "input": { + "age": 22, + "request_oneof": { + "request_id": 789 + } + }, + "output": { + "new_age": 23, + "response_oneof": { + "response_id": 790 + } + } + }, + { + "input": { + "age": 35, + "request_oneof": { + "message": "Greetings" + } + }, + "output": { + "new_age": 36, + "response_oneof": { + "result": "Greetings_response" + } + } + }, + { + "input": { + "age": 50, + "request_oneof": { + "request_id": 1000 + } + }, + "output": { + "new_age": 51, + "response_oneof": { + "response_id": 1001 + } + } + }, + { + "input": { + "age": 28, + "request_oneof": { + "message": "How are you?" + } + }, + "output": { + "new_age": 29, + "response_oneof": { + "result": "How are you?_response" + } + } + } +] diff --git a/tests/New_ATS/Tests/routeguide/Python_client/Getfeature_client.py b/tests/New_ATS/Tests/routeguide/Python_client/Getfeature_client.py index 6ddcf6e2..2b88a482 100644 --- a/tests/New_ATS/Tests/routeguide/Python_client/Getfeature_client.py +++ b/tests/New_ATS/Tests/routeguide/Python_client/Getfeature_client.py @@ -5,6 +5,13 @@ import pytest import os +# A simple RPC. +# +# Obtains the feature at a given position. +# +# A feature with an empty name is returned if there's no feature at the given +# position. + def read_json(filepath): with open(filepath, 'r') as file: test_data = json.load(file) diff --git a/tests/New_ATS/Tests/routeguide/Python_client/ListFeatures_client.py b/tests/New_ATS/Tests/routeguide/Python_client/ListFeatures_client.py index 2e3bae34..33b3aee2 100644 --- a/tests/New_ATS/Tests/routeguide/Python_client/ListFeatures_client.py +++ b/tests/New_ATS/Tests/routeguide/Python_client/ListFeatures_client.py @@ -5,6 +5,13 @@ import pytest import os +# A server-to-client streaming RPC. +# +# Obtains the Features available within the given Rectangle. Results are +# streamed rather than returned at once (e.g. in a response message with a +# repeated field), as the rectangle may cover a large area and contain a +# huge number of features. + def read_json(filepath): with open(filepath, 'r') as file: test_data = json.load(file) diff --git a/tests/New_ATS/Tests/routeguide/Python_client/RecordRoute_client.py b/tests/New_ATS/Tests/routeguide/Python_client/RecordRoute_client.py index 7602d5fd..de04fff5 100644 --- a/tests/New_ATS/Tests/routeguide/Python_client/RecordRoute_client.py +++ b/tests/New_ATS/Tests/routeguide/Python_client/RecordRoute_client.py @@ -5,6 +5,11 @@ import pytest import os +# A client-to-server streaming RPC. +# +# Accepts a stream of Points on a route being traversed, returning a +# RouteSummary when traversal is completed. + def read_json(filepath): with open(filepath, 'r') as file: test_data = json.load(file) diff --git a/tests/New_ATS/Tests/routeguide/Python_client/RouteChat_client.py b/tests/New_ATS/Tests/routeguide/Python_client/RouteChat_client.py index a2a44960..0aeb56d1 100644 --- a/tests/New_ATS/Tests/routeguide/Python_client/RouteChat_client.py +++ b/tests/New_ATS/Tests/routeguide/Python_client/RouteChat_client.py @@ -5,6 +5,11 @@ import pytest import os +# A Bidirectional streaming RPC. +# +# Accepts a stream of RouteNotes sent while a route is being traversed, +# while receiving other RouteNotes (e.g. from other users). + def read_json(filepath): with open(filepath, 'r') as file: test_data = json.load(file) diff --git a/tests/New_ATS/Tests/routeguide/routeguide.proto b/tests/New_ATS/Tests/routeguide/routeguide.proto index 055ea7ca..aab861c9 100644 --- a/tests/New_ATS/Tests/routeguide/routeguide.proto +++ b/tests/New_ATS/Tests/routeguide/routeguide.proto @@ -2,13 +2,37 @@ syntax = "proto3"; package routeguide; -service RouteGuide{ +service RouteGuide { + // A simple RPC. + // + // Obtains the feature at a given position. + // + // A feature with an empty name is returned if there's no feature at the given + // position. rpc GetFeature(Point) returns (Feature) {} + + // A server-to-client streaming RPC. + // + // Obtains the Features available within the given Rectangle. Results are + // streamed rather than returned at once (e.g. in a response message with a + // repeated field), as the rectangle may cover a large area and contain a + // huge number of features. rpc ListFeatures(Rectangle) returns (stream Feature) {} + + // A client-to-server streaming RPC. + // + // Accepts a stream of Points on a route being traversed, returning a + // RouteSummary when traversal is completed. rpc RecordRoute(stream Point) returns (RouteSummary) {} + + // A Bidirectional streaming RPC. + // + // Accepts a stream of RouteNotes sent while a route is being traversed, + // while receiving other RouteNotes (e.g. from other users). rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} } + message Point { int32 latitude = 1; int32 longitude = 2; diff --git a/tests/New_ATS/Tests/sibling-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/sibling-oneof/Python_client/GetFeature_client.py index 8b8889df..949823ba 100644 --- a/tests/New_ATS/Tests/sibling-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/sibling-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,11 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. +# 2) Increments req_id of req_oneof by 1 and saves in res_oneof's res_id field of 'res' message. +# 3) Appends '_response' to the req_name field of req_oneof and save in res_name field of res_oneof of 'res' message. +# 4) Appends '_response' to the data_a1 field of message_a field and saves in corresponding message_a field of 'res' message. def get_GetFeature_output(test_input): req_latitude = test_input.get('req_latitude') message_a = req_id = req_name = None diff --git a/tests/New_ATS/Tests/sibling-oneof/sibling-oneof.proto b/tests/New_ATS/Tests/sibling-oneof/sibling-oneof.proto index 5f044a26..1224f8a7 100644 --- a/tests/New_ATS/Tests/sibling-oneof/sibling-oneof.proto +++ b/tests/New_ATS/Tests/sibling-oneof/sibling-oneof.proto @@ -3,6 +3,12 @@ syntax = "proto3"; package Greeter; service GreeterService { + + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. + // 2) Increments req_id of req_oneof by 1 and saves in res_oneof's res_id field of 'res' message. + // 3) Appends '_response' to the req_name field of req_oneof and save in res_name field of res_oneof of 'res' message. + // 4) Appends '_response' to the data_a1 field of message_a field and saves in corresponding message_a field of 'res' message. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/Tests/simple-oneof/Python_client/GetFeature_client.py b/tests/New_ATS/Tests/simple-oneof/Python_client/GetFeature_client.py index 6c1c67dc..02370d09 100644 --- a/tests/New_ATS/Tests/simple-oneof/Python_client/GetFeature_client.py +++ b/tests/New_ATS/Tests/simple-oneof/Python_client/GetFeature_client.py @@ -5,6 +5,10 @@ import pytest import os +# 'GetFeature' rpc performs the following operations on the 'req' message fields: +# 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. +# 2) Increments req_num of req_oneof by 1 and saves in res_oneof's res_num field of 'res' message. +# 3) Appends '_response' to the req_name field of req_oneof and save in res_name field of res_oneof of 'res' message. def get_GetFeature_output(test_input): req_latitude = int(test_input.get('req_latitude')) req_name = test_input['req_oneof'].get('req_name') diff --git a/tests/New_ATS/Tests/simple-oneof/simple-oneof.proto b/tests/New_ATS/Tests/simple-oneof/simple-oneof.proto index bd615689..6c55d9b7 100644 --- a/tests/New_ATS/Tests/simple-oneof/simple-oneof.proto +++ b/tests/New_ATS/Tests/simple-oneof/simple-oneof.proto @@ -3,6 +3,11 @@ syntax = "proto3"; package Greeter; service GreeterService { + + // 'GetFeature' rpc performs the following operations on the 'req' message fields: + // 1) Increments req_latitude by 1 and saves in res_latitude of 'res' message. + // 2) Increments req_num of req_oneof by 1 and saves in res_oneof's res_num field of 'res' message. + // 3) Appends '_response' to the req_name field of req_oneof and save in res_name field of res_oneof of 'res' message. rpc GetFeature(req) returns (res) {} } diff --git a/tests/New_ATS/pylib/run_tests.py b/tests/New_ATS/pylib/run_tests.py index 8ccfce22..08dda844 100644 --- a/tests/New_ATS/pylib/run_tests.py +++ b/tests/New_ATS/pylib/run_tests.py @@ -29,13 +29,8 @@ def check_for_pre_requisites(test_config): if not test_config["lvcli_path"].exists(): raise Exception(f'LabVIEW CLI is not installed at {test_config["lvcli_path"]}') - -def generate_server(test_config): - # 1. Delete the Generated_server folder. TODO: Take a boolean in the config to say whether the build should be a clean build - if test_config['generated_server'].exists(): - shutil.rmtree(test_config['generated_server']) - - # 2. Generate the server +def call_code_generator(test_config): + # 1. Generate the server # todo: call the LabVIEW VI from LabVIEW CLI main_wrapper_vi_path = test_config['test_suite_folder'] / 'Main_CLIWrapper.vi' # subprocess.run([f'{labviewCLI_path} -OperationName RunVI', @@ -51,6 +46,14 @@ def generate_server(test_config): run_command(CLI_command) +def clean_server_generation(test_config): + # 1. Delete the Generated_server folder. + if test_config['generated_server'].exists() and test_config['clean_gen']: + shutil.rmtree(test_config['generated_server']) + + # 2. Call the code generator. + call_code_generator(test_config) + def run_test(test_config): global FAILED @@ -58,8 +61,8 @@ def run_test(test_config): check_for_pre_requisites(test_config) # 2. Generate the server - print ("Generating server code for " + test_config['test_name']) - generate_server(test_config) + print("Generating server code for " + test_config['test_name']) + clean_server_generation(test_config) # 3. Copy the 'Run Service.vi' from the Impl folder to the Generated_server folder run_service_impl_path = test_config['impl'] / 'Run Service.vi' @@ -80,8 +83,16 @@ def run_test(test_config): else: print (f"{test_config['generated_server']} not generated") - # 5. Quit LabVIEW if it is running - run_command(['taskkill', '/f', '/im', 'labview.exe']) + # 5. Generate server again if clean_gen is false + if not test_config['clean_gen']: + print("Generating server again") + call_code_generator(test_config) + + # 6. Quit LabVIEW if it is running + try: + run_command(['taskkill', '/f', '/im', 'labview.exe']) + except Exception: + pass # 6. Start Run Service.vi from command prompt by launching labview.exe form lv_folder with the following arguments: # this must be non-blocking @@ -106,17 +117,19 @@ def run_test(test_config): ]) run_command(CLI_command) - # 8. Generate python grpc classes - generate_command = ' '.join([ - f"{test_config['python_path']} -m grpc_tools.protoc", - f"--proto_path={test_config['test_folder']}", - f"--python_out={test_config['python_client_folder']}", - f"--pyi_out={test_config['python_client_folder']}", - f"--grpc_python_out={test_config['python_client_folder']}", - f"{test_config['test_name']}.proto" - ]) - print ("Compiling proto file") - run_command(generate_command) + # 8. Generate python client and server grpc classes + for path in ['python_client_folder', 'python_server_folder']: + if os.path.exists(test_config[f'{path}']): + generate_command = ' '.join([ + f"{test_config['python_path']} -m grpc_tools.protoc", + f"--proto_path={test_config['test_folder']}", + f"--python_out={test_config[f'{path}']}", + f"--pyi_out={test_config[f'{path}']}", + f"--grpc_python_out={test_config[f'{path}']}", + f"{test_config['test_name']}.proto" + ]) + print ("Compiling proto file for "+path.split('_')[1]) + run_command(generate_command) # 9. Call the TestServer() from test_folder/test_name_client.py and get the return value print(f"Running tests for all rpc's in {test_config['test_name']}") @@ -168,6 +181,7 @@ def main(): test_config['tests_folder'] = test_config['test_suite_folder'] / 'Tests' test_config['python_path'] = test_config['test_suite_folder'] / 'venv' / "Scripts" / "python.exe" tests_folder = test_config['tests_folder'] + test_config['clean_gen'] = test['clean_gen'] # locals for test_name in test['name']: print(f'\nRunning test for "{test_name}"...') @@ -180,6 +194,7 @@ def main(): test_config['impl'] = test_config['test_folder'] / 'Impl' test_config['gen_type'] = gen_type test_config['python_client_folder'] = test_config['test_folder'] / 'Python_client' + test_config['python_server_folder'] = test_config['test_folder'] / 'Python_server' run_test(test_config) if FAILED: raise Exception(f"{FAILED} test cases have failed. Please review the above results") diff --git a/tests/New_ATS/pylib/testlist.json b/tests/New_ATS/pylib/testlist.json index b6d27c9f..87208fdf 100644 --- a/tests/New_ATS/pylib/testlist.json +++ b/tests/New_ATS/pylib/testlist.json @@ -6,12 +6,16 @@ "enum-oneof", "message-oneof", "multiple-field-oneof", + "all-datatypes-oneof", "nested-oneof", "sibling-oneof", - "simple-oneof" + "simple-oneof", + "oneof-streaming", + "enum-streaming" ], "gen_type": "0", "labview_version": "2019", - "labview_bitness": "32" + "labview_bitness": "32", + "clean_gen": true } ]