简体   繁体   中英

Azure DevOps Pipeline does not run Pytest. Keeps loading

I am facing a strange problem I never had before with Azure.

When I want to run a pipeline and execute the following bash command:

echo 'Running unit tests'
pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml

It does nothing. The agent keeps 'loading'. Locally when I run pytest it runs the tests and passes them.

Anyone knows what the problem could be?

Same pytest command works on my side.

The below is everything on my side. You can do a test to check whether it works on your side.

bowmantest_module/ init .py

#a module with +, -, *, / method

def add_bowman(a, b):
    return a + b

def sub_bowman(a, b):
    return a - b

def mul_bowman(a, b):
    return a * b

def div_bowman(a, b):
    return a / b

python_test.py

#a python unit test
import unittest
import bowmantest_module as btm

#+, -, *, / method in test class
class python_test(unittest.TestCase):
    def test_add(self):
        self.assertEqual(btm.add_bowman(1,1), 2)
    def test_sub(self):
        self.assertEqual(btm.sub_bowman(1,1), 0)
    def test_mul(self):
        self.assertEqual(btm.mul_bowman(1,1), 1)
    def test_div(self):
        self.assertEqual(btm.div_bowman(1,1), 1)

Repository Structure:

在此处输入图像描述

azure-pipelines.yml

trigger:
- none

pool:
  vmImage: ubuntu-latest

steps:
- script: |
    pip install pytest
    pip install pytest-cov
  displayName: 'Install modules'
- script: |
    pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml
    ls
  displayName: 'Run tests'

I can successfully get the results:

在此处输入图像描述

I am sure the above works, if still not work, I suggest you to check the job queue status in the agent pool. Microsoft Hosted Agent is in this place:

在此处输入图像描述

Microsoft Host agent only offer 1 parallel job up to 1800 mins/month for DevOps. If other jobs are in the queue then the agent will not run the pipeline immediately.

And also make sure you didn't run out of the limit of the pipeline parallel jobs(total time limit and parallel jobs limit.).


By the way, since you can run the command successfully on local, you can set up a self-hosted agent and then design&run the pipeline based on the self-hosted agent , so that you will have same environment as local.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM