Skip to content

Commit

Permalink
Add more tests for custom client in CI
Browse files Browse the repository at this point in the history
Testing the two approaches to generate and build custom client on both Linux and Windows:
1. Build custom client along with C++ SDK by specifying ADD_CUSTOM_CLIENTS in CMake.
2. Build standalone custom client on the top of pre-installed C++ SDK by running python scripts: generate_sdks.py
  • Loading branch information
wps132230 authored Sep 30, 2019
1 parent 54a9f8d commit 0c19eb1
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 51 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,3 @@ aws-cpp-sdk-core/include/aws/core/SDKConfig.h

#nuget
*.nupkg

#Aws common runtime libs
.aws-common-runtime-libs-build/
.aws-common-runtime-libs-install/
49 changes: 49 additions & 0 deletions CI/dev-pipeline/build_custom_client_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: 0.2
phases:
build:
commands:
- export SDK_ROOT=$CODEBUILD_SRC_DIR/aws-sdk-cpp
- cd $SDK_ROOT
# Testing the first approach to build custom client as a separate package, which means you have to build and install aws-sdk-cpp first.
# Generate custom client source code under custom-service/ with API description file located at code-generation/api-description/custom-service.
- python scripts/generate_sdks.py --pathToApiDefinitions=code-generation/api-descriptions/custom-service --outputLocation custom-service --serviceName custom-service --apiVersion 2017-11-03 --namespace Custom --prepareTool --standalone

# Build and install aws-cpp-sdk-core
- mkdir -p $SDK_ROOT/build/AWSSDK
- mkdir -p $SDK_ROOT/install
- cd $SDK_ROOT/build/AWSSDK
- cmake $SDK_ROOT -DBUILD_ONLY="core" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$SDK_ROOT/install" -DBUILD_SHARED_LIBS=ON
- make -j 8
- make install

# Build custom-service
- mkdir -p $SDK_ROOT/build/custom-service
- cd $SDK_ROOT/build/custom-service
- cmake $SDK_ROOT/custom-service/aws-cpp-sdk-custom-service -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$SDK_ROOT/install" -DAWSSDK_ROOT_DIR="$SDK_ROOT/install" -DBUILD_SHARED_LIBS=ON
- make -j 8

# Build and run custom-service integration tests
- mkdir -p $SDK_ROOT/build/custom-service-integration-tests
- cd $SDK_ROOT/build/custom-service-integration-tests
- cmake $SDK_ROOT/aws-cpp-sdk-custom-service-integration-tests -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$SDK_ROOT/install;$SDK_ROOT/build/custom-service" -DAWSSDK_ROOT_DIR="$SDK_ROOT/install" -DBUILD_SHARED_LIBS=ON -DSTANDALONE=ON
- make -j 8
- $SDK_ROOT/build/custom-service-integration-tests/aws-cpp-sdk-custom-service-integration-tests

# Testing the second approach to build custom client along with AWS C++ SDK, which means we will build everything altogether at the same time.
# Copy the c2j model to code-generation/api-descriptions
- cp $SDK_ROOT/code-generation/api-descriptions/custom-service/custom-service-2017-11-03.normal.json $SDK_ROOT/code-generation/api-descriptions/petstore-2017-11-03.normal.json

# Build and install aws-cpp-sdk-core and aws-cpp-sdk-petstore
- mkdir -p $SDK_ROOT/build_all
- mkdir -p $SDK_ROOT/install_all
- cd $SDK_ROOT/build_all
- cmake $SDK_ROOT -DBUILD_ONLY=core -DADD_CUSTOM_CLIENTS="serviceName=petstore, version=2017-11-03" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SDK_ROOT/install_all -DBUILD_SHARED_LIBS=ON
- make -j 8
- make install

