Skip to content

Commit

Permalink
add support for specifying parameters through config file
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Aug 30, 2024
1 parent 5f368dc commit 4893116
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions docs/config/global.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ The global configuration file consists of the following settings:
* `console`: boolean indicating whether the logging should be dumped at console or not (Default: `false`)
* `level`: debugging level of the controller (Default: `INFO`)
* `timestamp`: adds timestamp to genereated logs (Default: `true`)
* `tests`: a list of tests sets to run - these represent the default set of
tests to be run, unless specified as arguments otherwise (Default: empty)
* `test`: a list of test filters to be used unless specified as arguments
through the (`-t|--test` argument) (Default: empty)
* `exclude`: a list of exclude filters to be used unless specified as
arguments through the (`-e|--exclude` argument) (Default: empty)

## Example

Expand Down
25 changes: 17 additions & 8 deletions sipssert/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,33 @@ class Controller:
"""Controller class that implements the logic"""

def __init__(self, args):
self.sets_dirs = args.tests
self.filters = (tests_filters.ParseTestsFilters(args.test),
tests_filters.ParseTestsFilters(args.exclude))
self.logs_dir = args.logs_dir
self.config_file = args.config
try:
self.config = config.Config(self.config_file, None, "defines.yml")
except config.ConfigParseError:
raise Exception(f"could not parse {self.config_file}")
if len(args.tests):
self.sets_dirs = args.tests
else:
self.sets_dirs = list(map(os.path.abspath,
self.config.get("tests", [])))
test_filters = args.test if len(args.test) else \
self.config.get("test", [])
exclude_filters = args.exclude if len(args.exclude) else \
self.config.get("exclude", [])
self.filters = (tests_filters.ParseTestsFilters(test_filters),
tests_filters.ParseTestsFilters(exclude_filters))
self.logs_dir = args.logs_dir
self.no_delete = args.no_delete
current_date = datetime.now().strftime("%Y-%m-%d.%H:%M:%S.%f")
self.run_logs_dir = os.path.join(self.logs_dir, current_date)
self.link_file = os.path.join(self.logs_dir, "latest")
self.create_run_logs_dir()
try:
self.config = config.Config(self.config_file, None, "defines.yml")
except config.ConfigParseError:
raise Exception("could not parse {}".format(self.config_file))
if self.config.get("logging"):
logging = self.config.get("logging").get("controller")
else:
logging = None

logger.init_logger(logging, self.run_logs_dir)
self.docker = docker.from_env()
self.tlogger = testing.Testing("Running SIPssert Testing Framework")
Expand Down
2 changes: 1 addition & 1 deletion sipssert/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
arg_parser.add_argument('tests',
help='Absolute path of the tests director',
type=os.path.abspath,
nargs='+')
nargs='*')

arg_parser.add_argument('-t', '--test',
help='Pattern that specify the tests to run. ' \
Expand Down

0 comments on commit 4893116

Please sign in to comment.