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

Replace TempDir with TestArrayUri #102

Merged
merged 1 commit into from
May 28, 2024
Merged

Conversation

davisp
Copy link
Collaborator

@davisp davisp commented May 28, 2024

This removes our usage of the TempDir for tests and instead uses a new TestArrayUri trait. Eventually this will allow us to dynamically change whether tests run against a local file system or a remote cloud service instance.

This does not yet support actually running against the cloud service as that will take more infra setup to get going. However, it should be as simple as creating a new TestCloudUri struct which then implements the TestArrayUri trait. Then the test_util::get_uri_generator can return either trait implementation at runtime based on an environment variable or whatever is easiest in CI.

This removes our usage of the TempDir for tests and instead uses a new
TestArrayUri trait. Eventually this will allow us to dynamically change
whether tests run against a local file system or a remote cloud service
instance.

This does not yet support actually running against the cloud service as
that will take more infra setup to get going. However, it should be as
simple as creating a new TestCloudUri struct which then implements the
TestArrayUri trait. Then the `test_util::get_uri_generator` can return
either trait implementation at runtime based on an environment variable
or whatever is easiest in CI.
@davisp davisp requested a review from rroelke May 28, 2024 17:20
use crate::array::*;
use crate::config::Config;
use crate::query::{QueryBuilder, WriteBuilder};
use crate::test_util::{self, TestArrayUri};
Copy link
Member

Choose a reason for hiding this comment

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

Huh, what does self mean here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its the equivalent to use crate::test_util so that you can write test_util::get_uri_generator().

Copy link
Member

Choose a reason for hiding this comment

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

Neat!

self.base_dir()
}

fn with_path(&self, path: &str) -> TileDBResult<String> {
Copy link
Member

Choose a reason for hiding this comment

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

This resolves correctly?
It must, since you have a passing CI. I'm surprised though. Does it break if you use the trait?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what resolution you're asking about here? The self.with_path(path) call and how its picked the TestDirectory implementation vs the trait-method-which-becomes-recursive issue? I contemplated if I'd need to cast things there but just went with the obvious first and it worked so I stopped thinking about it.

I think the "cast required to pick an implementation" only kicks in when you have multiple traits with duplicate names but I'd have to go read the spec closely to get to the root of it.

}

fn with_path(&self, path: &str) -> TileDBResult<String> {
self.with_path(path)
Copy link
Member

Choose a reason for hiding this comment

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

Do you ever envision a different implementation? This could be a provided method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I waffled on that but had written the TestDirectory implementation before defining the trait. I'll go back and make it a provided method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out the VFS tests (which can't run against the REST api) were using this so I had to keep the implementation on TestDirectory. Though its now provided so the impl TestArrayUri for TestDirectory doesn't have to specify it at least.

@davisp davisp merged commit b5caa7d into main May 28, 2024
2 checks passed
@davisp davisp deleted the pd/sc-46438/add-test-array-uri branch May 28, 2024 20:23
@rroelke
Copy link
Member

rroelke commented May 28, 2024

Tables repo needs something similar too now that I think about it

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.

2 participants