Skip to content

Commit

Permalink
Integ test fixes (#353)
Browse files Browse the repository at this point in the history
* Minor fixes for integration tests
  • Loading branch information
shangabl authored Dec 12, 2022
1 parent dc9065b commit 74118a3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
7 changes: 7 additions & 0 deletions integration-tests/source/GTestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ static constexpr char FLEET_PROVISIONING_RUNTIME_CONFIG_FILE[] =
static constexpr char CLI_THING_NAME[] = "--thing-name";
static constexpr char CLI_REGION[] = "--region";
static constexpr char CLI_PORT[] = "--port";
static constexpr char CLI_LOCAL_PROXY_PATH[] = "--localproxy";
static constexpr char CLI_CLEAN_UP[] = "--clean-up";
static constexpr char CLI_SKIP_ST[] = "--skip-st";
static constexpr char CLI_HELP[] = "--help";

std::string THING_NAME;
std::string REGION = "us-east-1";
std::string PORT = "5555";
std::string LOCAL_PROXY_PATH = "/localproxy";
bool CLEAN_UP = false;
bool SKIP_FP = false;
bool SKIP_ST = false;
Expand Down Expand Up @@ -65,6 +67,7 @@ void PrintHelp()
printf("--thing-name Thing Group ARN to run the tests against\n");
printf("--region The AWS Region to run the tests. Example: us-east-1\n");
printf("--port The local port to run Local Proxy.\n");
printf("--localproxy Path to local proxy binary for Secure Tunneling tests.\n");
printf("--skip-st Skip Secure Tunneling integration tests\n");
printf(
"--clean-up (Caution) Pass this flag kill to Device Client on the devices delete the provisioned IoT "
Expand All @@ -91,6 +94,10 @@ bool parseCliArgs(int argc, char **argv)
{
PORT = argv[++i];
}
else if (currentArg == CLI_LOCAL_PROXY_PATH)
{
LOCAL_PROXY_PATH = argv[++i];
}
else if (currentArg == CLI_SKIP_ST)
{
SKIP_ST = true;
Expand Down
20 changes: 17 additions & 3 deletions integration-tests/source/IntegrationTestResourceHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <aws/iot/model/DescribeJobExecutionRequest.h>
#include <aws/iot/model/DescribeJobExecutionResult.h>
#include <aws/iot/model/DescribeThingRequest.h>
#include <aws/iot/model/DescribeThingResult.h>
#include <aws/iot/model/DetachPolicyRequest.h>
#include <aws/iot/model/DetachThingPrincipalRequest.h>
#include <aws/iot/model/ListAttachedPoliciesRequest.h>
Expand Down Expand Up @@ -299,11 +300,24 @@ void IntegrationTestResourceHandler::CloseTunnel(const string &tunnelId)
ioTSecureTunnelingClient.CloseTunnel(request);
}

std::string IntegrationTestResourceHandler::GetTargetArn(const std::string &target)
std::string IntegrationTestResourceHandler::GetTargetArn(const std::string &thingName)
{
std::string arn;

DescribeThingRequest request;
request.SetThingName(target);
return iotClient.DescribeThing(request).GetResult().GetThingArn();
request.SetThingName(thingName);

DescribeThingOutcome outcome = iotClient.DescribeThing(request);

if (!outcome.IsSuccess())
{
printf("Failed to Describe Thing: %s\n%s\n", thingName.c_str(), outcome.GetError().GetMessage().c_str());
}
else
{
arn = outcome.GetResult().GetThingArn();
}
return arn;
}
std::string IntegrationTestResourceHandler::GetResourceId(const std::string &resource)
{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/source/IntegrationTestResourceHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IntegrationTestResourceHandler
void CleanUpThingAndCert(const std::string &thingName);
std::string GetTimeStamp();
Aws::IoT::Model::JobExecutionStatus GetJobExecutionStatusWithRetry(const std::string &jobId);
std::string GetTargetArn(const std::string &target);
std::string GetTargetArn(const std::string &thingName);

protected:
Aws::IoT::IoTClient iotClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extern string THING_NAME;
extern string PORT;
extern string REGION;
extern bool SKIP_ST;
extern string LOCAL_PROXY_PATH;

const string LOCAL_PROXY_PATH = "/localproxy";
const string TEST_TUNNEL_PATH = "/test-tunnel.sh";

class TestSecureTunnelingFixture : public ::testing::Test
Expand Down Expand Up @@ -67,6 +67,7 @@ class TestSecureTunnelingFixture : public ::testing::Test
}
else
{
printf("Skipping Secure Tunneling Tests\n");
GTEST_SKIP();
}
}
Expand Down

0 comments on commit 74118a3

Please sign in to comment.