Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure executor names are alphanumeric #1440

Merged
merged 3 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion buildtest/builders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,6 @@ def check_test_state(self):

# if status is defined in Buildspec, then check for returncode and regex
if self.status:

# if 'state' property is specified explicitly honor this value regardless of what is calculated
if self.status.get("state"):
self.metadata["result"]["state"] = self.status["state"]
Expand Down
1 change: 0 additions & 1 deletion buildtest/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def get_parser():
subparsers = parser.add_subparsers(title="COMMANDS", dest="subcommands", metavar="")

def get_parent_parser():

parent_parser = {}

parent_parser["pager"] = argparse.ArgumentParser(add_help=False)
Expand Down
2 changes: 1 addition & 1 deletion buildtest/cli/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def inspect_list(
for column in table.keys():
inspect_table.add_column(column)

for (identifier, name, buildspec) in zip(
for identifier, name, buildspec in zip(
table["id"], table["name"], table["buildspec"]
):
inspect_table.add_row(identifier, name, buildspec)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
system:
generic:
hostnames: ['.*']
moduletool: N/A
executors:
local:
# the line below is invalid due to pattern property
==bash:
description: submit jobs on local machine
shell: bash -v
slurm:
# the line below is invalid due to pattern property
$haswell:
launcher: sbatch
options: ["-p haswell", "-t 00:10"]
lsf:
<>batch:
launcher: bsub
queue: batch
options: ["-q batch", "-t 00:10"]
cobalt:
<normal>:
launcher: qsub
queue: normal
options: ["-n 1", "-t 10"]
compilers:
compiler:
gcc:
default:
cc: /usr/bin/gcc
cxx: /usr/bin/g++
fc: /usr/bin/gfortran
45 changes: 25 additions & 20 deletions buildtest/schemas/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,46 +252,51 @@
"local": {
"type": "object",
"description": "The ``local`` section is used for declaring local executors for running jobs on local machine",
"patternProperties": {
"^.*$": {
"$ref": "#/definitions/local"
}
"propertyNames": {
"pattern": "^[A-Za-z0-9_.-]+$"
},
"additionalProperties": {
"$ref": "#/definitions/local"
}
},
"lsf": {
"type": "object",
"description": "The ``lsf`` section is used for declaring LSF executors for running jobs using LSF scheduler",
"patternProperties": {
"^.*$": {
"$ref": "#/definitions/lsf"
}
"propertyNames": {
"pattern": "^[A-Za-z0-9_.-]+$"
},
"additionalProperties": {
"$ref": "#/definitions/lsf"
}
},
"slurm": {
"type": "object",
"description": "The ``slurm`` section is used for declaring Slurm executors for running jobs using Slurm scheduler",
"patternProperties": {
"^.*$": {
"$ref": "#/definitions/slurm"
}
"propertyNames": {
"pattern": "^[A-Za-z0-9_.-]+$"
},
"additionalProperties": {
"$ref": "#/definitions/slurm"
}
},
"cobalt": {
"type": "object",
"description": "The ``cobalt`` section is used for declaring Cobalt executors for running jobs using Cobalt scheduler",
"patternProperties": {
"^.*$": {
"$ref": "#/definitions/cobalt"
}
"propertyNames": {
"pattern": "^[A-Za-z0-9_.-]+$"
},
"additionalProperties": {
"$ref": "#/definitions/cobalt"
}
},
"pbs": {
"type": "object",
"description": "The ``pbs`` section is used for declaring PBS executors for running jobs using PBS scheduler",
"patternProperties": {
"^.*$": {
"$ref": "#/definitions/pbs"
}
"propertyNames": {
"pattern": "^[A-Za-z0-9_.-]+$"
},
"additionalProperties": {
"$ref": "#/definitions/pbs"
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion tests/schema_tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from buildtest.defaults import SCHEMA_ROOT
from buildtest.schemas.defaults import custom_validator
from buildtest.schemas.utils import load_recipe, load_schema
from jsonschema.exceptions import ValidationError

schema_file = "settings.schema.json"
settings_schema = os.path.join(SCHEMA_ROOT, schema_file)
Expand All @@ -19,7 +20,7 @@ def test_settings_examples():
assert valid

valid_recipes = os.listdir(valid)
assert valid_recipes

# check all valid recipes
for example in valid_recipes:
filepath = os.path.join(valid, example)
Expand All @@ -29,3 +30,14 @@ def test_settings_examples():

print(f"Expecting Recipe File: {filepath} to be valid")
custom_validator(recipe=example_recipe, schema=recipe)

invalid = os.path.join(settings_schema_examples, "invalid")
for example in os.listdir(invalid):
filepath = os.path.join(invalid, example)
print(f"Loading Recipe File: {filepath}")
example_recipe = load_recipe(filepath)
assert example_recipe

print(f"Expecting Recipe File: {filepath} to be invalid")
with pytest.raises(ValidationError):
custom_validator(recipe=example_recipe, schema=recipe)