-
Notifications
You must be signed in to change notification settings - Fork 4
144 lines (130 loc) · 5.04 KB
/
vcptcore-loadtest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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