Run vcptcore-loadtest #361
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run vcptcore-loadtest | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ vcptcore-loadtest ] | |
types: [closed] | |
env: | |
ARGO_SERVER: argo.virtocommerce.cloud | |
ENV_NAME: vcptcore-loadtest | |
ARGO_USERNAME: ${{ secrets.VIRTOCLOUD_LOGIN }} | |
ARGO_PASSWORD: ${{ secrets.VIRTOCLOUD_PASSWORD }} | |
DB_NAME: loadtest-platform_dev_separate | |
DB_SERVER: vc-dev-dbserver | |
DB_RESOURCE_GROUP: aks-cluster-dev | |
jobs: | |
#azure-sql: | |
# runs-on: ubuntu-20.04 | |
# steps: | |
#- name: Azure login | |
# uses: azure/login@v1 | |
# with: | |
# creds: '{"clientId":"${{ secrets.AZURE_CREDENTIALS_CLIENT }}","clientSecret":"${{ secrets.AZURE_CREDENTIALS_SECRET }}","subscriptionId":"${{ secrets.AZURE_CREDENTIALS_SUB }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
# - name: Azure CLI - scale up DB | |
# uses: azure/CLI@v1 | |
# with: | |
# azcliversion: 2.30.0 | |
# inlineScript: | | |
# az sql db create --resource-group ${{ env.DB_RESOURCE_GROUP }} --server ${{ env.DB_SERVER }} --name ${{ env.DB_NAME }} --service-objective S2 | |
azure-vm: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Azure login | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId":"${{ secrets.AZURE_CREDENTIALS_CLIENT }}","clientSecret":"${{ secrets.AZURE_CREDENTIALS_SECRET }}","subscriptionId":"29e73d5c-378f-4e50-8803-270f82cf1114","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
- name: Azure CLI - start vm | |
uses: azure/CLI@master | |
with: | |
azcliversion: 2.30.0 | |
inlineScript: | | |
az vm start --resource-group Loadtest --name linuxJmeter | |
loadtest: | |
#needs: [azure-sql, azure-vm] | |
needs: [ azure-vm ] | |
runs-on: ubuntu-20.04 | |
name: loadtest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: vcptcore-loadtest | |
- name: Get platfrom version | |
id: platform-version | |
run: | | |
echo "PLATFORM_IMAGE_TAG=$(cat ./backend/packages.json | jq -r '.PlatformImageTag')" >> $GITHUB_ENV | |
- name: App wait | |
uses: VirtoCommerce/vc-github-actions/vc-argocd-cli@master # Uses an action in the root directory | |
id: argocd-cli | |
with: | |
server: ${{env.ARGO_SERVER}} | |
username: ${{ env.ARGO_USERNAME }} | |
password: ${{ env.ARGO_PASSWORD }} | |
command: app wait ${{ env.ENV_NAME }} | |
- run: | | |
cd ${{ github.workspace }}/scripts/ | |
ls -l | |
- uses: appleboy/scp-action@master | |
name: Upload script | |
with: | |
host: ${{ secrets.VM_HOST }} | |
username: vcadmin | |
password: ${{ secrets.VM_PASSWORD }} | |
source: "${{ github.workspace }}/scripts/loadtest.py" | |
target: "/home/vcadmin/loadtest-vcptcore" | |
rm: true | |
overwrite: true | |
# strip_components: 5 | |
- name: Run Loadtest | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.VM_HOST }} | |
username: vcadmin | |
password: ${{ secrets.VM_PASSWORD }} | |
command_timeout: 2h | |
script: | | |
cd /home/vcadmin | |
export RELEASE_TAG='${{ env.PLATFORM_IMAGE_TAG }}-${{ github.run_id }}' | |
export TEST='./vc-loadtests/Virto_Templates/Backend_Load_Script_Template.jmx' | |
export REPO='https://${{ secrets.TMP_TOKEN }}@github.com/VirtoCommerce/vc-loadtests.git' | |
echo $RELEASE_TAG | |
export AUTH_TOKEN=${{ secrets.REPO_TOKEN }} | |
cd loadtest-vcptcore/github/workspace/scripts | |
ls -la | |
python3.8 loadtest.py && rm loadtest.py | |
#test | |
Scaledown: | |
#needs: [azure-sql, azure-vm, loadtest] | |
needs: [ azure-vm, loadtest] | |
if: always() | |
runs-on: ubuntu-20.04 | |
name: Scaledown | |
steps: | |
# - name: Azure login SQL | |
# uses: azure/login@v1 | |
# with: | |
# creds: '{"clientId":"${{ secrets.AZURE_CREDENTIALS_CLIENT }}","clientSecret":"${{ secrets.AZURE_CREDENTIALS_SECRET }}","subscriptionId":"63624d02-de44-421b-9d19-306a8e26b322","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
# - name: Azure CLI - scale down DB | |
# uses: azure/CLI@v1 | |
# with: | |
# azcliversion: 2.30.0 | |
# inlineScript: | | |
# az sql db delete --resource-group ${{ env.DB_RESOURCE_GROUP }} --server ${{ env.DB_SERVER }} --name ${{ env.DB_NAME }} --yes | |
- name: Azure login VM | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId":"${{ secrets.AZURE_CREDENTIALS_CLIENT }}","clientSecret":"${{ secrets.AZURE_CREDENTIALS_SECRET }}","subscriptionId":"29e73d5c-378f-4e50-8803-270f82cf1114","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
- name: Azure CLI - stop(deallocate) VM | |
uses: azure/CLI@master | |
with: | |
azcliversion: 2.30.0 | |
inlineScript: | | |
az vm deallocate --resource-group Loadtest --name linuxJmeter | |
# - name: Restart platform | |
# uses: VirtoCommerce/vc-github-actions/vc-argocd-cli@master | |
# id: argocd-cli | |
# with: | |
# server: ${{env.ARGO_SERVER}} | |
# username: ${{ env.ARGO_USERNAME }} | |
# password: ${{ env.ARGO_PASSWORD }} | |
# command: app actions run ${{ env.ENV_NAME }} restart --kind Rollout --resource-name ${{ env.ENV_NAME }}-platform |