Skip to content

Commit 0bea11a

Browse files
authored
Merge pull request #68 from awslabs/FB-ConcurrentTests
Resource prefix to allow concurrent test runs
2 parents 5990e2c + ddc81bb commit 0bea11a

File tree

21 files changed

+337
-178
lines changed

21 files changed

+337
-178
lines changed

aws-cpp-sdk-cognitoidentity-integration-tests/IdentityPoolOperationTest.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <aws/core/client/CoreErrors.h>
3737
#include <aws/core/utils/json/JsonSerializer.h>
3838
#include <aws/core/utils/Outcome.h>
39+
#include <aws/testing/TestingEnvironment.h>
3940

4041
using namespace Aws::CognitoIdentity;
4142
using namespace Aws::CognitoIdentity::Model;
@@ -47,6 +48,11 @@ namespace
4748
{
4849
static const char* ALLOCATION_TAG = "IdentityPoolOperationTest";
4950

51+
Aws::String GetResourcePrefix()
52+
{
53+
return Aws::Testing::GetAwsResourcePrefix() + TEST_POOL_PREFIX;
54+
}
55+
5056
class IdentityPoolOperationTest : public ::testing::Test
5157
{
5258
public:
@@ -71,13 +77,15 @@ class IdentityPoolOperationTest : public ::testing::Test
7177

7278
void CleanupPreviousFailedTests()
7379
{
74-
size_t prefixLength = strlen(TEST_POOL_PREFIX);
80+
Aws::String resourcePrefix = GetResourcePrefix();
81+
82+
size_t prefixLength = resourcePrefix.length();
7583

7684
Aws::Vector<IdentityPoolShortDescription> pools = GetAllPools();
7785
for (auto& pool : pools)
7886
{
7987
// Only delete integration test pools
80-
if (pool.GetIdentityPoolName().compare(0, prefixLength, TEST_POOL_PREFIX) == 0)
88+
if (pool.GetIdentityPoolName().compare(0, prefixLength, resourcePrefix) == 0)
8189
{
8290
DeleteIdentityPoolRequest deleteIdentityPoolRequest;
8391
deleteIdentityPoolRequest.WithIdentityPoolId(pool.GetIdentityPoolId());
@@ -105,7 +113,7 @@ class IdentityPoolOperationTest : public ::testing::Test
105113
TEST_F(IdentityPoolOperationTest, TestCreateGetUpdateDeleteOperations)
106114
{
107115
std::size_t initialPoolCount = GetAllPools().size();
108-
Aws::String identityPoolName = TEST_POOL_PREFIX;
116+
Aws::String identityPoolName = GetResourcePrefix();
109117
identityPoolName += "BatCave";
110118
CreateIdentityPoolRequest createIdentityPoolRequest;
111119
createIdentityPoolRequest.WithDeveloperProviderName("BruceWayne")
@@ -163,7 +171,7 @@ TEST_F(IdentityPoolOperationTest, TestCreateGetUpdateDeleteOperations)
163171

164172
TEST_F(IdentityPoolOperationTest, TestExceptionProperlyPropgates)
165173
{
166-
Aws::String identityPoolName = TEST_POOL_PREFIX;
174+
Aws::String identityPoolName = GetResourcePrefix();
167175
identityPoolName += "Bat Cave";
168176

169177
CreateIdentityPoolRequest createIdentityPoolRequest;
@@ -180,7 +188,7 @@ TEST_F(IdentityPoolOperationTest, TestExceptionProperlyPropgates)
180188

181189
TEST_F(IdentityPoolOperationTest, TestIdentityActions)
182190
{
183-
Aws::String identityPoolName = TEST_POOL_PREFIX;
191+
Aws::String identityPoolName = GetResourcePrefix();
184192
identityPoolName += "FortressOfSolitude";
185193
CreateIdentityPoolRequest createIdentityPoolRequest;
186194
createIdentityPoolRequest.WithDeveloperProviderName("Superman")

aws-cpp-sdk-cognitoidentity-integration-tests/RunTests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616
#include <aws/external/gtest.h>
1717
#include <aws/core/Aws.h>
1818
#include <aws/testing/platform/PlatformTesting.h>
19+
#include <aws/testing/TestingEnvironment.h>
1920

2021
int main(int argc, char** argv)
2122
{
2223
Aws::SDKOptions options;
2324

2425
Aws::Testing::InitPlatformTest(options);
26+
if(argc > 1)
27+
{
28+
Aws::Testing::SetAwsResourcePrefix(argv[1]);
29+
}
2530

2631
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
2732
Aws::InitAPI(options);

aws-cpp-sdk-dynamodb-integration-tests/RunTests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616
#include <aws/external/gtest.h>
1717
#include <aws/core/Aws.h>
1818
#include <aws/testing/platform/PlatformTesting.h>
19+
#include <aws/testing/TestingEnvironment.h>
1920

2021
int main(int argc, char** argv)
2122
{
2223
Aws::SDKOptions options;
2324

2425
Aws::Testing::InitPlatformTest(options);
26+
if(argc > 1)
27+
{
28+
Aws::Testing::SetAwsResourcePrefix(argv[1]);
29+
}
2530

2631
Aws::InitAPI(options);
2732
::testing::InitGoogleTest(&argc, argv);

0 commit comments

Comments
 (0)