Skip to content

Commit

Permalink
quick test with removing uri
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 20, 2023
1 parent 5969866 commit 445da59
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions bin/mqtt5_canary/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct AppCtx
{
Allocator *allocator;
struct aws_mutex lock;
Io::Uri uri;
Aws::Crt::String uri;
uint16_t port;
const char *cacert;
const char *cert;
Expand Down Expand Up @@ -204,20 +204,19 @@ static void s_ParseOptions(int argc, char **argv, struct AppCtx &ctx, struct Aws
break;
case 0x02:
/* getopt_long() returns 0x02 (START_OF_TEXT) if a positional arg was encountered */
ctx.uri = Io::Uri(aws_byte_cursor_from_c_str(aws_cli_positional_arg), ctx.allocator);
if (!ctx.uri)
ctx.uri = Aws::Crt::String(aws_cli_positional_arg);
if (ctx.uri.empty())
{
fprintf(
stderr,
"Failed to parse uri %s with error %s\n",
aws_cli_positional_arg,
aws_error_debug_str(ctx.uri.LastError()));
"Failed to parse uri %s with error. \n",
ctx.uri.c_str());
s_Usage(1);
}
else
{
// fprintf(stderr, "Succeeded parsing uri");
fprintf(stderr, "Succeed to parse uri " PRInSTR "\n", AWS_BYTE_CURSOR_PRI(ctx.uri.GetFullUri()));
fprintf(stderr, "Succeed to parse uri %s.\n", aws_cli_positional_arg);
}
break;
default:
Expand All @@ -226,7 +225,7 @@ static void s_ParseOptions(int argc, char **argv, struct AppCtx &ctx, struct Aws
}
}

if (!ctx.uri)
if (ctx.uri.empty())
{
fprintf(stderr, "A URI for the request must be supplied.\n");
s_Usage(1);
Expand Down Expand Up @@ -306,7 +305,7 @@ static void s_AwsMqtt5CanaryAddOperationToArray(
static void s_AwsMqtt5CanaryInitWeightedOperations(AwsMqtt5CanaryTesterOptions *testerOptions)
{

s_AwsMqtt5CanaryAddOperationToArray(testerOptions, AWS_MQTT5_CANARY_OPERATION_STOP, 1);
// s_AwsMqtt5CanaryAddOperationToArray(testerOptions, AWS_MQTT5_CANARY_OPERATION_STOP, 1);
s_AwsMqtt5CanaryAddOperationToArray(testerOptions, AWS_MQTT5_CANARY_OPERATION_SUBSCRIBE, 200);
s_AwsMqtt5CanaryAddOperationToArray(testerOptions, AWS_MQTT5_CANARY_OPERATION_UNSUBSCRIBE, 200);
s_AwsMqtt5CanaryAddOperationToArray(testerOptions, AWS_MQTT5_CANARY_OPERATION_UNSUBSCRIBE_BAD, 100);
Expand Down Expand Up @@ -689,10 +688,6 @@ int main(int argc, char **argv)
testerOptions.operations = operations;

s_ParseOptions(argc, argv, appCtx, &testerOptions);
if (appCtx.uri.GetPort())
{
appCtx.port = appCtx.uri.GetPort();
}

s_Mqtt5CanaryUpdateTpsSleepTime(&testerOptions);
s_AwsMqtt5CanaryInitWeightedOperations(&testerOptions);
Expand All @@ -713,7 +708,7 @@ int main(int argc, char **argv)
/***************************************************
* TLS
***************************************************/
auto hostName = appCtx.uri.GetHostName();
auto hostName = ByteCursorFromString(appCtx.uri);
Io::TlsContextOptions tlsCtxOptions;
Io::TlsContext tlsContext;
Io::TlsConnectionOptions tlsConnectionOptions;
Expand Down

0 comments on commit 445da59

Please sign in to comment.