# Build and run petstore integration tests
- mkdir -p $SDK_ROOT/build_tests
- cd $SDK_ROOT/build_tests
- cmake $SDK_ROOT/aws-cpp-sdk-custom-service-integration-tests -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$SDK_ROOT/install_all" -DAWSSDK_ROOT_DIR="$SDK_ROOT/install_all" -DBUILD_SHARED_LIBS=ON -DSTANDALONE=OFF
- make -j 8
- $SDK_ROOT/build_tests/aws-cpp-sdk-custom-service-integration-tests
50 changes: 50 additions & 0 deletions CI/dev-pipeline/build_custom_client_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 0.2
phases:
build:
commands:
- $SDK_ROOT="$Env:CODEBUILD_SRC_DIR/aws-sdk-cpp"
- cd $SDK_ROOT
# Testing the first approach to build custom client as a separate package, which means you have to build and install aws-sdk-cpp first.
# Generate custom client source code under custom-service/ with API description file located at code-generation/api-description/custom-service.
- python scripts/generate_sdks.py --pathToApiDefinitions=code-generation/api-descriptions/custom-service --outputLocation custom-service --serviceName custom-service --apiVersion 2017-11-03 --namespace Custom --prepareTool --standalone

# Build and install aws-cpp-sdk-core
- mkdir -p $SDK_ROOT/build/AWSSDK
- mkdir -p $SDK_ROOT/install
- cd $SDK_ROOT/build/AWSSDK
- cmake $SDK_ROOT -DBUILD_ONLY="core" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$SDK_ROOT/install" -DBUILD_SHARED_LIBS=ON
- MSBuild.exe ALL_BUILD.vcxproj -p:Configuration=Debug -m
- MSBuild.exe INSTALL.vcxproj -p:Configuration=Debug

# Build custom-service
- mkdir -p $SDK_ROOT/build/custom-service
- cd $SDK_ROOT/build/custom-service
- cmake $SDK_ROOT/custom-service/aws-cpp-sdk-custom-service -DCMAKE_PREFIX_PATH="$SDK_ROOT/install" -DAWSSDK_ROOT_DIR="$SDK_ROOT/install" -DCMAKE_INSTALL_PREFIX="$SDK_ROOT/install" -DBUILD_SHARED_LIBS=ON -DUSE_WINDOWS_DLL_SEMANTICS=ON
- MSBuild.exe ALL_BUILD.vcxproj -p:Configuration=Debug -m
- MSBuild.exe INSTALL.vcxproj -p:Configuration=Debug

# Build and run custom-service integration tests
- mkdir -p $SDK_ROOT/build/custom-service-integration-tests
- cd $SDK_ROOT/build/custom-service-integration-tests
- cmake $SDK_ROOT/aws-cpp-sdk-custom-service-integration-tests -DCMAKE_PREFIX_PATH="$SDK_ROOT/install" -DAWSSDK_ROOT_DIR="$SDK_ROOT/install" -DBUILD_SHARED_LIBS=ON -DSTANDALONE=ON
- MSBuild.exe ALL_BUILD.vcxproj -p:Configuration=Debug -m
- ./Debug/aws-cpp-sdk-custom-service-integration-tests

# Testing the second approach to build custom client along with AWS C++ SDK, which means we will build everything altogether at the same time.
# Copy the c2j model to code-generation/api-descriptions
- cp $SDK_ROOT/code-generation/api-descriptions/custom-service/custom-service-2017-11-03.normal.json $SDK_ROOT/code-generation/api-descriptions/petstore-2017-11-03.normal.json

# Build and install aws-cpp-sdk-core and aws-cpp-sdk-petstore
- mkdir -p $SDK_ROOT/build_all
- mkdir -p $SDK_ROOT/install_all
- cd $SDK_ROOT/build_all
- cmake $SDK_ROOT -DBUILD_ONLY=core -DADD_CUSTOM_CLIENTS="serviceName=petstore, version=2017-11-03" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$SDK_ROOT/install_all" -DBUILD_SHARED_LIBS=ON
- MSBuild.exe ALL_BUILD.vcxproj -p:Configuration=Debug -m
- MSBuild.exe INSTALL.vcxproj -p:Configuration=Debug

