Skip to content

Commit 54d3987

Browse files
committed
Small conceptual simplification in new_run().
1 parent 12981ff commit 54d3987

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

server/fishtest/rundb.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def new_run(
501501
if tc_base:
502502
tc_base = float(tc_base.group(1))
503503
new_run = {
504+
"_id": ObjectId(),
504505
"version": RUN_VERSION,
505506
"args": run_args,
506507
"start_time": start_time,
@@ -566,12 +567,11 @@ def new_run(
566567
print(message, flush=True)
567568
raise Exception(message)
568569

569-
# We cannot use self.buffer since new_run does not have an id yet.
570-
run_id = str(self.runs.insert_one(new_run).inserted_id)
570+
self.buffer(new_run, True)
571571

572+
run_id = str(new_run["_id"])
572573
with self.unfinished_runs_lock:
573574
self.unfinished_runs.add(run_id)
574-
575575
return run_id
576576

577577
def is_primary_instance(self):
@@ -725,7 +725,7 @@ def buffer(self, run, flush):
725725
}
726726
if flush:
727727
with self.active_run_lock(r_id):
728-
self.runs.replace_one({"_id": ObjectId(r_id)}, run)
728+
self.runs.replace_one({"_id": ObjectId(r_id)}, run, upsert=True)
729729

730730
def stop(self):
731731
self.flush_all()

server/fishtest/schemas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,11 @@ def flags_must_match(run):
640640
# about non-validation of runs created with the prior
641641
# schema.
642642

643-
RUN_VERSION = 4
643+
RUN_VERSION = 5
644644

645645
runs_schema = intersect(
646646
{
647-
"_id?": ObjectId,
647+
"_id": ObjectId,
648648
"version": uint,
649649
"start_time": datetime_utc,
650650
"last_updated": datetime_utc,

0 commit comments

Comments
 (0)