Skip to content

Commit 015ac51

Browse files
authored
test: Allow protocol selection in api-test app (#57)
1 parent f4fedbf commit 015ac51

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [Unreleased](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.5.2...main)
2+
3+
### Changed
4+
- Added protocol selection to the API Test App: `[--legacy | --rpc-v2]`
5+
16
## [0.5.2](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.5.1...v0.5.2)
27

38
### Changed

test/api_test_app/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The app binary name is:
1717
## Command Line Usage
1818

1919
```bash
20-
api-test-app [--auto] [--mock] [--platform] [--url <URL>] [--dbg] [--help]
20+
api-test-app [--auto] [--mock] [--platform] [--url <URL>] [--legacy | --rpc-v2] [--dbg] [--help]
2121
```
2222

2323
### Options
@@ -34,6 +34,12 @@ api-test-app [--auto] [--mock] [--platform] [--url <URL>] [--dbg] [--help]
3434
- `--url URL`
3535
Set the WebSocket endpoint to the specified URL.
3636

37+
- `--legacy`
38+
Override default protocol communication to legacy.
39+
40+
- `--rpc-v2`
41+
Override default protocol communication to JSON-RPC compliant.
42+
3743
- `--dbg`
3844
Enable debug logging.
3945

test/api_test_app/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@
3434
#include <cstdlib>
3535
#include <future>
3636
#include <ios>
37+
#include <optional>
3738
#include <unistd.h>
39+
#include <vector>
3840

3941
int main(int argc, char** argv)
4042
{
4143
auto& appConfig = GetAppConfig();
4244

4345
Firebolt::LogLevel logLevel = Firebolt::LogLevel::Notice;
4446
std::string url;
47+
std::optional<bool> legacyRPCv1;
4548

4649
for (int i = 1; i < argc; ++i)
4750
{
@@ -66,6 +69,14 @@ int main(int argc, char** argv)
6669
}
6770
url = argv[++i];
6871
}
72+
else if (std::string(argv[i]) == "--legacy")
73+
{
74+
legacyRPCv1 = true;
75+
}
76+
else if (std::string(argv[i]) == "--rpc-v2")
77+
{
78+
legacyRPCv1 = false;
79+
}
6980
else if (std::string(argv[i]) == "--dbg")
7081
{
7182
logLevel = Firebolt::LogLevel::Debug;
@@ -81,6 +92,8 @@ int main(int argc, char** argv)
8192
std::cout << " --mock Connect to a local mock server instead of the default Firebolt Demo Service" << std::endl;
8293
std::cout << " --platform Connect to the platform's Firebolt service (default if available)" << std::endl;
8394
std::cout << " --url <URL> Specify a custom URL for the Firebolt service" << std::endl;
95+
std::cout << " --legacy Use legacy communication" << std::endl;
96+
std::cout << " --rpc-v2 Use JSON-RPC compliant communication" << std::endl;
8497
std::cout << " --dbg Enable debug logging" << std::endl;
8598
std::cout << " --help Show this help message" << std::endl;
8699
/* clang-format on */
@@ -106,6 +119,10 @@ int main(int argc, char** argv)
106119
config.wsUrl = url;
107120
config.waitTime_ms = 1000;
108121
config.log.level = logLevel;
122+
if (legacyRPCv1.has_value())
123+
{
124+
config.legacyRPCv1 = legacyRPCv1.value();
125+
}
109126

110127
std::promise<bool> connectionPromise;
111128
std::once_flag connectionOnce;

0 commit comments

Comments
 (0)