Skip to content

Conversation

@Nathanjp91
Copy link
Contributor

Problem

No E2E tests for darwin cli exists

Solution

Add in E2E tests and fixes to get tests running

Changelog

Testing added for create and basic push tests via cli

@linear
Copy link

linear bot commented Sep 15, 2023

f._error("Darwin seems unreachable, please try again in a minute or contact support.")
except GracefulExit as e:
f.error(e.message)
f._error(e.message)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how this made it in but may as well stay

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that is a bit weird, but nvm as you say.

Copy link
Contributor

@owencjones owencjones left a comment

Choose a reason for hiding this comment

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

Good stuff man, sorry I wasn't about to help out more tail end of the week.

pip install pytest pytest-describe
- name: Run Tests
run: python -m pytest -W ignore::DeprecationWarning
e2e:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll need to transplant these in the new refactor of the GHAs, but that's my problem for not getting them in first.

pip install --upgrade setuptools
pip install --editable ".[test,ml,medical,dev]"
pip install pytest pytest-describe
- name: Run Tests
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be added as a step under the existing installs from the tests job, but I'd say in this instance, I've got a load of pending changes to this area, including this, so I can incorporate it.

# pytest.datasets = datasets
setattr(pytest, "datasets", datasets)
# Set the environment variables for running CLI arguments
os.environ["DARWIN_BASE_URL"] = server
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻

)

return result.returncode, result.stdout.decode("utf-8"), result.stderr.decode("utf-8")
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Good work around, but I really hate this for the stdlib inconsistencies!

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it makes sense given it's just a byte string, but still

@@ -0,0 +1,68 @@
import re
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice first test. Good to see it starting to come together.

E2E_ENVIRONMENT: ${{ secrets.E2E_ENVIRONMENT }}
E2E_TEAM: ${{ secrets.E2E_TEAM }}


Copy link
Contributor

Choose a reason for hiding this comment

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

too much newlines

pip install pytest pytest-describe
- name: Run Tests
run: python -m pytest -W ignore::DeprecationWarning
e2e:
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about moving this to separate file?

setattr(pytest, "datasets", datasets)
# Set the environment variables for running CLI arguments
environ["DARWIN_BASE_URL"] = server
environ["DARWIN_TEAM"] = team_slug
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally, after setting ENV's you want to revert them, as this is change to global state.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's slightly misleading - it looks like a change to global state, but posix env vars, which these will be in most cases, are in one of two scopes, global or local - os.environ is changing the local (process) scope, at least in a posix-like system.

In windows, it might set it globally.

Obv, unsetting these wouldn't hurt, just adding context.

try:
return result.returncode, result.stdout.decode("utf-8"), result.stderr.decode("utf-8")
except:
return result.returncode, result.stdout.decode("cp437"), result.stderr.decode("cp437")
Copy link
Contributor

Choose a reason for hiding this comment

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

no newline

if __name__ == "__main__":
pytest.main(["-vv", "-s", __file__])


No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

no newline

assert local_dataset.name is not None



Copy link
Contributor

Choose a reason for hiding this comment

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

is this different amount of lines between tests intended?

api_key = environ.get("E2E_API_KEY")
team_slug = environ.get("E2E_TEAM")


Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor

@owencjones owencjones left a comment

Choose a reason for hiding this comment

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

Yep, like it, all looks good, and the slack integ is good blueprint for the incoming one from my branch

{
"channel": "#${{ vars.SLACK_CHANNEL }}",
"username": "${{ vars.SLACK_USERNAME }}",
"text": "Nightly E2E run failed <!subteam^S04T5MWDHJ6>: https://github.com/v7labs/darwin-py/actions/runs/${{ github.run_id }}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Fun fact: you can also email this id and send a message.

f._error("Darwin seems unreachable, please try again in a minute or contact support.")
except GracefulExit as e:
f.error(e.message)
f._error(e.message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that is a bit weird, but nvm as you say.

setattr(pytest, "datasets", datasets)
# Set the environment variables for running CLI arguments
environ["DARWIN_BASE_URL"] = server
environ["DARWIN_TEAM"] = team_slug
Copy link
Contributor

Choose a reason for hiding this comment

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

It's slightly misleading - it looks like a change to global state, but posix env vars, which these will be in most cases, are in one of two scopes, global or local - os.environ is changing the local (process) scope, at least in a posix-like system.

In windows, it might set it globally.

Obv, unsetting these wouldn't hurt, just adding context.

del environ["DARWIN_BASE_URL"]
del environ["DARWIN_TEAM"]
del environ["DARWIN_API_KEY"]

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, @brain-geek turns out it doesn't matter anymore anyway!

@Nathanjp91 Nathanjp91 merged commit 5485f1b into master Sep 19, 2023
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.

4 participants