[SERVER-46581] mongo_embedded_test opens storage data files in the default dbpath (/data/db) Created: 03/Mar/20  Updated: 29/Oct/23  Resolved: 12/Mar/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Andrew Morrow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-54414 Prevent tests from using /data/db dbpath Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Dev Tools 2020-03-23, Dev Platform 2021-02-22, Dev Platform 2021-03-08, Dev Platform 2021-03-22
Participants:

 Description   

When I run mongo_embedded_test, it appears open the default dbpath (/data/db) with the default (or detected) storage engine. It then closes that storage engine before proceeding with the unit test suites (which all use temporary locations for their dbpaths).
This happens because the embedded instance initialize() calls initializeStorageEngine().

This means that if you have corrupt or problematic files in /data/db, your unit test can fail, or worse, silently change the files.



 Comments   
Comment by Githook User [ 11/Mar/21 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-46581 Use a temporary directory in the embedded test log callback check
Branch: master
https://github.com/mongodb/mongo/commit/a47cda347b4934cce1943f41231814db9cdc9e8d

Comment by Andrew Morrow (Inactive) [ 09/Feb/21 ]

This is directly caused by this part of the test in mongo_embedded_test.cpp:

    // Attempt to create an embedded instance to make sure something gets logged. This will probably
    // fail but that's fine.
    mongo_embedded_v1_instance* instance = mongo_embedded_v1_instance_create(lib, nullptr, nullptr);
    if (instance) {
        mongo_embedded_v1_instance_destroy(instance, nullptr);
    }
 
    if (mongo_embedded_v1_lib_fini(lib, nullptr) != MONGO_EMBEDDED_V1_SUCCESS) {
        std::cerr << "mongo_embedded_v1_fini() failed with "
                  << mongo_embedded_v1_status_get_error(status.get()) << ": "
                  << mongo_embedded_v1_status_get_explanation(status.get()) << std::endl;
    }
 
    if (!receivedCallback) {
        std::cerr << "Did not get a log callback." << std::endl;
        return EXIT_FAILURE;
    }

The intention is to spin up an instance and ensure we get a logging callback. Since we didn't provide any configuration, the default is used. A fix should be straightforward.

Comment by Eric Milkie [ 03/Mar/20 ]

Alternatively, we may end up deleting this test entirely.

Generated at Thu Feb 08 05:11:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.