Skip to content

Commit

Permalink
Make sure to clean collections and indexes before inserting new fake …
Browse files Browse the repository at this point in the history
…date.
  • Loading branch information
notoraptor committed Mar 4, 2024
1 parent 6c23935 commit d468cac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/store_huge_fake_data_in_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ def populate_fake_data(db_insertion_point, **kwargs):
E = _generate_huge_fake_data(**kwargs)
print("Generated huge fake data")

# Drop any collection (and related index) before.
for k in ["users", "jobs", "nodes", "gpu", "job_user_props"]:
db_insertion_point[k].drop()
assert not list(db_insertion_point[k].list_indexes())

if not disable_index:
print("Generate MongoDB index.")
# Create indices. This isn't half as important as when we're
Expand Down Expand Up @@ -479,6 +484,9 @@ def populate_fake_data(db_insertion_point, **kwargs):
name="job_user_props_index",
)

for k in ["users", "jobs", "nodes", "gpu", "job_user_props"]:
assert list(db_insertion_point[k].list_indexes())

for k in ["users", "jobs", "nodes", "gpu", "job_user_props"]:
# Anyway clean before inserting
db_insertion_point[k].delete_many({})
Expand Down

0 comments on commit d468cac

Please sign in to comment.