Skip to content

Commit

Permalink
{AKS} create ssh-key in advance when perform concurrent tests (Azure#…
Browse files Browse the repository at this point in the history
…3756)

* create ssh-key in advance

* update ssh-key generation

* update default ssh dir

* update ssh storage

* fix key path bug

* add vars back

* clarify transcribe

* more pythonic
  • Loading branch information
FumingZhang authored Aug 13, 2021
1 parent 3318e4b commit 1827351
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 133 deletions.
15 changes: 15 additions & 0 deletions src/aks-preview/azcli_aks_live_test/scripts/setup_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# check var
# specify the version of python3, e.g. 3.6
[[ -z "${PYTHON_VERSION}" ]] && (echo "PYTHON_VERSION is empty"; exit 1)
[[ -z "${ACS_BASE_DIR}" ]] && (echo "ACS_BASE_DIR is empty"; exit 1)

setupVenv(){
# delete existing venv
Expand Down Expand Up @@ -106,6 +107,19 @@ setupAKSPreview(){
source azEnv/bin/activate
}

createSSHKey(){
# create ssh-key in advance to avoid the race condition that is prone to occur when key creation is handled by
# azure-cli when performing test cases concurrently, this command will not overwrite the existing ssh-key
custom_ssh_dir=${1:-"${ACS_BASE_DIR}/tests/latest/data/.ssh"}
# remove dir if exists (clean up), otherwise create it
if [[ -d ${custom_ssh_dir} ]]; then
rm -rf ${custom_ssh_dir}
else
mkdir -p ${custom_ssh_dir}
fi
ssh-keygen -t rsa -b 2048 -C "azcli_aks_live_test@example.com" -f ${custom_ssh_dir}/id_rsa -N "" -q <<< n
}

setup_option=${1:-""}
if [[ -n ${setup_option} ]]; then
# bash options
Expand Down Expand Up @@ -142,6 +156,7 @@ if [[ -n ${setup_option} ]]; then
ext_repo=${4:-""}
setupAZ "${cli_repo}" "${ext_repo}"
installTestPackages
createSSHKey
elif [[ ${setup_option} == "setup-akspreview" ]]; then
echo "Start to setup aks-preview!"
setupAKSPreview
Expand Down
9 changes: 9 additions & 0 deletions src/aks-preview/azcli_aks_live_test/scripts/transcribe_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ set -o xtrace
[[ -z "${CLI_BRANCH}" ]] && (echo "CLI_BRANCH is empty"; exit 1)
[[ -z "${EXT_REPO}" ]] && (echo "EXT_REPO is empty"; exit 1)
[[ -z "${EXT_BRANCH}" ]] && (echo "EXT_BRANCH is empty"; exit 1)
# base directories for acs, aks-preview and live test
[[ -z "${ACS_BASE_DIR}" ]] && (echo "ACS_BASE_DIR is empty"; exit 1)
[[ -z "${AKS_PREVIEW_BASE_DIR}" ]] && (echo "AKS_PREVIEW_BASE_DIR is empty"; exit 1)
[[ -z "${LIVE_TEST_BASE_DIR}" ]] && (echo "LIVE_TEST_BASE_DIR is empty"; exit 1)

# clear
cat /dev/null > env.list
Expand All @@ -60,6 +64,11 @@ echo "SYSTEM_PULLREQUEST_TARGETBRANCH=${SYSTEM_PULLREQUEST_TARGETBRANCH}" >> env
# python version
echo "PYTHON_VERSION=${PYTHON_VERSION}" >> env.list

# base directories
echo "ACS_BASE_DIR=${ACS_BASE_DIR}" >> env.list
echo "AKS_PREVIEW_BASE_DIR=${AKS_PREVIEW_BASE_DIR}" >> env.list
echo "LIVE_TEST_BASE_DIR=${LIVE_TEST_BASE_DIR}" >> env.list

# azdev env
echo "AZURE_CLI_TEST_DEV_SP_NAME=${AZCLI_ALT_CLIENT_ID}" >> env.list
echo "AZURE_CLI_TEST_DEV_RESOURCE_GROUP_LOCATION=${TEST_LOCATION}" >> env.list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ variables:
value: "azure-cli-extensions"
- name: LIVE_TEST_BASE_DIR
value: "azure-cli-extensions/src/aks-preview/azcli_aks_live_test"
- name: ACS_BASE_DIR
value: "azure-cli/src/azure-cli/azure/cli/command_modules/acs"
- name: AKS_PREVIEW_BASE_DIR
value: "azure-cli-extensions/src/aks-preview/azext_aks_preview"

jobs:
- job: UnitTest
Expand Down
Loading

0 comments on commit 1827351

Please sign in to comment.