code: def test_db_cleanup():
      def _get_new_datasets(new_datasets, old_datasets):
          new_datasets = set(new_datasets) - set(old_datasets)
          assert len(new_datasets) == 1
          return list(new_datasets)[0]
  
      with cleanup_subprocesses(strict=True):
          with InteractiveSubprocess() as ip:
              ip.run_code(_start_db_snippet)
              orig_datasets = set(ip.run_code(_list_datasets_snippet))
              ip.run_code("d1 = fo.Dataset()")
              dataset_nonpersistent = _get_new_datasets(
                  ip.run_code(_list_datasets_snippet), orig_datasets
              )
              ip.run_code("d2 = fo.Dataset(persistent=True)")
              dataset_persistent = _get_new_datasets(
                  ip.run_code(_list_datasets_snippet),
                  orig_datasets | {dataset_nonpersistent},
              )
  
          wait_for_mongod_exit()  # runs DatabaseService.cleanup()
  
          with InteractiveSubprocess() as ip:
              ip.run_code(_start_db_snippet)
              cur_datasets = set(ip.run_code(_list_datasets_snippet))
              assert cur_datasets == orig_datasets | {
                  dataset_persistent
              }
              ip.run_code(
                  "d = fo.load_dataset(%r)" % dataset_persistent
              )
              ip.run_code("d.persistent = False")
              ip.run_code("d.save()")
  
          wait_for_mongod_exit()  # runs DatabaseService.cleanup()
  
          with InteractiveSubprocess() as ip:
              ip.run_code(_start_db_snippet)
              cur_datasets = set(ip.run_code(_list_datasets_snippet))
              assert cur_datasets == orig_datasets
  
imports: from contextlib import contextmanager
  import os
  import sys
  import time
  import unittest
  import psutil
  import requests
  import retrying
  import fiftyone
  import fiftyone.constants
  import fiftyone.core.service
  import fiftyone.service.util
label_desc: Use image node_id 14 for calling a global function with example usage: test_db_cleanup() and returns: list