# Build and run petstore integration tests
- mkdir -p $SDK_ROOT/build_tests
- cd $SDK_ROOT/build_tests
- cmake $SDK_ROOT/aws-cpp-sdk-custom-service-integration-tests -DCMAKE_PREFIX_PATH="$SDK_ROOT/install_all" -DAWSSDK_ROOT_DIR="$SDK_ROOT/install_all" -DBUILD_SHARED_LIBS=ON -DSTANDALONE=OFF
- MSBuild.exe ALL_BUILD.vcxproj -p:Configuration=Debug -m
- ./Debug/aws-cpp-sdk-custom-service-integration-tests.exe
20 changes: 15 additions & 5 deletions aws-cpp-sdk-custom-service-integration-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#
# Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
#
# http://aws.amazon.com/apache2.0
#
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
Expand All @@ -15,11 +15,19 @@

cmake_minimum_required (VERSION 3.1)

option(STANDALONE "If enabled, the integration tests will be configured for a standalone custom client." ON)
if(STANDALONE)
add_definitions(-DSTANDALONE)
set(CUSTOME_SERVICE "custom-service")
else()
set(CUSTOME_SERVICE "petstore")
endif()

project(aws-cpp-sdk-custom-service-integration-tests)

find_package(AWSSDK REQUIRED COMPONENTS core)
find_package(testing-resources)
find_package(aws-cpp-sdk-custom-service)
find_package(aws-cpp-sdk-${CUSTOME_SERVICE})

# Headers are included in the source so that they show up in Visual Studio.
# They are included elsewhere for consistency.
Expand All @@ -28,6 +36,8 @@ file(GLOB AWS_CUSTOM_SERVICE_INTEGRATION_TESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/

if(MSVC AND BUILD_SHARED_LIBS)
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1)
list(APPEND LINKING_LIBRARIES ${CUSTOME_SERVICE} testing-resources)
AWSSDK_CPY_DYN_LIBS(LINKING_LIBRARIES "" ${CMAKE_CURRENT_BINARY_DIR}/Debug)
endif()

enable_testing()
Expand All @@ -41,4 +51,4 @@ endif()
set_compiler_flags(${PROJECT_NAME})
set_compiler_warnings(${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} ${AWSSDK_LINK_LIBRARIES} aws-cpp-sdk-custom-service testing-resources)
target_link_libraries(${PROJECT_NAME} aws-cpp-sdk-${CUSTOME_SERVICE} testing-resources)
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
#include <aws/external/gtest.h>
#include <aws/core/utils/Outcome.h>
#include <aws/core/auth/AWSAuthSignerProvider.h>
#if STANDALONE
#include <aws/custom-service/PetStoreClient.h>
#include <aws/custom-service/model/CreatePetRequest.h>
#include <aws/custom-service/model/GetPetRequest.h>
#include <aws/custom-service/model/GetPetsRequest.h>

using namespace Aws::Auth;
using namespace Custom::PetStore;
using namespace Custom::PetStore::Model;
#else
#include <aws/petstore/PetStoreClient.h>
#include <aws/petstore/model/CreatePetRequest.h>
#include <aws/petstore/model/GetPetRequest.h>
#include <aws/petstore/model/GetPetsRequest.h>

using namespace Aws::PetStore;
using namespace Aws::PetStore::Model;
#endif

using namespace Aws::Auth;

