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

Add Clickhouse module #648

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

tomershafir
Copy link

@tomershafir tomershafir commented Sep 4, 2023

Add basic clickhouse module

@netlify
Copy link

netlify bot commented Sep 4, 2023

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit 47a9adf
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-node/deploys/65ae97a1e56c580008b46a3a
😎 Deploy Preview https://deploy-preview-648--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, @tomershafir ! I've left some comments.

Comment on lines 60 to 63
if (this.hostConfigPathXml)
this.withCopyFilesToContainer([{source: this.hostConfigPathXml, target: CONFIG_PATH_XML, mode: CONFIG_FILE_MODE}]);
if (this.hostConfigPathYaml)
this.withCopyFilesToContainer([{source: this.hostConfigPathYaml, target: CONFIG_PATH_YAML, mode: CONFIG_FILE_MODE}]);
Copy link
Member

Choose a reason for hiding this comment

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

Although, those are very convenient, sometimes, can confuse to users when having multiple configurations. I'm not a ClickHouse expert, so, for now my suggestion would be to do not support those OOTB but rather have examples using the withCopyFilesToContainer as part of the documentation.


function createClickhouseContainerHttpClient(container: StartedClickhouseContainer) {
return createClient({
host: `http://${container.getHost()}:${container.getHostPorts().http}`,
Copy link
Member

Choose a reason for hiding this comment

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

is this should be returned by the container implementation for easy access?

Copy link
Author

Choose a reason for hiding this comment

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

I think the client should be a different module rather than part the container abstraction
it also couples the dev to a dep he may not want (even though it may make sense to couple because its an official client), for example qryn project doesnt use this client atm

Comment on lines 93 to 95
public getHostPorts(): {http: number; native: number} {
return {http: this.httpHostPort, native: this.nativeHostPort}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think the urls should be returned instead of the ports.


function createClickhouseContainerHttpClient(container: StartedClickhouseContainer) {
return createClient({
host: container.getHttpUrl("http"),
Copy link
Member

Choose a reason for hiding this comment

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

Due to the current support the getHttpUrl() can return the http protocol. If, at some point in the future, https is supported another method/fn can be added or revisited

@cristianrgreco cristianrgreco added enhancement New feature or request minor Backward compatible functionality labels Oct 26, 2023
@djakielski
Copy link
Contributor

@tomershafir please add your module under modules add file https://github.com/testcontainers/testcontainers-node/blob/main/mkdocs.yml. Otherwise it will be missing in the documentation.

@tomershafir
Copy link
Author

done, @cristianrgreco hey, can you merge?

@cristianrgreco
Copy link
Collaborator

Thanks @tomershafir, please address the linting issues. The security alerts could also be solved by replacing Math.random() with a uuid (we have a UUID generator). I know it's for test only but it'd be nice not to get alerted each time a change is made here.

@tomershafir
Copy link
Author

done

Comment on lines 76 to 78
public getNativeUrl(schema: string): string {
return this.toUrl(schema, this.hostNativePort)
}
Copy link
Member

Choose a reason for hiding this comment

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

can you provide an example of this please? or better add a test :)

Copy link
Author

Choose a reason for hiding this comment

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

as clickhouse-js doesnt support native protocol I removed the js methods. Added https one

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

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

LGTM

@cristianrgreco
Copy link
Collaborator

Thanks @eddumelendez 🙂 Will merge when the build passes

@cristianrgreco
Copy link
Collaborator

@tomershafir This test is failing: should work with custom database and custom yaml config (120432 ms)

@cristianrgreco cristianrgreco changed the title add basic clickhouse module Add Clickhouse module Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor Backward compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants