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

System test framework #392

Merged
merged 11 commits into from Aug 12, 2020
Merged

System test framework #392

merged 11 commits into from Aug 12, 2020

Conversation

quaark
Copy link
Member

@quaark quaark commented Aug 3, 2020

Added a system test framework.

  • With a base TestMLRunSystem class to extend.
  • The system tests connect to an existing Iguazio system in order to run the tests(for now) using an env.yml file to specify the address and credentials.
  • A custom decorator (@TestMLRunSystem.skip_test_env_not_configured) is put above each system test class in order for the tests to be skipped if the env.yml isn't configured properly.
  • make test-system creates a docker container that only does pip install mlrun[api] pytestbefore running the system tests, in order to run the system tests from a user's perspective.
  • Converted the 4 existing notebook tests to real pytest tests with assertions on the runs, using the framework.

Makefile Show resolved Hide resolved
Makefile Show resolved Hide resolved
dockerfiles/test-system/Dockerfile Outdated Show resolved Hide resolved
tests/system/base.py Show resolved Hide resolved
tests/system/base.py Outdated Show resolved Hide resolved
tests/system/examples/artifacts/dask_function.py Outdated Show resolved Hide resolved
tests/system/examples/artifacts/params.csv Outdated Show resolved Hide resolved
tests/system/examples/base.py Outdated Show resolved Hide resolved
tests/system/examples/test_dask.py Outdated Show resolved Hide resolved
tests/system/examples/test_jobs.py Outdated Show resolved Hide resolved
@Hedingber Hedingber merged commit 5a94236 into mlrun:development Aug 12, 2020
Copy link
Contributor

@omesser omesser left a comment

Choose a reason for hiding this comment

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

GJ! Left some comments posthumously

RUN pip install --upgrade pytest
RUN cd /tmp/mlrun && python -m pip install --no-cache-dir ".[api]" && mv tests /tests && cd /tmp && rm -rf mlrun

CMD ["pytest", "-rf", "-v", "--disable-warnings", "/tests/system"]
Copy link
Contributor

Choose a reason for hiding this comment

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

newline eof
also in some other places


COPY . /tmp/mlrun
RUN pip install --upgrade pytest
RUN cd /tmp/mlrun && python -m pip install --no-cache-dir ".[api]" && mv tests /tests && cd /tmp && rm -rf mlrun
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Why aren't you copying tests to /tests in the first place (after line 18 COPY tests /tests)
  • What is the significance of removing /tmp/mlrun/mlrun? (add comment if needed)

Copy link
Member Author

Choose a reason for hiding this comment

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

We're removing mlrun to ensure that the testing environment is as close to a user environment as possible. As in the relevant code is in site-packages and nothing else

logger = create_logger(level='debug', name='test')


class TestMLRunSystem:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class TestMLRunSystem:
class MLRunSystemTest:

not configured,
reason=f'This is a system test, add the needed environment variables {*cls.mandatory_env_vars,} '
'in tests/system/env.yml to run it',
)(test)
Copy link
Contributor

Choose a reason for hiding this comment

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

misconfiguration should cause the tests to fail not be skipped, no?
That way we will get false positives without anything running

Copy link
Member Author

Choose a reason for hiding this comment

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

That way, CI will fail 100% of the time right now that there isn't a constant test system

'V3IO_API',
'V3IO_USERNAME',
'V3IO_ACCESS_KEY',
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these class properties (and handled via classmethods) and not simple data fields on the class instance (defined in __init__)?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are indeed static properties that relate to every object of the class, so I'm using them as intended

V3IO_PASSWORD:

# access key used to add v3io mounts to pods - e.g. 4c1c2011-618f-434a-abd6-d456770fd33c
V3IO_ACCESS_KEY:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest to put non empty placeholders - style "REPLACEME" - this is always a good idea to not have things the user needs to input default to empty string. something like this can easily go unnoticed in outputs / logs / error messages.
Something meaningful will catch the eye and be clear

@@ -0,0 +1,14 @@
# The mlrun-api URL. e.g. https://mlrun-api.default-tenant.app.hedingber-28-1.iguazio-cd2.com
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a yml file ? env key=value shouldn't be declared verbatim in a yaml (https://docs.docker.com/compose/env-file/)


kfp.compiler.Compiler().compile(dask_pipe, 'daskpipe.yaml', type_check=False)
arguments = {'x': 4, 'y': -5}
artifact_path = '/User/test'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use py3 path syntax

run['spec'],
parameters={'x': 4, 'y': -5},
outputs=['run_id'],
output_path='/User/test',
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants