Skip to content

Commit

Permalink
simply nets check code
Browse files Browse the repository at this point in the history
  • Loading branch information
ppigazzini committed Feb 28, 2024
1 parent e56b270 commit 69ba76e
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions server/fishtest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,30 +918,24 @@ def strip_message(m):
)
data["base_same_as_master"] = master_diff.text == ""

# Store nets info
data["base_nets"] = get_nets(data["resolved_base"], data["tests_repo"])
data["new_nets"] = get_nets(data["resolved_new"], data["tests_repo"])

# Test existence of nets
new_nets = get_nets(data["resolved_new"], data["tests_repo"])
missing_nets = []
for new_net in new_nets:
if not request.rundb.get_nn(new_net):
missing_nets.append(new_net)
for net_name in set(data["base_nets"]) | set(data["new_nets"]):
net = request.rundb.get_nn(net_name)
if not net:
missing_nets.append(net_name)
if missing_nets:
verb, pronoun = ("are", "them") if len(missing_nets) > 1 else ("is", "it")
raise Exception(
"The following net(s): {}, used by {}, {} not "
"known to Fishtest. Please upload {} to: "
"{}/upload.".format(
"Please upload the following net(s): {} to: {}/upload.".format(
", ".join(missing_nets),
data["new_tag"],
verb,
pronoun,
request.host_url,
)
)

# Store nets info
data["new_nets"] = new_nets
data["base_nets"] = get_nets(data["resolved_base"], data["tests_repo"])

# Integer parameters
data["threads"] = int(request.POST["threads"])
data["priority"] = int(request.POST["priority"])
Expand Down Expand Up @@ -1013,32 +1007,25 @@ def update_nets(request, run):
run_id = str(run["_id"])
data = run["args"]
if run["base_same_as_master"]:
base_nets = data["base_nets"]
missing_nets = []
for base_net in base_nets:
net = request.rundb.get_nn(base_net)
for net_name in data["base_nets"]:
net = request.rundb.get_nn(net_name)
if not net:
# Should never happen:
missing_nets.append(base_net)
missing_nets.append(net_name)
elif "is_master" not in net:
net["is_master"] = True
request.rundb.update_nn(net)
if missing_nets:
verb, pronoun = ("are", "them") if len(missing_nets) > 1 else ("is", "it")
raise Exception(
"The following net(s): {}, used by {}, {} not "
"known to Fishtest. Please upload {} to: "
"{}/upload.".format(
"Please upload the following net(s): {} to: {}/upload.".format(
", ".join(missing_nets),
data["base_tag"],
verb,
pronoun,
request.host_url,
)
)
new_nets = data["new_nets"]
for new_net in new_nets:
net = request.rundb.get_nn(new_net)
for net_name in data["new_nets"]:
net = request.rundb.get_nn(net_name)
if not net:
return
if "first_test" not in net:
Expand Down

0 comments on commit 69ba76e

Please sign in to comment.