Update deployment scripts to support AWSI automation tests on Linux (#7038)

* Update deployment scripts to support AWSI automation tests on Linux

Signed-off-by: Junbo Liang <68558268+junbo75@users.noreply.github.com>
This commit is contained in:
Junbo Liang
2022-01-24 11:20:15 -08:00
committed by GitHub
parent 160508d2d6
commit 1cf7d57b3f
12 changed files with 38 additions and 52 deletions
@@ -12,12 +12,6 @@
################################################################################
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
# Only enable AWS automated tests on Windows
set(SUPPORTED_PLATFORMS "Windows" "Linux")
if (NOT "${PAL_PLATFORM_NAME}" IN_LIST SUPPORTED_PLATFORMS)
return()
endif()
ly_add_pytest(
NAME AutomatedTesting::AWSTests
TEST_SUITE awsi
@@ -3,7 +3,7 @@
## Prerequisites
1. Build the O3DE Editor and AutomatedTesting.GameLauncher in Profile.
2. Install the latest version of NodeJs.
3. AWS CLI is installed and configured following [Configuration and Credential File Settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
3. AWS CLI is installed and AWS crendentials are configured via [environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) or [default profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
4. [AWS Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#getting_started_install) is installed.
## Deploy CDK Applications
@@ -68,6 +68,10 @@ class AwsCredentials:
if (len(self._credentials.sections()) == 0) and (not self._credentials_file_exists):
os.remove(self._credentials_path)
return
credentials_file_dir = os.path.dirname(self._credentials_path)
if not os.path.isdir(credentials_file_dir):
os.makedirs(credentials_file_dir)
with open(self._credentials_path, 'w+') as credential_file:
self._credentials.write(credential_file)
@@ -16,7 +16,7 @@ logging.getLogger('nose').setLevel(logging.WARNING)
class AwsUtils:
def __init__(self, arn: str, session_name: str, region_name: str):
local_session = boto3.Session(profile_name='default')
local_session = boto3.Session()
local_sts_client = local_session.client('sts')
self._local_account_id = local_sts_client.get_caller_identity()["Account"]
logger.info(f'Local Account Id: {self._local_account_id}')
@@ -6,11 +6,13 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
"""
import os
import platform
# ARN of the IAM role to assume for retrieving temporary AWS credentials
ASSUME_ROLE_ARN = os.environ.get('ASSUME_ROLE_ARN', 'arn:aws:iam::645075835648:role/o3de-automation-tests')
# Name of the AWS project deployed by the CDK applications
AWS_PROJECT_NAME = os.environ.get('O3DE_AWS_PROJECT_NAME', 'AWSAUTO')
AWS_PROJECT_NAME = os.environ.get('O3DE_AWS_PROJECT_NAME').upper() if os.environ.get('O3DE_AWS_PROJECT_NAME') else \
(os.environ.get('BRANCH_NAME', '') + '-' + os.environ.get('PIPELINE_NAME', '') + '-' + platform.system()).upper()
# Region for the existing CloudFormation stacks used by the automation tests
AWS_REGION = os.environ.get('O3DE_AWS_DEPLOY_REGION', 'us-east-1')
# Name of the default resource mapping config file used by the automation tests
@@ -185,11 +185,11 @@
"COMMAND": "build_test_linux.sh",
"PARAMETERS": {
"CONFIGURATION": "profile",
"OUTPUT_DIRECTORY": "build\\linux",
"OUTPUT_DIRECTORY": "build/linux",
"CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4",
"CMAKE_LY_PROJECTS": "AutomatedTesting",
"CMAKE_TARGET": "TEST_SUITE_awsi",
"CTEST_OPTIONS": "-L \"(SUITE_awsi)\" --no-tests=error",
"CTEST_OPTIONS": "-L (SUITE_awsi) --no-tests=error",
"TEST_RESULTS": "True"
}
},
@@ -1,5 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
@@ -8,7 +8,7 @@
# Deploy the CDK applications for AWS gems (Linux only)
SOURCE_DIRECTORY=$(dirname "$0")
SOURCE_DIRECTORY=$PWD
PATH=$SOURCE_DIRECTORY/python:$PATH
GEM_DIRECTORY=$SOURCE_DIRECTORY/Gems
@@ -80,11 +80,14 @@ fi
# Set temporary AWS credentials from the assume role
credentials=$(aws sts assume-role --query Credentials.[SecretAccessKey,SessionToken,AccessKeyId] --output text --role-arn $ASSUME_ROLE_ARN --role-session-name o3de-Automation-session)
AWS_SECRET_ACCESS_KEY=$(echo "$credentials" | cut -d' ' -f1)
AWS_SESSION_TOKEN=$(echo "$credentials" | cut -d' ' -f2)
AWS_ACCESS_KEY_ID=$(echo "$credentials" | cut -d' ' -f3)
export AWS_SECRET_ACCESS_KEY=$(echo $credentials | cut -d' ' -f1)
export AWS_SESSION_TOKEN=$(echo $credentials | cut -d' ' -f2)
export AWS_ACCESS_KEY_ID=$(echo $credentials | cut -d' ' -f3)
O3DE_AWS_DEPLOY_ACCOUNT=$(echo "$ASSUME_ROLE_ARN" | cut -d':' -f5)
export O3DE_AWS_DEPLOY_ACCOUNT=$(echo "$ASSUME_ROLE_ARN" | cut -d':' -f5)
if [[ -z "$O3DE_AWS_PROJECT_NAME" ]]; then
export O3DE_AWS_PROJECT_NAME=$BRANCH_NAME-$PIPELINE_NAME-Linux
fi
# Bootstrap and deploy the CDK applications
echo [cdk_bootstrap] Bootstrap CDK
@@ -11,7 +11,7 @@
# 1) Node.js is installed
# 2) Node.js version >= 10.13.0, except for versions 13.0.0 - 13.6.0. A version in active long-term support is recommended.
SOURCE_DIRECTORY=$(dirname "$0")
SOURCE_DIRECTORY=$PWD
PATH=$SOURCE_DIRECTORY/python:$PATH
GEM_DIRECTORY=$SOURCE_DIRECTORY/Gems
@@ -70,12 +70,12 @@ echo [cdk_installation] Install the current version of nodejs
nvm install node
echo [cdk_installation] Install the latest version of CDK
if ! sudo npm uninstall -g aws-cdk;
if ! npm uninstall -g aws-cdk;
then
echo [cdk_bootstrap] Failed to uninstall the current version of CDK
exit 1
fi
if ! sudo npm install -g aws-cdk@latest;
if ! npm install -g aws-cdk@latest;
then
echo [cdk_bootstrap] Failed to install the latest version of CDK
exit 1
@@ -83,9 +83,13 @@ fi
# Set temporary AWS credentials from the assume role
credentials=$(aws sts assume-role --query Credentials.[SecretAccessKey,SessionToken,AccessKeyId] --output text --role-arn $ASSUME_ROLE_ARN --role-session-name o3de-Automation-session)
AWS_SECRET_ACCESS_KEY=$(echo "$credentials" | cut -d' ' -f1)
AWS_SESSION_TOKEN=$(echo "$credentials" | cut -d' ' -f2)
AWS_ACCESS_KEY_ID=$(echo "$credentials" | cut -d' ' -f3)
export AWS_SECRET_ACCESS_KEY=$(echo $credentials | cut -d' ' -f1)
export AWS_SESSION_TOKEN=$(echo $credentials | cut -d' ' -f2)
export AWS_ACCESS_KEY_ID=$(echo $credentials | cut -d' ' -f3)
if [[ -z "$O3DE_AWS_PROJECT_NAME" ]]; then
export O3DE_AWS_PROJECT_NAME=$BRANCH_NAME-$PIPELINE_NAME-Linux
fi
ERROR_EXISTS=0
DestroyCDKApplication AWSCore
@@ -16,13 +16,6 @@
},
"PIPELINE_JENKINS_PARAMETERS": {
"nightly-incremental": [
{
"parameter_name": "O3DE_AWS_PROJECT_NAME",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": "The name of the O3DE project that stacks should be deployed for."
},
{
"parameter_name": "O3DE_AWS_DEPLOY_REGION",
"parameter_type": "string",
@@ -46,13 +39,6 @@
}
],
"nightly-clean": [
{
"parameter_name": "O3DE_AWS_PROJECT_NAME",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": "The name of the O3DE project that stacks should be deployed for."
},
{
"parameter_name": "O3DE_AWS_DEPLOY_REGION",
"parameter_type": "string",
@@ -49,6 +49,10 @@ FOR /f "tokens=1,2,3" %%a IN ('CALL aws sts assume-role --query Credentials.[Sec
)
FOR /F "tokens=4 delims=:" %%a IN ("%ASSUME_ROLE_ARN%") DO SET O3DE_AWS_DEPLOY_ACCOUNT=%%a
IF "%O3DE_AWS_PROJECT_NAME%"=="" (
SET O3DE_AWS_PROJECT_NAME=%BRANCH_NAME%-%PIPELINE_NAME%-Windows
)
REM Bootstrap and deploy the CDK applications
ECHO [cdk_bootstrap] Bootstrap CDK
CALL cdk bootstrap aws://%O3DE_AWS_DEPLOY_ACCOUNT%/%O3DE_AWS_DEPLOY_REGION%
@@ -48,6 +48,9 @@ FOR /f "tokens=1,2,3" %%a IN ('CALL aws sts assume-role --query Credentials.[Sec
SET AWS_ACCESS_KEY_ID=%%c
)
FOR /F "tokens=4 delims=:" %%a IN ("%ASSUME_ROLE_ARN%") DO SET O3DE_AWS_DEPLOY_ACCOUNT=%%a
IF "%O3DE_AWS_PROJECT_NAME%"=="" (
SET O3DE_AWS_PROJECT_NAME=%BRANCH_NAME%-%PIPELINE_NAME%-Windows
)
SET ERROR_EXISTS=0
CALL :DestroyCDKApplication AWSCore,ERROR_EXISTS
@@ -16,13 +16,6 @@
},
"PIPELINE_JENKINS_PARAMETERS": {
"nightly-incremental": [
{
"parameter_name": "O3DE_AWS_PROJECT_NAME",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": "The name of the O3DE project that stacks should be deployed for."
},
{
"parameter_name": "O3DE_AWS_DEPLOY_REGION",
"parameter_type": "string",
@@ -46,13 +39,6 @@
}
],
"nightly-clean": [
{
"parameter_name": "O3DE_AWS_PROJECT_NAME",
"parameter_type": "string",
"default_value": "",
"use_last_run_value": true,
"description": "The name of the O3DE project that stacks should be deployed for."
},
{
"parameter_name": "O3DE_AWS_DEPLOY_REGION",
"parameter_type": "string",