Optimal Agent Allocation Strategy for Efficient Build

Uriel Dardik 0 Reputation points
2023-04-16T13:34:12.28+00:00

Hi everybody, I have a question regarding azure-pipeline configurations that I can't figure-out how to solve.

Pipeline - Automation, Fast, Slow
Build - An instance\single-run of the pipeline, on a specific commit
Job - The parts\steps of a build
Task - The parts\steps of a job
Agent - The server that runs the jobsEvery build starts with building the environment for the tests, an
action that takes time.

I want to achieve -

  1. Once a build has started on a specific agent, this agent won’t take any job from different builds, until the current build is complete. - Is there any way to do it?
  2. The max number of agents on one build is 3
  3. We prefer that the maximum amount of agents will be handling the same build at once
  4. Every build can run on one agent or more

Currently the status is that the agents are jumping from one build to another, and leaving some builds un-handled.
My current YAML configuration's file -

trigger:
  tags:
    include:
    - 2.*

parameters:
  - name: 'tests'
    type: object
    default:
      - "test_1"
      - "test_2"
      - "test_3"
      - "test_4"
      - "test_5"
      - "test_6"
      - "test_7"
      - "test_8"
      - "test_9"

stages:
  - stage: RunTests
    displayName: 'Run Tests'
    jobs:
      - job: ui
        timeoutInMinutes: 120
        pool:
          name: Nightly
          demands:
            - Cmd
            - DotNetFramework

        strategy:
          maxParallel: 3
          matrix:
            ${{ each test_case in parameters.tests }}:
              ${{ test_case }}:
                test: ${{ test_case }}

        steps:
          - task: DeleteFiles@1
            displayName: 'Delete past session artifacts'
            inputs:
              sourceFolder: 'C:/dev'
              contents: |
                /files/**/*
                /temp/**/*
            condition: always()

          - task: DeleteFiles@1
            displayName: 'Delete past session captures'
            inputs:
              sourceFolder: 'C:/test_capture'
              contents: |
                **/*
            condition: always()

          - task: BatchScript@1
            displayName: 'configure z'
            inputs:
              filename: 'scripts\configure_z.bat'
              modifyEnvironment: false
            timeoutInMinutes: 20

          - template: build_env.yaml

          - task: BatchScript@1
            displayName: 'Run script automation/run_tests.bat '
            inputs:
              filename: 'automation/run_tests.bat'
              arguments: $(test)
              modifyEnvironment: false
            condition: and(succeeded(), ne(variables['Agent.JobStatus'], 'Canceled'))

          - task: PublishPipelineArtifact@1
            displayName: 'Publish Pipeline Artifact'
            inputs:
              artifactName: Automation logs $(Agent.JobName) Attemp $(System.JobAttempt)
              targetPath: 'c:\test_capture'
            condition: always()

          - template: publish_test_results.yaml

  - stage: WrapUp
    displayName: 'Wrap Up'
    dependsOn: RunTests
    jobs:
      - job: PublishCompiledLogs
        displayName: 'Publish Compiled Logs'
        timeoutInMinutes: 20
        pool:
          name: Nightly
          demands:
            - Cmd
            - DotNetFramework

        steps:
          - task: DownloadPipelineArtifact@2
            inputs:
              patterns: '**/nosetest-*.xml'
              path: './tests-xml'
            condition: always()

          - task: CmdLine@1
            displayName: 'Combine Logs'
            inputs:
              filename: python
              arguments: 'scripts/merge_nosetest_logs.py --directory tests-xml --output tests-xml/nosetest-automation.xml --remove'
            continueOnError: true
            condition: always()

          - task: PublishPipelineArtifact@1
            displayName: 'Publish All Tests Artifact'
            inputs:
              artifactName: All Automatic Tests Logs
              targetPath: './tests-xml'
            condition: always()

Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 18,996 Reputation points Moderator
    2023-04-17T07:43:07.89+00:00

    @Uriel Dardik Thanks for reaching out! However, this forum is mainly intended for products mentioned here. I would kindly suggest you post your question on channels mentioned here where Azure Devops experts can assist you effectively for your request.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.