Skip to content

Commit

Permalink
Make storage engine configurable (#100)
Browse files Browse the repository at this point in the history
* Add support for storage engine override

* Set storage engine only when not none

* Drop warning

* Use inMemory instead of ephemeralStorage by default

ephemeralStorage was removed from newer versions and it was meant to be used for internal testing

* Revert back to ephemeralForTest as inMemory only in Enterprise version
  • Loading branch information
david-molnar-oculai authored Jan 21, 2024
1 parent ebb15fc commit df805ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 2 additions & 8 deletions pymongo_inmemory/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def __init__(
)
self.archive_folder = mkdir_ifnot_exist(self.download_folder, self.url_hash)
self.extracted_folder = mkdir_ifnot_exist(self.extract_folder, self.url_hash)
self.storage_engine = "ephemeralForTest"

def __str__(self):
return (
Expand All @@ -143,6 +144,7 @@ def __str__(self):
f"Use Local MongoD {self.use_local_mongod}\n"
f"Download Folder {self.download_folder}\n"
f"Extract Folder {self.extract_folder}\n"
f"Storage engine {self.storage_engine}\n"
)

def _build_operating_system_info(self, os_name=None):
Expand All @@ -152,14 +154,6 @@ def _build_operating_system_info(self, os_name=None):
os_name = _mapping.get(platform.system())
if os_name is None:
raise OperatingSystemNotFound("Can't determine operating system.")
else:
if os_name == "linux":
logger.warning(
(
"Starting from MongoDB 4.0.23 "
"there isn't a generic Linux version of MongoDB"
)
)
return os_name

def _build_download_url(self):
Expand Down
7 changes: 4 additions & 3 deletions pymongo_inmemory/mongod.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MongodConfig:
def __init__(self, pim_context: Context):
self._pim_context = pim_context
self.local_address = "127.0.0.1"
self.engine = "ephemeralForTest"
self.engine = pim_context.storage_engine

@property
def port(self):
Expand Down Expand Up @@ -135,9 +135,10 @@ def start(self):
self.config.port,
"--bind_ip",
self.config.local_address,
"--storageEngine",
self.config.engine,
]
if self.config.engine is not None:
boot_command.append("--storageEngine")
boot_command.append(self.config.engine)
logger.debug(boot_command)
self._proc = subprocess.Popen(boot_command)
_popen_objs.append(self._proc)
Expand Down

0 comments on commit df805ad

Please sign in to comment.