Azure DevOps

Bu kılavuz, otomatik performans testi için LoadFocus JMeter API Client'ı Azure DevOps ile nasıl entegre edeceğinizi açıklar.

Kurulum Adımları

1. Kimlik Bilgilerini Azure Key Vault'ta Saklayın

Güvenli kimlik bilgisi yönetimi için LoadFocus API kimlik bilgilerinizi Azure Key Vault'ta saklayın:

  1. Henüz yoksa Azure'da bir Key Vault oluşturun
  2. Aşağıdaki secrets'ları ekleyin:
    • loadfocus-api-key: LoadFocus API anahtarınız
    • loadfocus-team-id: LoadFocus takım kimliğiniz
  3. Pipeline'ınızdan Key Vault'a erişmek için bir hizmet bağlantısı kurun

2. Azure Pipeline Oluşturun

Deponuzda azure-pipelines.yml adında yeni bir dosya oluşturun:

trigger:
- main
- develop
pool:
vmImage: 'ubuntu-latest'
variables:
- group: loadfocus-variables # Variable group containing Key Vault references
stages:
- stage: Build
jobs:
- job: BuildAndTest
steps:
# Your existing build and test steps...
- stage: PerformanceTest
dependsOn: Build
condition: succeeded()
jobs:
- job: RunPerformanceTests
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- script: |
npm install -g @loadfocus/loadfocus-api-client
displayName: 'Install LoadFocus JMeter API Client'
- script: |
loadfocus-api config set apikey $(LOADFOCUS_API_KEY)
loadfocus-api config set teamid $(LOADFOCUS_TEAM_ID)
displayName: 'Configure LoadFocus API Client'
- script: |
loadfocus-api jmeter run-test \
--name "AzureDevOps_$(Build.Repository.Name)_$(Build.SourceBranchName)" \
--thresholds "avgresponse<=200,errors==0,p95<=250" \
--format json > $(Build.ArtifactStagingDirectory)/performance_results.json
displayName: 'Run Performance Tests'
continueOnError: false
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'performance-test-results'
displayName: 'Publish Performance Test Results'
- stage: Deploy
dependsOn: PerformanceTest
condition: succeeded()
jobs:
- job: DeployApplication
steps:
# Your deployment steps...

3. Key Vault Entegrasyonu ile Değişken Grubu Kurma

  1. Pipelines > Library > Variable Groups bölümüne gidin
  2. "loadfocus-variables" adında yeni bir Değişken Grubu oluşturun
  3. Azure Key Vault'unuza bağlayın
  4. Key Vault secrets'larınıza bağlayarak aşağıdaki değişkenleri ekleyin:
    • LOADFOCUS_API_KEY: loadfocus-api-key secret'ına bağlayın
    • LOADFOCUS_TEAM_ID: loadfocus-team-id secret'ına bağlayın

Gelişmiş Yapılandırma

YAML Şablonları Kullanma

Yeniden kullanılabilir performans testi adımları için performance-test-template.yml şablon dosyası oluşturun:

parameters:
testName: 'Default_Test'
thresholds: 'avgresponse<=200,errors==0,p95<=250'
waitTimeout: 1800
steps:
- script: |
loadfocus-api jmeter run-test \
--name "${{ parameters.testName }}" \
--thresholds "${{ parameters.thresholds }}" \
--waitTimeout ${{ parameters.waitTimeout }} \
--format json > $(Build.ArtifactStagingDirectory)/performance_results.json
displayName: 'Run Performance Tests'
continueOnError: false

Ardından ana pipeline'ınızda:

- template: performance-test-template.yml
parameters:
testName: 'AzureDevOps_$(Build.Repository.Name)_$(Build.SourceBranchName)'
thresholds: 'avgresponse<=150,errors==0,p95<=200'
waitTimeout: 2400

Azure DevOps Entegrasyonu İçin İpuçları

  1. Paralel İşler: Birden fazla performans testiniz varsa paralel işler kullanmayı düşünün.

  2. Dağıtım Kapıları: Performans testi sonuçlarını bir dağıtım kapısı olarak kullanın.

  3. Özel Kontrol Paneli: Zaman içinde performans testi sonuçlarını görselleştirmek için özel bir kontrol paneli oluşturun.

  4. Bildirimler: Performans testi başarısızlıkları için bildirimler ayarlayın.

Daha fazla bilgi için Azure DevOps dokümantasyonuna ve LoadFocus API Client dokümantasyonuna başvurun.