namespace
{
Expand Down
33 changes: 18 additions & 15 deletions cmake/AWSSDKConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#
# Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
#
# http://aws.amazon.com/apache2.0
#
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
Expand All @@ -25,7 +25,7 @@

# The libraries will all be in <prefix>/lib/<platform_prefix> dir
# The binaries will all be in <prefix>/bin/<platform_prefix> dir
# The archives will all be in <prefix>/lib/<platform_prefix> dir if target is shared,
# The archives will all be in <prefix>/lib/<platform_prefix> dir if target is shared,
# otherwise will be in <prefix>/bin/<platform_prefix> dir.

# Platfrom_prefix is determined on compile time nbu option SIMPLE_INSTALL
Expand Down Expand Up @@ -129,7 +129,7 @@ get_filename_component(TEMP_NAME "${TEMP_PATH}" NAME)

while (NOT TEMP_NAME STREQUAL ${LIB_SEARCH_PREFIX})
set(TEMP_PLATFORM_PREFIX "${TEMP_NAME}/${TEMP_PLATFORM_PREFIX}")
get_filename_component(TEMP_PATH "${TEMP_PATH}" PATH)
get_filename_component(TEMP_PATH "${TEMP_PATH}" PATH)
get_filename_component(TEMP_NAME "${TEMP_PATH}" NAME)
endwhile()

Expand All @@ -143,19 +143,19 @@ set(AWSSDK_BIN_DIR "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_BINDIR}/${AWSSDK_PLATFOR


if (AWSSDK_PLATFORM_DEPS_LIBS)
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS_LIBS}")
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS_LIBS}")
endif()

if (AWSSDK_CRYPTO_LIBS)
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS}" "${AWSSDK_CRYPTO_LIBS}")
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS}" "${AWSSDK_CRYPTO_LIBS}")
endif()

if (AWSSDK_CLIENT_LIBS)
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS}" "${AWSSDK_CLIENT_LIBS}")
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS}" "${AWSSDK_CLIENT_LIBS}")
endif()

if (AWSSDK_ADDITIONAL_LIBS)
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS}" "${AWSSDK_ADDITIONAL_LIBS}")
set(AWSSDK_PLATFORM_DEPS "${AWSSDK_PLATFORM_DEPS}" "${AWSSDK_ADDITIONAL_LIBS}")
endif()

message(STATUS "Found AWS SDK for C++, Version: ${PACKAGE_VERSION}, Install Root:${AWSSDK_ROOT_DIR}, Platform Prefix:${AWSSDK_PLATFORM_PREFIX}, Platform Dependent Libraries: ${AWSSDK_PLATFORM_DEPS}")
Expand All @@ -164,7 +164,7 @@ message(STATUS "Found AWS SDK for C++, Version: ${PACKAGE_VERSION}, Install Root
# copy libs of services in SERVICE_LIST and all there dependent libs to DEST_DIR
# CONFIG denote copy release or debug version
macro(AWSSDK_CPY_DYN_LIBS SERVICE_LIST CONFIG DEST_DIR)
set(ALL_SERVICES "core")
set(ALL_SERVICES "core;aws-c-event-stream;aws-checksums;aws-c-common")

foreach(SVC IN LISTS ${SERVICE_LIST})
list(APPEND ALL_SERVICES ${SVC})
Expand All @@ -178,15 +178,18 @@ macro(AWSSDK_CPY_DYN_LIBS SERVICE_LIST CONFIG DEST_DIR)
list(REMOVE_DUPLICATES ALL_SERVICES)

foreach(SVC IN LISTS ALL_SERVICES)
if (WIN32)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES_TEMP ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
endif()
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
endif()
find_library(LIB_PATH "aws-cpp-sdk-${SVC}" "${AWSSDK_LIB_DIR}/${CONFIG}" NO_DEFAULT_PATH)
if (NOT LIB_PATH)
message(FATAL_ERROR "Couldn't find library aws-cpp-sdk-${SVC}")
find_library(LIB_PATH "${SVC}" "${AWSSDK_LIB_DIR}/${CONFIG}" NO_DEFAULT_PATH)
if (NOT LIB_PATH)
message(FATAL_ERROR "Couldn't find library aws-cpp-sdk-${SVC} or ${SVC}")
endif()
endif()
file(COPY ${LIB_PATH} DESTINATION ${DEST_DIR})
file(COPY ${LIB_PATH} DESTINATION ${DEST_DIR})
unset(LIB_PATH CACHE)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_TEMP})
Expand Down
26 changes: 0 additions & 26 deletions scripts/build_custom_client.sh

This file was deleted.

0 comments on commit 0c19eb1

Please sign in to comment.