Conversation
a5c8249 to
f8c4ef7
Compare
TomasTomecek
left a comment
There was a problem hiding this comment.
It would be for the best to discuss this in person.
| @@ -0,0 +1,19 @@ | |||
| description: "asdasdsfdasfsda f" | |||
There was a problem hiding this comment.
what format is this? is it yaml?
| def _get_fmf_metadata(self): | ||
| output = {} | ||
| classfile = inspect.getfile(self.__class__) | ||
| fmf_tree = fmf.Tree(os.path.dirname(classfile)) |
There was a problem hiding this comment.
does this mean that we would have to store the metadata alongside the .py file?
| setattr(self, k, metadata_dict[k]) | ||
|
|
||
| def __init__(self, message=None, description=None, reference_url=None, tags=None): | ||
| if message or description or reference_url or tags: |
There was a problem hiding this comment.
better logic could be to load the metadata and just enable overriding them
af8f0e9 to
caf053c
Compare
TomasTomecek
left a comment
There was a problem hiding this comment.
Gotta say I'm pretty lost in the code. I like the change when you removed static data from the code and moved it to fmf metadata. The runner is mystery to me.
| self.description = description | ||
| self.reference_url = reference_url | ||
| self.tags = tags | ||
| def _fmf_meta_init(self, args, kwargs): |
There was a problem hiding this comment.
shouldn't this be *args, **kwargs?
There was a problem hiding this comment.
could be, but I forwarded these list and dict directly from __init__, so that no need to dereferenced them.
| @@ -0,0 +1,115 @@ | |||
| import os | |||
There was a problem hiding this comment.
What does this script is suppose to be doing?
There was a problem hiding this comment.
it does this scheduler, it dynamically generates nosetest testclasses and cases from metadata
There was a problem hiding this comment.
I still don't understand how should I use this file:
$ ./fmf_scheduler.py
zsh: permission denied: ./fmf_scheduler.py
$ python3 ./fmf_scheduler.py
/home/tt/.local/lib/python3.6/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.23) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "./fmf_scheduler.py", line 16, in <module>
TARGET = Target(os.environ.get("TARGET"), LOG_LEVEL)
File "/home/tt/g/user-cont/colin/colin/core/target.py", line 78, in __init__
self.instance = Target._get_target_instance(target, logging_level=logging_level)
File "/home/tt/g/user-cont/colin/colin/core/target.py", line 100, in _get_target_instance
if os.path.isfile(target):
File "/usr/lib64/python3.6/genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
$ python3 ./fmf_scheduler.py registry.access.redhat.com/rhscl/mariadb-101-rhel7:latest
/home/tt/.local/lib/python3.6/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.23) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "./fmf_scheduler.py", line 16, in <module>
TARGET = Target(os.environ.get("TARGET"), LOG_LEVEL)
File "/home/tt/g/user-cont/colin/colin/core/target.py", line 78, in __init__
self.instance = Target._get_target_instance(target, logging_level=logging_level)
File "/home/tt/g/user-cont/colin/colin/core/target.py", line 100, in _get_target_instance
if os.path.isfile(target):
File "/usr/lib64/python3.6/genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
There was a problem hiding this comment.
@TomasTomecek I've wrote it to PR description. usage could be via nosetests like:
TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py
and I've fixed it, and fmf_scheduler.py can be used as scheduler too and fixed there issue when envvar TARGET is not given
|
|
||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| self._fmf_meta_init(args, kwargs) |
There was a problem hiding this comment.
I don't like that fmf is the only way to configure colin.
There was a problem hiding this comment.
It is not just one way. It allows also pass params via normal init
I'll rename it, to another name, like generic_init or something similar
| description = "" | ||
| reference_url = "" | ||
| tags = [] | ||
| base_init_list = ["message", "description", "reference_url", "tags"] |
There was a problem hiding this comment.
so why not just do __init__(self, message, description, reference_url, tags)?
There was a problem hiding this comment.
because this allows me, pass init parameters and assign them as instance variables from fmf data.
|
|
||
| def references(self, patterntree, whole=False): | ||
| """ | ||
| resolve references in names like /a/b/c/d@.x.y or /a/b/c/@y |
There was a problem hiding this comment.
what are these references?
There was a problem hiding this comment.
these references implements something similar, what are in colin rulesets.
|
|
||
| """ | ||
| Module handling FMF stored metadata for classes | ||
| """ |
There was a problem hiding this comment.
module docstrings are meant to be before imports
| @@ -0,0 +1 @@ | |||
| 1 | |||
There was a problem hiding this comment.
yes, this is created by fmf init. This is new feature of fmf.
|
I like the changes to the test metadata: it's great they are now all static and not embedded in the code. It seems that the ruleset interface is still functional: I was able to pass our own ruleset just fine. |
move fmf metadata loader outsite, to be able to use it more generic add more flexible functions to deal with default values and init values from FMF fist step with meta classes for testing via nosetest changed all core.checks to support fmf input format added fmf file for best practices and added init to all files fix defaut values, remove them from init_list cleanup of fmf init method first working version with fmf metadata for few cases added relevancy filtering to fmf scheduler add fmf rulesets via referencing shorter output when using nose added docs strings and few fixes based on reviews
cleanup, use just one fmf import improve scheduler, allow schedule tests directly via this file (nosetest framework import inside) I hope that this is good enough format for codacy, grrr another codacy fixes
|
Regarding the test failure, it's failing on After ~15 minutes of debugging, the problem is that FMF processes as string Interesting that is processed correctly. All attributes of the check: |
…uleset or select tests based on names or advanced filters
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
easier to trace issues Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
| @@ -0,0 +1,188 @@ | |||
| #!/usr/bin/python3 | |||
There was a problem hiding this comment.
Since this script actually proposes a new runtime, I would personally prefer to have it proposed in a different PR. I actually dislike that it's not integrated into colin's CLI interface.
There was a problem hiding this comment.
yep, this is my suggested solution, split this PR, to 2 or 3 PRs, and last of them will be this nosetests generator.
But on other hand, without this, it is harder to show benefits eg:
- write tests just in metadata without empty python classes
- using nosetests scheduled tests
- filtering and selecting or test items
- using FMF rulesets
And this PR will just split metadata outside python classes to FMF files.
But I agree and with this knowledge, that these PRs are closely connected I can split it.
| reference_url="https://fedoraproject.org/wiki/Container:Guidelines#FROM", | ||
| tags=["from", "dockerfile", "baseimage", "latest"]) | ||
| class FromTagNotLatestCheck(FMFAbstractCheck, DockerfileAbstractCheck): | ||
| name, metadata = FMFAbstractCheck.get_metadata("from_tag_not_latest") |
There was a problem hiding this comment.
I wonder whether there is a nicer way of doing this. Calling functions on class' attributes outside of methods seems sketchy.
There was a problem hiding this comment.
Yep, I had also troubles with this, but actually there is probably not better way how to do it without bigger changes in colin. Because current colin implementation does static inspection of classes, to find checks based on class attribute name. If you have some idea I'll be happy to change it to better way
FMF Metadata works well
FMF metadata support in colin. There are two different parts
TODOs:
research how to ideally solve two
__init__()or how to check that all variables are setfind way how to name tests
transform all
__init__s to FMF compatible wayfind way how transform rulesets to FMF testsets
remove all duplicated stuff from colin what is already implemented by FMF** (next PRs)
Colin output:
$ python -m colin.cli.colin list-checkspython -m colin.cli.colin check tests/data/DockerfileFMF output
fmf show --path colin/checkswhen I want to be supercool and have backward compilant output:
use format abilites of fmf:
fmf show --path colin/checks --format "{}\n -> {}\n -> {}\n -> {}\n -> {}\n\n" --value name --value "data['description']" --value "data['message']" --value "data['reference_url']" --value "data['tags']"Nosetests output - direct
TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.pyusing rulesets
advanced filtering
possible to apply them to rulesets or directy to testcases
FILTERS=tags:dockerfile TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py$ NAMES="from_tag_not_latest;maintainer_label" TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.pyrulesets filters
$ NAMES=default RULESETPATH=rulesets/ TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py$ NAMES=fedora RULESETPATH=rulesets/ TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.pyfedora ruleset is not given there, so that it runs 0 tests