-
Notifications
You must be signed in to change notification settings - Fork 4
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
Read suites from Kubernetes testrun resource #74
Read suites from Kubernetes testrun resource #74
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase
d44fcb9
to
cead2dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this change been tested? It should not work.
tercc = EiffelTestExecutionRecipeCollectionCreatedEvent() | ||
tercc_json = None | ||
if os.getenv("TERCC") is not None: | ||
# first option for backwards compatibility | ||
self.logger.info("Reading TERCC from environment variable") | ||
tercc_json = json.loads(os.getenv("TERCC", "{}")) | ||
tercc.rebuild(tercc_json) | ||
else: | ||
# requires testrun custom resource defined in Kubernetes | ||
self.logger.info("Reading TERCC from Kubernetes testrun resource") | ||
tercc = TestRun(Kubernetes()).get(os.getenv("TESTRUN")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few problems with this.
- This property should only be used as a fallback for when we're not running in the controller environment (line 123).
- The TestRun resource from Kubernetes is not equivalent to a TERCC.
- The code for requesting a TestRun resource from Kubernetes instead of loading the TERCC environment variable as a TestRun should be in the
test_suite
property (line 174)
cf63faf
to
e7b07fa
Compare
if isinstance(tercc, list): | ||
test_suite = [Suite(**suite) for suite in tercc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part was the part that handled TESTRUN before. It shouldn't be needed here.
if os.environ.get("TERCC") is not None: | ||
self.__test_suite = self._get_test_suite_list_from_tercc() | ||
else: | ||
test_suite = self._eiffel_test_suite(tercc) | ||
# The dataset is not necessary for the suite runner. | ||
self.__test_suite = [Suite.from_tercc(suite, {}) for suite in test_suite] | ||
self.__test_suite = self._get_test_suite_list_from_kubernetes_testrun() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just
if testrun_id := os.getenv("TESTRUN") is not None:
testrun = TestRun(Kubernetes()).get(testrun_id)
self.__test_suite = testrun.spec.suites
else:
self.__test_suite = self._eiffel_test_suite(os.getenv("TERCC", "{}"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parentheses are needed in the if-line, because otherwise testrun_id evaluates to a boolean.
The else block seems to need this line too:
test_suite = [Suite.from_tercc(suite, {}) for suite in test_suite]
Applicable Issues
Description of the Change
This change enables ETOS Suite Runner to read suites from Kubernetes' TestRun.
Alternate Designs
Possible Drawbacks
Sign-off
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
Signed-off-by: Andrei Matveyeu, [email protected]