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

Use pytest servers #8

Merged
merged 2 commits into from
Aug 26, 2022
Merged

Use pytest servers #8

merged 2 commits into from
Aug 26, 2022

Conversation

dtrifiro
Copy link
Contributor

closes #2

@dtrifiro dtrifiro requested a review from efiop August 18, 2022 16:47
@dtrifiro dtrifiro mentioned this pull request Aug 18, 2022
@dtrifiro dtrifiro marked this pull request as draft August 18, 2022 16:54
@dtrifiro dtrifiro marked this pull request as ready for review August 18, 2022 16:54
@dtrifiro

This comment was marked as outdated.

Comment on lines 21 to 29
@pytest.fixture
def make_gs(gs_creds):
def _make_gs():
return GCP(GCP.get_url(), gs_creds)
def make_gs(request):
if os.getenv("DVC_GS_NO_EMULATOR", None):

def _make_gs():
return GCP(GCP.get_url(), "")

else:
gcs_path = request.getfixturevalue("gcs_path")
fake_gcs_server = request.getfixturevalue("fake_gcs_server")

def _make_gs():
return FakeGCP(
str(gcs_path).replace("gcs://", "gs://"),
endpoint_url=fake_gcs_server,
)

return _make_gs
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do similar to dvc-s3: have gs fixture that is always using fake server and have a real_gs fixture that uses real gs. Tests should use gs(fake) always, but if one would need to debug stuff, he could use real_gs manually.

@dtrifiro dtrifiro force-pushed the use-pytest-servers branch from f6dc151 to e9c956f Compare August 22, 2022 14:52
@dtrifiro dtrifiro marked this pull request as draft August 22, 2022 15:01
@dtrifiro dtrifiro force-pushed the use-pytest-servers branch from e9c956f to f7e40e5 Compare August 25, 2022 20:05
@dtrifiro dtrifiro marked this pull request as ready for review August 25, 2022 20:05
@dtrifiro
Copy link
Contributor Author

We were getting errors when setting up pytest-servers fixtures because of -n=auto: we were trying to setup multiple session-scoped fixtures at once. I'll work out something in pytest-servers in the future to support (see iterative/pytest-servers#50), but for now I got rid of -nauto in gha.

Note that test_import is still broken, and this will be taken care of in #9

@dtrifiro dtrifiro force-pushed the use-pytest-servers branch 2 times, most recently from 552e5f5 to e196309 Compare August 25, 2022 20:47
@dtrifiro dtrifiro force-pushed the use-pytest-servers branch from e196309 to 2893837 Compare August 26, 2022 09:57
@efiop
Copy link
Contributor

efiop commented Aug 26, 2022

@dtrifiro Not sure I understand, so is this ready for review/merge? Seems like there are still some cloud credentials issues in the log?

@dtrifiro
Copy link
Contributor Author

The cloud credentials messages in the logs are just debug messages, and are related to GCSFileSystem trying to get credentials from various sources (including environment) before giving up, see
https://github.com/fsspec/gcsfs/blob/fef6c0b098342a95990fd5aad8c3353d257f8d1b/gcsfs/credentials.py#L225-L242.

Note that these credentials are not used to access storage.googleapis.com because endpoint_url is overriden.

We could get rid of those warnings by setting GOOGLE_APPLICATION_CREDENTIALS to the path of a service account private key json, something similar to what we do with S3 with fake_creds_file. Trying to decide whether it's better to have a fixture for that here or in pytest-servers, although I'm opting for the former.

@efiop
Copy link
Contributor

efiop commented Aug 26, 2022

@dtrifiro So this is ready, right? Feel free to merge then.

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.

try gs emulator
2 participants