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

Fix NsJail Tests #93

Merged
merged 7 commits into from Mar 8, 2021
Merged

Fix NsJail Tests #93

merged 7 commits into from Mar 8, 2021

Conversation

MarkKoz
Copy link
Member

@MarkKoz MarkKoz commented Feb 5, 2021

#88 left tests in a broken state. This wasn't noticed since CI had a bug that prevented the step from failing despite tests failing. This PR fixes both of these issues.

Generating the report in the same step resulted in the report exit code
overriding the exit code of the test runner.
@MarkKoz MarkKoz added type: bug Something isn't working area: CI Related to continuous intergration and deployment area: tests Related to tests (e.g. unit tests) labels Feb 5, 2021
Copy link
Contributor

@Akarys42 Akarys42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (except for the failing test)

@MarkKoz
Copy link
Member Author

MarkKoz commented Feb 6, 2021

Yeah this wasn't ready for review. I became too busy to continue and fix those issues.

Comment on lines 146 to 147
sudo pip install coveralls~=2.1
sudo coveralls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why we don't make a user install rather than a system install?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC it's cause the user site is not on PATH. It's more convenient to use sudo in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though maybe it's bad practice, even in CI, and I should have kept using the Python version task...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't yell at me, but I forced push to get rid of it. Turns out I had already dropped the commit locally last month, forgot about it, and commited changes over it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

CI was building the image twice: once with dev dependencies and again
without. Separating the pipenv command into separate layers allows the
second build in CI to take advantage of the cache for the base
dependencies that it will share across both builds.

Install numpy along with the dev dependencies within the container.
Previously it was installed in CI only, but this meant extra work for
those running tests locally.

Install numpy to the correct site.
@coveralls
Copy link

coveralls commented Mar 8, 2021

Coverage Status

Coverage increased (+34.7%) to 91.566% when pulling 46fc728 on bug/tests/nsjail into 59a1bf4 on master.

The branch needs the fixes from #94 to make the tests pass.
@MarkKoz
Copy link
Member Author

MarkKoz commented Mar 8, 2021

@jb3 One of the tests is failing. This is a similar issue to what #94 was trying to fix, but the test still fails despite merging that into this branch.

======================================================================
ERROR: test_stdout_flood_results_in_graceful_sigterm (tests.test_nsjail.NsJailTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/snekbox/snekbox/tests/test_nsjail.py", line 188, in test_stdout_flood_results_in_graceful_sigterm
    result = self.nsjail.python3(stdout_flood)
  File "/home/runner/work/snekbox/snekbox/snekbox/nsjail.py", line 236, in python3
    child.rmdir()
  File "/usr/local/lib/python3.9/pathlib.py", line 1352, in rmdir
    self._accessor.rmdir(self)
OSError: [Errno 16] Device or resource busy: '/sys/fs/cgroup/memory/snekbox-976324a6-c789-49eb-b88e-4702e4ac0626/NSJAIL.901'

Do you have any ideas? Oddly enough, the tests all pass locally.

@jb3
Copy link
Member

jb3 commented Mar 8, 2021

So I guess the child cgroups are still busy. I'll check it out.

@MarkKoz
Copy link
Member Author

MarkKoz commented Mar 8, 2021

Turns out that killing the parent process does not kill its children. Therefore, we have nsjail's children (which are Python processes in this case) sticking around preventing child cgroups from being removed. This will be addressed in a separate PR.

@MarkKoz MarkKoz merged commit bc05ed1 into master Mar 8, 2021
@MarkKoz MarkKoz deleted the bug/tests/nsjail branch March 8, 2021 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CI Related to continuous intergration and deployment area: tests Related to tests (e.g. unit tests) type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants