2
votes

Setting up Azure DevOps to test a Python lib with MongoDB.

The pipeline uses a linux machine.

It seems MongoDB is installed by default so I shouldn't have to do it: my pipeline config includes a script: mongod --version step. The output I get is

db version v4.4.1
Build Info: {
    "version": "4.4.1",
    "gitVersion": "ad91a93a5a31e175f5cbf8c69561e788bbc55ce1",
    "openSSLVersion": "OpenSSL 1.1.1g  21 Apr 2020",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "ubuntu1804",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

However, I can't connect to the database. The default port doesn't reply.

I couldn't find much information about this. Looks like the information I find about Azure DevOps + MongoDB is about using MongoDB for the DevOps process, like storing DevOps results.

1

1 Answers

2
votes

MongoDB is installed but must be started manually:

systemctl status mongod yields

● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: https://docs.mongodb.org/manual

Add a sudo systemctl start mongod step before the tests:

- script: mongod --version
- script: sudo systemctl start mongod
- script: test command (e.g. pytest, tox...)

MongoDB is then available, running on default port.