-
Notifications
You must be signed in to change notification settings - Fork 244
Google Cloud Storage support #792
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
Conversation
This reverts commit 8f13c9d.
# Conflicts: # testcontainers-spring-boot-bom/pom.xml
|
What is an issue with taking the following approach https://github.com/googleapis/google-cloud-java/blob/main/TESTING.md#testing-code-that-uses-storage? |
|
@Aloren Moreover we have some kind of middle level "component" tests which test both integration and functionality independently of the environment outside of the "component". One of the most important requirement for such a test we have is not to replace any part of a component with test double or test implementation, but test configuration close to production as much as possible on this level. So a component should talk with the dependencies making a network call. |
|
Heads up! |
|
Sorry for the delay. |
|
Also can you pls rebase to the latest changes. |
|
@Aloren
sure, made it as a "provided" dependency.
I would say it's pretty much mature, it has about 500+ stars on github and is actively supported and developed by the maintainer. |
| <groupId>com.google.cloud</groupId> | ||
| <artifactId>google-cloud-storage</artifactId> | ||
| <version>${google-cloud-storage.version}</version> | ||
| <scope>provided</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add into the documentation that this module consumes/expects this dependency to be provided by the user.
|
|
||
| @Slf4j | ||
| @Configuration | ||
| @ConditionalOnExpression("${embedded.containers.enabled:true}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add
@ConditionalOnClass(com.google.cloud.storage.Storage.class)
to this autoconfiguration, so that is does not startup and fail if user does not have google-cloud-storage on classpath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, added
embedded-google-storage/pom.xml
Outdated
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <properties> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please move these properties just before dependencies section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, moved
| @PostConstruct | ||
| protected void init() { | ||
| log.info("Creating buckets."); | ||
| buckets.forEach(this::createBucket); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to create bucket via cli, so that we do not have dependency on google-cloud-storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've just looked into the transitive dependencies of google-cloud-storage and it looks like it comes with half of the internet :), so if possible please use rest api. for bucket creation, i suppose, this won't be difficult?
https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
| /** location for buckets */ | ||
| private String bucketLocation = "US-CENTRAL1"; | ||
| /** list with predefined buckets to be created */ | ||
| private Collection<String> buckets = emptyList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bucket creation operation supports additional parameters, that may be needed by someone in the future, so lets' replace this instead with:
private Collection<BucketProperties> buckets = emptyList();
static class BucketProperties {
String name;
// other properties if needed can be added later
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me, BucketProperties introduced
embedded-google-storage/README.adoc
Outdated
| * `embedded.google.storage.projectId` `(project id for storage, default is my-project-id)` | ||
| * `embedded.google.storage.bucketLocation` `(location for buckets, default is US-CENTRAL1)` | ||
|
|
||
| * Predefined buckets: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rephrase this part to smth like:
embedded.google.storage.buckets creates buckets on startup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description changed.
| GenericContainer<?> container = new GenericContainer<>(ContainerUtils.getDockerImageName(properties)) | ||
| .withExposedPorts(StorageProperties.PORT) | ||
| .withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint( | ||
| "/bin/fake-gcs-server", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldnt we also provide -backend memory option? is is provided in examples and i don't see what is the default value for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default one is filesystem backend, which was used previously.
from now, setting it as a memory backend.
nice catch!
|
@Aloren I would discuss the The The main use case I would expect is to add Also noticing that |
|
@sergseven 2.1.6 was release successfully and is already present in sonatype. Unfortunately Maven central had sync issues on 6th April. I hope that within 48 hours artifacts will be available there as well. |
Awesome, thank you! |
|
@sergseven we've released 2.1.7 and it's already available in maven central, please use it. Thanks |
The image used as a base: https://github.com/fsouza/fake-gcs-server