regro / regolith

Research Group Content Managment System

Home Page:http://regro.github.io/regolith-docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Testing results in subprocess.CalledProcessError when mongodb package is installed

N-G-Asker opened this issue · comments

running python run_tests.py fails with the following abbreviated error message:
tests/test_builders.py::test_builder[mongo-cv] - subprocess.CalledProcessError

This obnoxious issue has reared its ugly head yet again.

I am on it and will ensure we patch it in ALL files in our repository this time. The solution is the same as from this commit

The issue seems to be a bit more hairy than I thought. The solution might involve adding exception handling to tests/test_builders.py. It's possible there's something wrong with my configuration of mongodb, as well. I will work more on this tomorrow.

Full output wouldn't fit in the chat, but here's a text file of it: run_tests_dump.txt

And here's the summary it gives at the end:
=========================== short test summary info ============================
FAILED tests/test_builders.py::test_builder[mongo-cv] - subprocess.CalledProc...
FAILED tests/test_builders.py::test_builder[mongo-review-prop] - subprocess.C...
FAILED tests/test_builders.py::test_builder[mongo-annual-activity] - subproce...
FAILED tests/test_builders.py::test_builder[mongo-beamplan0] - subprocess.Cal...
FAILED tests/test_builders.py::test_builder[mongo-current-pending] - subproce...
FAILED tests/test_builders.py::test_builder[mongo-html] - subprocess.CalledPr...
FAILED tests/test_builders.py::test_builder[mongo-preslist] - subprocess.Call...
FAILED tests/test_builders.py::test_builder[mongo-publist] - subprocess.Calle...
FAILED tests/test_builders.py::test_builder[mongo-recent-collabs] - subproces...
FAILED tests/test_builders.py::test_builder[mongo-beamplan1] - subprocess.Cal...
FAILED tests/test_builders.py::test_builder[mongo-grantreport] - FileNotFound...
FAILED tests/test_builders.py::test_builder[mongo-resume] - subprocess.Called...
FAILED tests/test_builders.py::test_builder[mongo-review-man] - subprocess.Ca...
FAILED tests/test_builders.py::test_builder[mongo-reimb] - subprocess.CalledP...
FAILED tests/test_builders.py::test_builder_python[cv-mongo] - FileNotFoundEr...
FAILED tests/test_builders.py::test_builder_python[review-prop-mongo] - FileN...
FAILED tests/test_builders.py::test_builder_python[annual-activity-mongo] - F...
FAILED tests/test_builders.py::test_builder_python[beamplan0-mongo] - FileNot...
FAILED tests/test_builders.py::test_builder_python[current-pending-mongo] - F...
FAILED tests/test_builders.py::test_builder_python[html-mongo] - FileNotFound...
FAILED tests/test_builders.py::test_builder_python[internalhtml-mongo] - File...
FAILED tests/test_builders.py::test_builder_python[preslist-mongo] - FileNotF...
FAILED tests/test_builders.py::test_builder_python[publist-mongo] - FileNotFo...
FAILED tests/test_builders.py::test_builder_python[recent-collabs-mongo] - Fi...
FAILED tests/test_builders.py::test_builder_python[beamplan1-mongo] - FileNot...
FAILED tests/test_builders.py::test_builder_python[grantreport-mongo] - FileN...
FAILED tests/test_builders.py::test_builder_python[resume-mongo] - FileNotFou...
FAILED tests/test_builders.py::test_builder_python[review-man-mongo] - FileNo...
FAILED tests/test_builders.py::test_builder_python[reimb-mongo] - FileNotFoun...
FAILED tests/test_client_manager.py::test_collection_retrieval_python - FileN...
FAILED tests/test_commands.py::test_fs_to_mongo_python - assert True == False
FAILED tests/test_commands.py::test_mongo_to_fs_python - assert True == False
FAILED tests/test_validators.py::test_mongo_invalid_insertion - FileNotFoundE...
====== 33 failed, 462 passed, 2 skipped, 11 warnings in 156.91s (0:02:36) ======

Sorry for the problems @N-G-Asker . I think it runs find on CI (Travis), so maybe create a new env and follow the steps that the CI follows to make it run and pass tests over there.... i.e., look into the .travis file and see how it builds the environments, then build your regolith testing env with the same commands?

Thanks for pointing to the travis.yml file...it didn't solve my problem but put me on the right track. It was an issue with my local system software, not my python environment.

Turns out I had all the dependencies listed in the requirements/ directory (which the travis script installs), so my python environment was complete. But after digging into the CI build messages, I realized that the tests also require a system installation of the mongodb-org package -- the Travis docker container has this natively, but my system did not. I followed this great tutorial from Digital Ocean to download the required software to my system using the linux package manager apt.

Running python run_tests.py, I am still getting 2 skips, but everything else is passing off a clean, synchronized master.

===================================== 495 passed, 2 skipped, 17 warnings in 331.72s (0:05:31) ======================================

These are the two tests that skip:

tests/test_builders.py::test_builder[mongo-internalhtml] SKIPPED (mocking of Crossref not working with subprocess)
tests/test_builders.py::test_builder[fs-internalhtml] SKIPPED (mocking of Crossref not working with subprocess) 

Working on figuring out why, but it does seem related to the subprocess module.

These skips appear to be a known issue/bug and are documented in test_builders.py with dev comments:

def test_builder(bm, db_src, make_db, make_mongodb, monkeypatch):
    # FIXME: Somehow the mongo backend failed to build figure
    # FIXME: now fs is failing to build figure
    # if db_src == "mongo" and bm == "figure":
    if bm == "figure":
        return
    if db_src == "fs":
        repo = make_db
    elif db_src == "mongo":
        if make_mongodb is False:
            pytest.skip("Mongoclient failed to start")
        else:
            repo = make_mongodb
    else:
        raise ValueError("Unknown database source: {}".format(db_src))
    os.chdir(repo)
    if bm == "figure":
        prep_figure()
    if bm == "internalhtml":
        # for some reason the mocking of the crossref call doesn't work when the
        # test is run using subprocess, so skip in this case.
        # the functionality is fully tested in test_builder_python
        pytest.skip("mocking of Crossref not working with subprocess")

all good. This is a legitimate skip..... Glad it is all resolved on your side. I am closing this issue. Thanks for raising it and looking into it.