version: 2
plan:
  project-key: PT
  name: Run Neoload Test
  key: RT

variables:
  api_url: https://neoload-api.saas.neotys.com
  # You can encrypt passwords with Bamboo Specs Encryption feature.
  token_secret: BAMSCRT@0@0@/VoBmSJawRda7djjT5mKww==
  zone_id: defaultzone

stages:
  - Performance test:
      jobs:
        - Install Neoload CLI
        - Run Performance test

Install Neoload CLI:
  tasks:
    # Install Neoload CLI
    - script: |
        pip3 install neoload
        neoload --version

Run Performance test:
  tasks:
    # Get NeoLoad project for simple demo example. In production, you can use an already exiting test settings on your NLWeb server.
    - script: wget https://raw.githubusercontent.com/Neotys-Labs/neoload-cli/78a1366743b041088f357f0f702babfce5e55187/tests/neoload_projects/simpledemo.yml

    # Prepare NeoLoad test
    - script: |
        neoload login --url ${bamboo.api_url} ${bamboo.token_secret} \
                test-settings --zone ${bamboo.zone_id} --scenario simpledemo createorpatch "My Bamboo Test With CLI" \
                project --path simpledemo.yml upload

    # Run test
    - script: neoload run --name "Bamboo pipeline performance regression test ${bamboo.buildNumber}" --external-url "${bamboo.resultsUrl}" --external-url-label "Bamboo build ${bamboo.buildNumber}"

    # Generate Test Report
    - script: neoload test-results junitsla
    - test-parser:
        type: junit
        test-results:
          - 'junit-sla.xml'
